{"canonical_url":"https://engineer.company/glossary/monorepo/","content_markdown":"# Monorepo\n\n## What it is\n\nA monorepo stores several related projects in one version-control repository. It\nmay contain an API, web app, shared library and jobs that can each build or\ndeploy separately. A contributor can change a library and its consumers in the\nsame commit. The repository gives people and automation a common view of the\nversions that belong together.\n\nThe build graph matters more than the number of directories. It identifies which\nprojects depend on a shared component and which outputs can reasonably be built,\ntested or released separately. A build tool can use declared dependencies and\nfile inputs to find the parts affected by a change. A change to a shared library\nmight need several suites. A change to one application's documentation might\nneed only its own checks.\n\nA monorepo also needs ownership. Teams can own individual projects, common types\nor deployment configuration. Some rules apply across the repository. Other rules\nare useful only for one runtime or service. Document who can maintain each kind\nof code and how its consumers participate in changes. That makes the shared\nhistory useful without requiring everybody to understand all of it.\n\n## Why it matters\n\nConsider a developer changing a type shared by a mobile client, API and\nscheduled job. A single commit can carry the coordinated source changes and\ntheir tests. A reviewer can see the new type and which consumers it affects\ntogether. The resulting artefacts may still reach users at different times. An\nolder mobile app can remain installed while the API has already changed.\nCompatibility across deployed versions remains a separate requirement.\n\nThe monorepo also changes how a team pays for checks. Running every build on\nevery file change can consume the time saved by sharing the source. Declaring\ndependencies lets the team test the affected parts sooner. That declaration\nneeds evidence. A tool that bases its decision on a directory name alone can\nmiss changes to shared schemas, config or scripts that generate a file consumed\nelsewhere.\n\nCross-project changes can make standards easier to distribute when the same\ntools and rules apply. The group also needs clear handling for projects that\nhave different requirements. A small library might have a different test runner\nfrom a web app. Document common entry points and the ownership of changes to a\nshared toolchain. The usefulness of the shared repository comes from being able\nto predict which projects and artefacts a change will affect.\n\n## What it looks like in practice\n\nImagine an application stack with a database schema, a generated client and two\nfrontends. The repository carries separate build targets. A declared dependency\nconnects both frontends to their client generator and the generated client to a\nschema input. Change a field in the schema and verify that the automation checks\neach affected consumer. Change a help page in one frontend and verify that its\nbuild and tests run without needlessly rebuilding the other application.\n\nTreat deployment as its own graph. A source change may require preparing both\nfrontends for a new API representation several releases before the feature\nbecomes visible. Record which commit and inputs produce each deployable. When an\nautomated skip decides there is nothing to publish, its evidence should include\nthe artefact and its actual dependencies. A shared Git SHA alone cannot tell you\nwhich site's output changed.\n\nEngineer's\n[repository guard-engine case study](/portfolio/built-a-268-check-guard-engine-for-the-repo/)\ndescribes validating boundaries that standard tools did not know about,\nincluding routes, migrations and translations. That kind of guard can help a\nshared repository express what projects expect from a common change. The\nillustrative build graph keeps checks tied to measured inputs and gives a\nreviewer a way to trace an affected target.\n\nAlso test cache ownership. A build can legitimately reuse an output only for the\ninputs its key covers. Change a generator, configured tool version or shared\nfile and check the selected build again. If the old output still passes the\ncache check, investigate that dependency. A useful test compares both the\nrequested target and the produced artefact.\n\n## Where it goes wrong\n\nA shared directory can become a place where every project imports whatever it\nneeds from another project. The dependency graph then inherits implementation\ndetails people never agreed to support. Give shared code a defined public\nboundary. Review how changes propagate and make tests for the actual consumer\ncontracts. Where stability matters, demonstrate a revision that can be adopted\nin more than one release window.\n\nTreat shared build changes explicitly. Updating a compiler, dependency lockfile\nor code generator can affect targets that have no modified source files of their\nown. Give those tool inputs paths in the build graph or define the group whose\noutputs they invalidate. Include a fixture that changes just the shared tool\nversion and observes the artefacts rebuilt. A fast affected-target calculation\nhas value only if its decisions remain correct for these less obvious changes.\n\nOwnership can become uncertain when several projects edit the same\nconfiguration. Identify who reviews a shared change and who can diagnose its\neffect. Use a narrow check for the project that owns the configuration and an\nintegration check where it affects more than one product. An explicit shared\nowner makes the project easier to operate when something breaks.\n\nFinally, measure the experience of making a small change. Observe check time,\naffected targets, cache results and whether a project can release its own work.\nSome changes deserve broad coverage and others have a small impact. A monorepo\nis useful when maintainers can explain and test that difference without\ndepending on a full rebuild to reveal the result.\n\n## Further reading\n\n- [Google's single-repository engineering paper](https://research.google/pubs/why-google-stores-billions-of-lines-of-code-in-a-single-repository/).\n  Describes Google's arrangement and the tooling that supports it.\n- [The Nx build mental model](https://nx.dev/docs/concepts/mental-model).\n  Explains project graphs, tasks and caching.\n- [Bazel dependencies](https://bazel.build/basics/dependencies). Describes\n  declared and actual dependencies in builds.\n\n\u003chttps://engineer.company/glossary/monorepo/\u003e\n","date_modified":"2026-11-25T07:18:46Z","description":"Track consumers of a shared change, keep checks relevant and preserve independent release decisions in one repository.","formats":{"gemtext":"https://engineer.company/glossary/monorepo/index.gmi","gopher":"https://engineer.company/glossary/monorepo/gophermap","html":"https://engineer.company/glossary/monorepo/","json":"https://engineer.company/glossary/monorepo/index.json","markdown":"https://engineer.company/glossary/monorepo/index.md","pdf":"https://engineer.company/glossary/monorepo/index.pdf"},"kind":"page","language":"en","title":"What is a monorepo?","url":"https://engineer.company/glossary/monorepo/","version":1}