The Timezynk backend is composed of a number of microservices each presenting independent APIs. The guidelines come from 12 Factor apps, please read that resource first. Here are the rules every microservice in the ecosystem MUST follow:
API namespacing and versioning
The microservice should publish its API under a namespace and version, for example:
All configuration should be done using environment variables. When starting the service with one or more required variables unset, it should print all used environment variables. Some environment variables are standardized in the production environment and must have exactly these names, if they are used:
MONGO_URL : MongoDB url for the cluster and database to use, i.e.
TZBACKEND_URL : URL pointing to the root of the microservice load balancer, i.e. https://api.timezynk.com/api
CLIENT_ID : OAuth2 Client ID for authenticating with tzbackend
CLIENT_SECRET: Oauth2 Client Secret for authenticating with tzbackend
BIND_PORT: The TCP port to listen for connections on
NSQLOOKUP_SERVERS: List of NSQLookup servers for connection to the message queue.
If the microservices needs to persist data, it MUST do so using mongodb. Every microservice MUST use its own mongodb database and is forbidden to read or connect to any other database.
Communication with other microservices are done over the published HTTP APIs or over the NSQD message queue. If the service depends on coordination of several other services, assume that one of them could be down and cache the data locally before contacting the other services.
All microservices should publish prometheus compatible metrics. Both service specific metrics and basic system metrics like CPU- and memory-usage should be published. The metrics MUST be available on
Logging should be done to STDOUT, preferably in JSON format.
Microservices should have automated unit tests. The tests should be run by Gitlab pipelines on every commit and output results as a JUnit test report.
Linting should be set up and run by Gitlab pipelines on every commit.
Microservices are deployed using Docker containers running in ECS.