Skip to content

Instantly share code, notes, and snippets.

@croraf
Last active February 24, 2019 01:02
Show Gist options
  • Save croraf/ee7017bdda3e3c65881936173df2cbc9 to your computer and use it in GitHub Desktop.
Save croraf/ee7017bdda3e3c65881936173df2cbc9 to your computer and use it in GitHub Desktop.
orderme app - backend interfaces description
orderme app backend interfaces with other parts of the app in the following ways:
1. KOA server
a) serves static resources
- single HTML template, which gets managed by React JS - single page application
- webpack-bundled JS which does everything that is done on frontend
- images
b) exposes REST API (endpoints)
REST API is defined by swagger, and can be explored on exposed swagger ui URL (https://order1.herokuapp.com/swagger).
What comes on REST endpoints passes through 3 layers.
- swagger specification (apiSpec folder), which makes request validation
- koa router part (api folder), which should be 1-1 bound on the swagger apiSpec defined endpoints,
should contain little to no logic, only route the request to the correct business function for processing
- business part (business folder), which contains logic to actually processes the request
If needed the business part will contact the other interfaces (make outgoing HTTP request, contact database, ....)
c) manages websocket communication
Websocket link to the fronted part of the app is added, as the server has to initiate some sending to the client (frontent).
The same KOA server is configured to handle websocket communication.
`ws` folder contains the actual websocket interfacing.
2. Database interface
`dal` folder handles the actual interfacing towards mongo database that runs as a service on separate cloud.
3. Sporadically the backend may generate some HTTP requests to outer resources (like Facebook/Google services).
It uses `request-promise` library in place where needed, without any special interface layer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment