Monorepo
How it works
All projects live in a single directory tree within one repository. Dedicated tools (e.g. Nx, Turborepo, Bazel) analyse inter-project dependencies and build a task graph, so build, test, and lint operations run only for the projects affected by a change and their dependents. Task results are cached (locally and remotely), allowing unchanged work to be skipped. A single change can atomically modify several projects at once in one commit, with a shared CI pipeline validating the whole. Organizations with very large codebases additionally use specialized version-control systems that scale to billions of lines (Piper at Google, Sapling at Meta).
Problem solved
With many separate repositories (polyrepo), sharing code requires publishing and versioning packages, and a change spanning several projects fragments into many manually coordinated commits and pull requests. This causes context loss, duplicated configuration, and dependency-version drift. A monorepo addresses these by enabling atomic cross-project changes, a single source of truth for dependencies, and code sharing without the overhead of package publishing.
Components
A single repository (e.g. Git) holding the entire organization's or product's code in one directory tree.
Explicitly separated projects (applications, libraries, tools) with encapsulation, distinguishing a monorepo from mere code colocation.
A model of inter-project dependencies used by tooling to determine what to build and test after a change.
Tools (Nx, Turborepo, Bazel) that run tasks only for changed projects and cache results locally and remotely.
Implementation
Evolution
The article by Rachel Potvin and Josh Levenberg, 'Why Google Stores Billions of Lines of Code in a Single Repository', popularized the large-scale monorepo.
Hyperparameters (configurable axes)
How fine-grained projects and their mutual dependencies are defined.
Strategy for caching task results (locally and/or remotely), key to monorepo scalability.
How build/test tasks are parallelized and scheduled based on the dependency graph.
Ownership and permission rules (e.g. CODEOWNERS) defining team responsibility for parts of the monorepo.