Monorepo and Multi-Repository Design
Choose boundaries based on change patterns
A monorepo contains multiple projects in one repository, for example apps/web, apps/worker and packages/shared. One commit can change both consumers and a shared contract atomically. A multi-repository design keeps separate histories and can support distinct access controls and release cycles, but cross-repository changes require coordinated versioning and compatibility. A monorepo need not be one application or one deployment. Multiple repositories need not imply independent teams.
Reduce the working checkout
In the synthetic mono fixture, sparse checkout limits which tracked files are materialized. Cone mode accepts directory names and also retains root files and files in ancestor directories. It does not remove committed history or enforce access control. Here the web developer selects apps/web and packages/shared. The worker file is absent from the working directory but can still be read from HEAD. Full sparse checkout mechanics are covered in the next chapter.
git sparse-checkout set --cone apps/web packages/sharedgit sparse-checkout listgit show HEAD:apps/worker/worker.txtgit sparse-checkout disablePlan ownership and builds
Keep ownership, tests and deployment boundaries explicit. In a monorepo, path-based reviews and selective builds can reduce coordination overhead, but dependencies must be considered when deciding what to test. A shared library change may affect both apps. In separate repositories, publish a compatible library version before upgrading consumers; use submodules, vendoring or a package manager when appropriate. Repository permissions are a real boundary; checkout filters and ownership-review rules are not read-access restrictions.
Practice
A shared schema changes every week with two tightly coupled applications. A monorepo can make that atomic change easy to review. A confidential service requires separate repository access: a separate repository may be justified even with extra integration costs. Explain your choice using ownership, access, build time, release cadence and dependency compatibility. Measure actual costs rather than assuming a universal winner.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Monorepo and Multi-Repository Design — knowledge check
Reason about dependency revisions, ownership and repository boundaries.
What is a potential monorepo advantage?
What may justify separate repositories?
Does sparse checkout restrict access to committed files?
Which tests may be needed after a shared library change?
What should guide repository architecture?