Vezi pagina în română

IT Glossary

What is a monorepo (single code repository) and how does it work?

One code repository for several projects: coordinated changes and shared code without copies, paid for with build tooling and clear ownership rules.

6
sections
5
questions answered

A monorepo is a single version-control repository (usually Git) holding the code of several distinct projects — website, mobile app, API, shared libraries — with defined relationships between them, so that a change touching all of them is made and tested in one commit. The most cited case is Google: in a Communications of the ACM paper (July 2016), Potvin and Levenberg describe a repository of about one billion files, about 35 million commits and 86 TB, used by 95% of the company’s developers (figures from January 2015). Google built an internal system, Piper, because no commercial or open-source tool handled that scale. The same authors say plainly that the model demands ongoing investment in tooling (code search, automated testing, builds), brings complexity and unnecessary dependencies, and is not for everyone — it fits poorly where large parts of the code must stay hidden between teams.

At a company without that scale the idea is the same. Ten teams, ten repositories, ten copies of one function each modified slightly differently: that is software entropy after a few years of growth. A monorepo gathers them into one shared building with a single source of truth for shared components. It becomes relevant when several products share code: it cuts duplication and friction between teams, but needs suitable tooling (Nx, Turborepo, Bazel) and ownership rules — otherwise the shared building turns into a crowded corridor.

Why it matters for your business

One source of truth for shared code

Shared components — a design system, invoicing logic, validation rules — exist once and are used everywhere; divergent clones maintained in parallel disappear.

Atomic changes across several projects

A change to the contract between an app and its API happens in a single operation, verified together — no more windows where half the systems still run the old version.

Full visibility for teams

Any developer can see how their code is used across the company — refactoring becomes safer and knowledge circulates between teams naturally.

How a monorepo works

A typical layout separates applications from shared libraries: an apps/ folder with the website, mobile app and API, and a packages/ folder with interface components, validation rules and the API client. The package manager links the folders through workspaces (pnpm has built-in support for monorepositories, and npm and Yarn have their own workspaces), so shared libraries never need to be published anywhere.

Without tooling, every commit would run every test. Monorepos therefore use build tools that run only what a change touched and cache the results: Nx has the nx affected command, Turborepo has the --affected option, and Bazel builds a full dependency graph. Example: a company with a web app, a mobile app and an API uses the same Romanian tax-ID (CUI/CIF) validation and the same e-Factura client; a change to the validation reaches all three in one commit.

Monorepo vs polyrepo

Polyrepo means each project has its own repository and shared code is published as versioned packages. Strengths: separate access per repository and independent release cycles. Cost: diverging versions of the shared code and changes across several repositories coordinated by hand.

A monorepo flips the balance: a change across projects is atomic and shared code lives in one place, but access can no longer be separated per project and builds need tooling. Do not confuse this choice with application architecture: monorepo says where the code lives, monolith or microservices says how it is delivered.

Want an estimate for your project?

Message us on WhatsApp. We reply the same working day, and the first 30-minute call is free.

Book a free call

Google, Meta and Microsoft: what the sources say

Google: the Communications of the ACM paper (July 2016) reports, as of January 2015, about one billion files, about 35 million commits and 86 TB, with 95% of developers working in this repository. Bazel is the public flavor of the tool Google uses to build its server software internally, according to the bazel.build FAQ.

Meta: in a post dated 7 January 2014, Meta (then Facebook) wrote that its main repository was many times larger than the Linux kernel and that it kept it as one because splitting it would make large atomic refactorings harder; it extended Mercurial rather than splitting the code. In November 2022, the Sapling announcement describes its monorepo as having tens of millions of files, tens of millions of commits and tens of millions of branches.

Microsoft: not the whole company, but the Windows codebase. On 24 May 2017, Brian Harry described the move from more than 40 repositories to a single Git repository of about 3.5 million files, about 300 GB and about 4,000 engineers, using GVFS (Git Virtual File System). All three had to build or extend their own version-control tooling — a scale that a company with 5–50 developers never reaches.

For a company: when it pays off and what the risks are

It pays off when several products share code, are run by the same or closely related teams, and you want coordinated changes. It does not when projects share nothing or belong to different clients.

The most neglected risk is access. Git has no per-folder read permissions: anyone who clones the repository sees all the code. A CODEOWNERS file (GitHub) only requests review or approval from the owners of an area, and git sparse-checkout only reduces which folders are checked out, it does not restrict access. Code for different clients, or code an external team must not see, deserves separate repositories.

When code is handed over to a client, a monorepo shared with other clients cannot be handed over as it is; who owns the code is settled in the contract, and the repository layout must allow the separation.

Frequently asked questions

Does a monorepo mean the application is a monolith?

No. Monorepo describes where the code lives, in one repository; monolith describes how the application is delivered, as one block. You can run 30 independent microservices, each released on its own, all hosted in the same monorepo, with no contradiction at all.

Doesn’t the repository become too large and slow?

At the scale of an ordinary company, the real problem is build and test time, not Git. Nx (nx affected) and Turborepo (--affected) run only what a change touched and cache results. Microsoft needed GVFS only at about 300 GB, in the Windows repository.

When is a monorepo a bad idea?

When projects share nothing, belong to different clients, or an external team may see only part of the code. Git offers no per-folder read rights, and the authors of the Google paper say plainly that the model is not for everyone.

Which tools are used for a monorepo?

For JavaScript and TypeScript: workspaces in pnpm, npm or Yarn. Nx and Turborepo add builds for only what changed, plus caching. Bazel suits large multi-language code. Version control stays in Git; no tool decides on its own who is responsible for which code.

Monorepo or polyrepo for a small company?

With one product and one team either works, and polyrepo is simpler. With two or more products sharing code, a monorepo with workspaces reduces copying. Code for a client that must be handed over or kept separate deserves its own repository.