Sobes.tech
Middle+

Are you familiar with the 12-Factor app design concept?

sobes.tech AI

Answer from AI

Yes, familiar. The 12 Factor app methodology is a set of principles for building SaaS applications aimed at increasing portability, scalability, and flexibility.

Main principles:

  1. Codebase: One codebase tracked in version control, many deploys.
  2. Dependencies: Explicitly declare and isolate dependencies.
  3. Config: Store configuration in the environment, not in the code.
  4. Backing services: Treat backing services (databases, message queues, etc.) as attached resources.
  5. Build, release, run: Strictly separate stages of build, release, and run.
  6. Processes: Execute the app as one or more stateless processes.
  7. Port binding: Export services via ports, self-contained.
  8. Concurrency: Horizontal scaling via the process model.
  9. Disposability: Fast startup and graceful shutdown for resilience.
  10. Dev/prod parity: Maximize similarity between development, staging, and production environments.
  11. Logs: Treat logs as a stream of events sent to stdout.
  12. Admin processes: Run administrative and migration tasks as one-off processes.

These principles help create applications that are easy to deploy and scale in modern cloud environments.

// Example of storing configuration in the environment
// package main

// import (
// 	"fmt"
// 	"os"
// )

// func main() {
// 	dbHost := os.Getenv("DATABASE_HOST") // Read environment variable
// 	if dbHost == "" {
// 		dbHost = "localhost" // Default value
// 	}
// 	fmt.Printf("Using database host: %s\n", dbHost)
// }