Twelve-Factor app

The twelve-factor app is a methodology for building applications.

These 12 best practices are designed to enable applications to be built with portability and resilience when deployed to the web.

# Name Description
1 Codebase One code base tracked in a version control.
Each app should have a single code base (in git for example) that can be deployed to multiple environments (int, homol, prod)
2 Dependencies Explicitly declare and isolate dependencies.
Use a dependency manager (like npm, maven) and avoid relying on system-wide packages
3 Config Store configuration in environment variables, not in code.
This keeps secrets and environment-specific settings separate from the application logic
4 Backing services Treat external service (like databases, queues, caches, api, ...) as attached resources
They should be easily swappable and replace without code changes (e.g. switching from MySQL to PostgreSQL)
5 Build, release, run Strictly separate build, release, and run.
Each stage should be independent and reproducible
6 Processes Execute the app as one or more stateless processes.
Persist state in a backing service (db, queue, ...) not in memory or local disk
7 Port binding Export services via port binding.
The app should be self-contained and not rely on an external web server, it should listen on a port and serve requests directly
8 Concurrency Scale out via the process models.
Use multiple processes for different workloads (e.g. web, worker) instead of threads within a single process
9 Disposability Maximize robustness with fast startup and graceful shutdown.
Processes should start quickly and handle termination cleanly to enable rapid scaling and deployment.
10 Dev/Prod parity Keep development, staging, and production as similar as possible.
Minmize gaps in environment, dependencies, and processes to reduce deployment surprises
11 Logs Treat logs as event streams.
Write logs and let the execution environment aggregate and store them, rather than managing log files
12 Admin processes Run admin/management tasks (like migrations or one-off scripts) as one-off processes in the same environment as the app, using the same codebase and config)