Best Practices

An app generated by Imagine follows known best practices outlined in the twelve-factor app methodology.


In this document, we have outlined the twelve-factor app principles as well as how we incorporate these when generating the code for an app.

Codebase


One codebase tracked in revision control, many deploys
  • The app comes with built-in support for Github actions for running lint, unit tests, test coverage, code quality checks
  • The app has a .gitignore that makes sure that temporary files are not commited to git
  • The app has a high quality README file with the key commands available

Dependencies


Explicitly declare and isolate dependencies
  • The app uses mainstream package managers like yarn, npm, pip, poetry
  • The app uses a single place to manage all dependencies
  • The app ships with the latest available versions of all dependencies
  • The app has dependabot integrated to help you keep all dependencies up to date with latest versions.

Config


Store config in the environment
  • There are no hard-coded passwords or access keys in the source code
  • The app has built-in support for multiple environments
  • The app loads required keys from environment variables
  • The app uses standard names for environment variables

Backing services


Treat backing services as attached resources
  • The app has support to connect to mainstream external databases
  • Additionally, we will be releasing support for the following in upcoming versions:
    • Integration with logging service providers
    • Integration with monitoring systems
    • Integration with product analytics services

Build, release, run


Strictly separate build and run stages
  • The app comes with robust commands to trigger build, release and run stages
  • The build creates optimized artifacts
  • The app has providers flexibility to run in production using different options for server containers

Processes


Execute the app as one or more stateless processes
  • The app runs as a stateless proces
  • There is support built-in for runnig with docker compose

Port binding


Export services via port binding
  • The app has ability to configure the port to run the service on

Concurrency


Scale out via the process model
  • The app is stateless and can be scaled horizontally
  • The app offers support for server containers that have ability to run multiple processes

Disposability


Maximize robustness with fast startup and graceful shutdown
  • App start and stop times are instant

Dev/prod parity


Keep development, staging, and production as similar as possible
  • The app code base is identical for different environments
  • The app has support to provide different keys for different environments using environment variables

Logs


Treat logs as event streams
  • Ability to send logs to a service provider of your choice is coming soon

Admin processes


Run admin/management tasks as one-off processes
  • The app has support for various dashboards like Django admin, Admin Bro for Node, Swagger dashboard, GraphiQL dashboard.