Codebase, Dependencies, and Config Factors
What you'll learn: You'll understand the first three principles of the Twelve-Factor App methodology that create a solid foundation for deployable applications.
The First Three Factors
The Twelve-Factor App methodology begins with three fundamental principles that address how you structure and manage your application's foundation:
I. Codebase: One Codebase Tracked in Revision Control
Your application should have exactly one codebase tracked in version control (like Git), but it deploys to many environments. This means:
- One repository per application (not multiple repos with duplicated code)
- All environments (dev, staging, production) deploy from this same codebase
- Different versions or branches may be deployed, but the source is unified
Analogy: Think of your codebase like a master recipe — there's one authoritative version, but you might make it in different kitchens (environments) or adjust quantities (configurations).
II. Dependencies: Explicitly Declare and Isolate
Never rely on system-wide packages existing. Instead:
- Declare all dependencies explicitly (you've learned this with dependency management)
- Use dependency manifests and lock files
- Isolate dependencies to prevent "works on my machine" problems
III. Config: Store Config in the Environment
Configuration that varies between environments must be separated from code:
- Use environment variables, not config files in source control
- Secrets and environment-specific settings stay out of the codebase
- The same code artifact runs everywhere with different configuration
These three factors work together: your one codebase declares its dependencies explicitly and reads config from the environment, making it truly portable and deployable anywhere.
Key Takeaway: The first three factors establish that you maintain one codebase in version control, declare all dependencies explicitly, and externalize all environment-specific configuration — creating a foundation for consistent, reproducible deployments.