DEV Community

Naval Kishor Upadhyay
Naval Kishor Upadhyay

Posted on

12-Factor App Principle #1: Codebase

Goal

Keep one clear, reliable source for your application code so everyone — developers, testers, and managers — works from the same version, making collaboration smoother and deployments predictable.


What It Means

A codebase is like the master copy of your app — all the instructions the software needs to run. It’s stored in a special system called version control (e.g., Git), which tracks every change over time.

  • One codebase can be used for multiple deployments (development, staging, production), but they all come from the same original set of files.
  • Don’t have two different codebases for the same app — that causes confusion and errors.
  • If two apps share some functionality, put that shared logic into a separate library that both can use, rather than mixing the apps together.

Why It Matters

  • Single source of truth – Everyone, from developers to project managers, can see and track the exact version of the app that’s live.
  • Consistency – The same code runs in testing and production, reducing surprises when launching features.
  • Faster fixes – If a bug is found, the team knows exactly where to look.
  • Easier scaling – Adding new environments or servers is straightforward because they all use the same code.

Example

Imagine a company that runs an online store:

  1. There’s one master copy of the store’s code in GitHub.
  2. Developers create feature branches to add new functions (e.g., a new payment method).
  3. Once ready, changes are tested in a staging environment before being merged into the production branch.
  4. Everyone knows exactly what’s running on the live website.

Best Practices

  • Always use version control to keep a history of changes and recover old versions if needed.
  • Keep one repository per application for clarity and control.
  • Separate shared code into libraries so multiple apps can use it without duplication.
  • Tag and label releases so managers and stakeholders can track which version is live.
  • Automate deployments so updates are smooth and error-free.

Takeaway

One app should always have one central codebase.

This creates transparency, improves teamwork, reduces errors, and makes it easier for both technical and non-technical teams to understand what’s running and where.

Top comments (0)