Monorepo engineering
A monorepo setup puts your web app, your backend and the API client your mobile app uses in one repository, with shared types and packages. We build it on pnpm workspaces with Turborepo or Nx, so a change to a shared package is checked against every app that uses it. CI builds and tests only the affected projects, and remote caching keeps the pipelines short.
Monorepo engineering: an overview
A web app, a mobile app and a backend that live in three repositories tend to drift apart. The API renames a field, the web app is updated, the mobile client is not, and the problem appears in production. A monorepo puts that code in one repository, so a change and all its consequences land in the same pull request, reviewed and tested together.
A good monorepo setup is mostly about the build graph. With pnpm workspaces, every app and package declares its dependencies explicitly. Turborepo or Nx reads that graph, works out which projects a commit affects, and runs lint, type checks, tests and builds only for those. Remote caching restores a task that already ran with the same inputs, on another developer's machine or in CI, instead of running it again.
A monorepo is one option among several, and we decide after looking at your code and your teams. It fits code that changes together and shares types or a release cycle. Separate repositories fit unrelated products with separate teams and release cycles, or code that must stay apart for access or compliance reasons. Several repositories sharing packages through a private registry sit in between. The choice and its reasons go into an ADR.
What the service covers
Repository strategy
We look at which code changes together, who works on it and how it is released, then recommend one repository, several, or a mix. Each option comes with its day-to-day cost for your team.
Workspace structure
Apps and packages are laid out with pnpm workspaces, with clear rules about which may depend on which. Shared configuration lives in packages as well.
Shared packages and types
Domain types, validation schemas, a generated API client and UI components become internal packages. A change to the shape of the API then fails the type check in every app that reads it.
Build orchestration
Turborepo or Nx defines the task pipeline: what must build before what, and which inputs each task depends on. Tasks run in parallel wherever the graph allows.
CI and remote caching
CI runs only the projects a commit affects, with a remote cache shared between developers and pipelines. We set it up on GitHub Actions or on the CI you already use.
Migration and ownership
We bring existing repositories in without losing history and set review rules per folder. Teams keep ownership of their code inside the shared repository.
When it is the right call
- 01
Your frontend and backend share types by copying files, and the copies have drifted.
- 02
A change to a shared library requires pull requests in several repositories, merged in the right order.
- 03
CI runs the full test suite on every commit, and the pipeline has become the slowest part of the working day.
- 04
You are adding a mobile app or a second web app and want it to reuse the API client and validation rules from the start.
What you get
Workspace structure with pnpm workspaces and Turborepo or Nx
Shared packages for types, API clients, UI components and configuration
Affected-only builds and tests in CI, with remote caching
Migration of existing repositories with their Git history preserved
How we work on it
Step 1
Audit the repositories
We list the existing repositories with their dependencies, build scripts and release processes. We note which ones share code, and how.
Step 2
Decide the repository strategy
We recommend one repository, several, or a mix, with the trade-offs written in an ADR. If separate repositories are the better fit, we improve how they share code instead.
Step 3
Design the workspace
We lay out apps and packages, pick Turborepo or Nx and define the task pipeline. The code owners file gives every folder a reviewing team.
Step 4
Migrate with history
Repositories move in one at a time with their Git history, so blame and log still work. Each move is a pull request that leaves CI green.
Step 5
Tune CI and caching
We set up affected-only runs and remote caching, then check the cache hit rate and fix the tasks that keep missing. Pipeline times are measured before and after so the effect is visible.
Monorepo or polyrepo: criteria for the choice
A monorepo makes atomic changes possible: one pull request updates the API, the web app and the mobile client together. It gives one place for tooling, one set of lint and test rules, and refactoring across projects with the type checker's help. In exchange, it needs build tooling that understands the dependency graph, attention to CI times, and a review model that keeps teams from stepping on each other.
Separate repositories give each team full control of its tooling and release process, and simple access rules: an outside contractor can see one repository and nothing else. The cost appears when code is shared, because a change to a common library becomes a published version, then an upgrade in each consumer, in the right order. We weigh how much code is actually shared, how often it changes, how many teams are involved, and whether any code must be kept apart for access or compliance reasons.
Structuring shared packages and types in a monorepo
A typical layout has an apps folder for deployable things, such as the Next.js site, the API and the mobile app, and a packages folder for the code they share: domain types, a generated API client, validation schemas, UI components, ESLint and TypeScript configuration. Apps depend on packages, packages never depend on apps, and that rule is checked in CI.
The most useful shared package is often the smallest: the types and schemas that describe your API. When the backend changes a response, the type check fails in every TypeScript app that reads it, in the same pull request. A whole class of production bugs turns into a red build.
Affected-only builds, remote caching and code owners
Without care, a monorepo makes CI slower, because every commit seems to touch everything. Affected-only runs fix that: the tool compares the commit with the main branch, walks the dependency graph and runs tasks only for the projects that changed and the ones that depend on them.
Correct caching depends on declaring inputs and outputs honestly. A task that reads an environment variable it did not declare will restore a stale result. We declare inputs per task and keep secrets out of the cache. A CODEOWNERS file then maps each folder to the team that reviews it, so one repository does not mean everyone reviews everything.
Methods and tools
- Monoliths and microservices
- Domain-driven design
- Architecture decision records
- C4 model
- pnpm workspaces
- Turborepo
- Nx
- PostgreSQL
- Kafka
How you can work with us
Fixed-scope project
The scope of the first version is written down, split into milestones and priced per milestone. It suits a product or a feature with a clear outline.
Dedicated team
A team works on your product over the long run, with its own planning and release cadence. It suits a product that keeps changing.
Team extension
One or more of our engineers join your team and work with your tools and routines. It suits a company that knows where it is going but lacks people or a specific skill.
Monthly support
A monthly retainer covers maintenance, updates and small changes, with an agreed response time. It suits a product in production that needs upkeep more than new features.
Questions about Monorepo engineering
Should we use a monorepo or separate repositories?
It depends on how much code your projects share and how they are released. If a web app, a mobile app and an API change together and share types, one repository usually saves work. If the products are unrelated, owned by separate teams or need strict access separation, separate repositories are simpler. We look at the code and the teams before recommending either.
Turborepo or Nx: which should we choose?
Turborepo for a mostly TypeScript repository where you want speed with little configuration. Nx when you want code generators, stricter boundary rules between projects or several languages in the same repository. Both share the core ideas of a task graph, affected runs and remote caching, so either is a reasonable starting point.
Will we lose our Git history when we move to a monorepo?
No. We import each repository with its history, so git log and git blame keep working on the moved files. Open pull requests on the old repositories need to be merged or recreated, and we plan the cut-over around them.
Does a monorepo mean one deployment for everything?
No. A monorepo is about where the code lives, not how it ships. Each app keeps its own pipeline and deployment target, and CI deploys only the apps a commit actually affected. A backend can release several times a day while the mobile app follows the app store schedule.
Does a monorepo slow down CI as it grows?
Only if every commit runs everything. With affected-only runs, CI builds and tests the projects a change touches and their dependents, and remote caching skips tasks whose inputs did not change. What still grows is the time to clone and install, which shallow clones and a cached pnpm store keep under control.
Can our native mobile apps live in the same monorepo?
Yes, with some care. Swift, Kotlin and Flutter apps cannot import TypeScript packages, but they can share the API contract through client code generated from the same OpenAPI schema. Mobile builds need their own toolchains and signing, so they run in dedicated CI jobs triggered only when the mobile code or the shared contract changes. Publishing to the app stores keeps its own release process.
In the same service area
Design, build and ship your project
Describe it in three lines. We reply with specific questions and a first take on how to proceed.