Developer & Data Platforms

Monorepo

Also known as: mono-repo, monolithic repository

A monorepo is a single version control repository that holds many projects, such as apps, services, and shared libraries, rather than splitting each into its own repository.

Google, Meta, and Microsoft are famous for using them. While a monorepo makes it easy to share code and change many projects at once, it only works well with tooling that builds and tests just what changed.

Monorepo, explained at three levels

At home

Imagine keeping every family recipe in one big binder instead of separate notebooks in different kitchens. Everyone can find and reuse any recipe, and updating a shared ingredient list updates it for everyone.

At work

A monorepo puts a company's code projects in one place. Teams can reuse each other's code easily, and a change that affects many projects can be made and reviewed in a single step.

Real-world examples

At home

Carlos maintains a website, a mobile app, and a shared design library for his small business. Moving them into one monorepo meant a colour change in the library updated both apps in a single pull request.

At work

Lena is an engineering manager at a Vancouver software company with 80 repositories. Updating a security library took weeks of coordinated pull requests. After moving core services into a monorepo with Nx, the same update took one afternoon.

How it compares

featureMonorepoPolyrepo
Code locationOne repository for many projectsOne repository per project
Cross-project changesOne atomic commitCoordinated changes across repositories
Tooling needsSmart build and test toolingSimpler per repository
Team independenceLower, shared standardsHigher

Monorepos favour consistency. Polyrepos favour independence.

For analysts

The monorepo debate is really about how much teams should share. I'd decide that first, based on how often changes span multiple projects, and then choose the repository structure that fits.

History & origin

Google has kept most of its code in one repository for decades; a 2016 paper by Rachel Potvin and Josh Levenberg described it holding billions of lines of code used by tens of thousands of engineers. Meta built similar infrastructure, and Microsoft moved Windows development into a giant Git repository in 2017, creating tools to make Git scale. Google open-sourced Bazel, a descendant of its internal build system, in 2015. In the JavaScript world, tools like Lerna, Nx, and Turborepo (acquired by Vercel in 2021) made monorepos popular for smaller teams. In my view, monorepos are an organizational choice disguised as a technical one: they favour shared ownership over team independence.