# 12 Factor App Architecture ### Key Principles: 1. **Version Control**: - All code must reside in a version control system (e.g., Git) to support collaboration, auditing, and recovery. 2. **Dependencies**: - Explicitly declare dependencies via configuration files (e.g., `package.json` for Node.js) to ensure environment consistency. 3. **Config**: - Store app configuration in environment variables, not in the code, to enable flexible and secure configuration management. 4. **Backing Services**: - Treat external services (e.g., databases, message queues) as attached resources, declared as dependencies, not embedded in the code. 5. **Build, Release, Run**: - Separate the build (compilation), release (versioning), and run stages of the app lifecycle for predictable deployments. 6. **Processes**: - Organize the app into stateless processes, making scaling and recovery simpler. 7. **Port Binding**: - Export services via ports, allowing the app to be self-contained and portable across environments. 8. **Concurrency**: - Scale the app by running multiple instances (processes), allowing parallel processing and efficient resource utilization. 9. **Disposability**: - Apps should start and stop gracefully, supporting rapid scaling and reliability during crashes or redeployments. 10. **Dev/Prod Parity**: - Minimize differences between development and production environments to prevent surprises during deployment. 11. **Logs**: - Stream logs to `stdout`, treating logs as event streams, and rely on external tools for storage and analysis. 12. **Admin Processes**: - Run administrative tasks (e.g., database migrations) as one-off processes using the same environment and codebase as the app.