Skip to content

Architecture

Farhad Makiabady edited this page Nov 2, 2018 · 1 revision

Production Architecture

figure 1

architecture


components

  • Linux VM: I use Ubuntu 16.04.
  1. Download and install `java 8
  2. Set up elasticsearch
  3. upload api-server and a compiled screenerClient. Put the client in a folder. Call it "build" or something. Start the api-server with nohup or someother process management, eg nodemon.
  4. Set up a reverse proxy as pictured above (I use caddyserver).
  5. execute the seed program on your database. You should then have the database set for use. If everything worked, you should have 1 test question, with 1 test program and answering that test question true should give you 1 result.

  • Reverse Proxy: This is your user and admin entry point to the app, and your developer's remote entry point into Elasticsearch. Read a sample config
  1. listen on 0.0.0.0:80, www.<yourdomain>.x, yourdomain.x etc...
  2. forward /api to localhost:3000
  3. forward /protected to localhost:3000. Use basic auth (this is administrator stuff)
  4. serve the build folder statically e.g. ./build to root for static files. The build folder is the compiled screenerClient. http.root
  5. (optional route): forward /elastic to localhost:9200. Strip the /elastic part of the path when forwarding, eg "without /elastic". Set basic auth.

  • api-server:
  1. listens on localhost:3000
  2. handles the backend logic and talks to the database.
  3. written in typescript and ran in node.
  4. ** important: ** this program uses in memory caching for programs and the screener. If you alter the database directly, you will need to restart the server to see new programs or screener.
    • point of improvement: make state-less
  5. requires node/npm

  • Elasticsearch:
  1. listens on localhost:9200
  2. default config
    • point of improvement: lower shards
  3. used as datastore
  4. user to percolate (reverse search)
  5. requires java 8

  • screenerClient:
  1. build the screenerClient app using npm run build
  2. transfer the compiled program to the linux vm.
  3. serve the files statically with the proxy server.
  4. requires npm/node

  • utils:
  1. clone the yeg-relief/utils repo.
  2. there are various database utility programs
  3. the upload ones only (as of yet) work locally hardcoded during development
    • point of improvement: use the config.json file to maintain endpoints.
  4. running the seed program locally is advised. ts-node ~/utils/seed/run.ts this will set the database up for use.

  • user:
  1. Will use the app by entering their data into a form that has been created by the admins.
  2. Accesses the sight on port 80 or 443 (http or https)