Skip to main content
All articles
15 min read

Architecture at Orus

How we grow our modular monolith

Axel Kalonji
Squad Lead
Cover

We are 23 on the tech team. We sell a dozen insurance products in 3 countries and 4 languages. Everything we build lives in one Git repository, and almost all of it ships as one application.

Every few months, someone asks the question, usually a candidate in an interview: "At your size, shouldn't you be splitting this into services?"

My answer is no, and it isn't a matter of taste. A team of 23 has a fixed budget of attention. Microservices spend a large part of that budget on overhead: everything you have to build, maintain and watch only because the system is cut into services. Our monorepo spends it on the product. This article shows what that looks like in practice: the structure, the rules, and the GitHub setup that keep one repository pleasant with 23 people in it.

Why the question keeps coming up​

Before the how, a word on the question itself. Samuel, our CTO, has a theory about why it comes back so often, and he admits he fell for it himself.

  1. Good developers want to improve, so they read a lot: how to be robust, fast, efficient.
  2. They mostly read what sits at the top of the internet.
  3. The top of the internet belongs to the big, solid companies that have the budget to write interesting engineering articles.
  4. Those companies write about their own problems, which are how to serve a billion users. They also publish their toughest challenges on purpose, because that attracts talent.
  5. So young engineers are fed the patterns that take you from one million users to one billion. Very few articles cover the patterns that take you from zero to a thousand, or from a thousand to a million.

Microservices are the best-known of those patterns. They answer real problems, at a scale of organisation and traffic that most companies never reach. We aren't there, and this article is about the stage we are actually at.

What's actually in the repo​

A few numbers, taken from main this week:

  • 1 backend application, made of about 80 domain modules (subscription, contract, invoicing, claims, payment and so on)
  • 1 frontend application
  • About 120 internal libraries
  • About 12,000 TypeScript files and 2,700 test files
  • The dbt models of the data team, the orchestration flows of the ops team, and the Terraform and Kubernetes definitions of the infrastructure
  • More than 800 pull requests merged into main over the last 30 days, bots included
packages/
apps/
backend/ Backend API and domain logic (event-sourced)
frontend/ Frontend SPA
libs/ Shared libraries: pricing, dimensions, one package per product...
tests/ End-to-end tests (Playwright + Cucumber)
data/ dbt transformations
orchestration/ Kestra flows
infra/ Terraform, Kubernetes, images
tools/ CI and dev scripts

Two things about this list matter for the rest of the article.

First, it is a monorepo and a modular monolith. Those are two separate decisions. You can have a monorepo full of microservices. We chose one deployable backend, cut into modules, with the libraries around it.

Second, 800 merges a month is roughly 40 per working day. If a single repository was going to slow a team down, we would have noticed by now.

The microservice overhead, at our size​

The classic argument for microservices is team autonomy. Each team owns a service, deploys it alone, and picks its own tools. That argument is real when you have 300 engineers and the cost of coordinating them dominates everything else.

With 23 people in 4 squads, the math is different. Say we split by domain and end up with 15 services. That's more services than we have pairs of engineers to be on call for them. Each one needs a pipeline, a deployment, dashboards, alerts, a dependency upgrade routine and a security patch routine.

That's only the visible part. The overhead of a service architecture is wider than the network between the services:

  • Backward compatibility everywhere. Every contract between two services is deployed on two schedules, so every change to it has to be compatible in both directions for a while.
  • A microservice chassis to maintain. Service templates, shared clients, discovery, tracing, authentication between services. With good tooling you barely notice you are calling another service, but somebody has to build that tooling and keep it alive.
  • Network overhead. Timeouts, retries, idempotency, partial failures.
  • Migrations across owners. When the data model changes, the data lives in several databases, owned by several services, and the migration has to be coordinated between them.
  • Architecture problems that exist only there. Distributed transactions, eventual consistency between services, debugging one request across five sets of logs.

None of that work sells an insurance contract.

Then there is the domain itself. In insurance, almost nothing is local. Adding one field to a product (we call these dimensions) touches pricing, the quote, the subscription funnel, the contract documents, the endorsement rules, invoicing, the back office and the data warehouse. In a service architecture, that's a versioned API change negotiated across six or seven services and deployed in the right order. Here is what it is for us: one pull request.

Here is how the same situations play out on each side.

SituationMicroservicesOur monorepo
A field is added to a productCoordinated releases across services, versioned contractsOne PR, one review, one deploy
A type changes in a shared modelConsumers find out at runtime, or through contract tests you have to maintainThe compiler lists every call site before the PR is opened
A function call between two domainsA network call: timeouts, retries, idempotency, partial failureA function call
Upgrading TypeScript or a libraryN upgrades, N schedules, version driftOne upgrade for everyone
A new joiner sets up their machineDepends on how many services their feature touchesTwo scripts
Applying a new coding ruleN repos, N linters, N review culturesOne file, effective at the next review

We do have distributed-systems problems. We'd just rather have the two or three that are unavoidable than add fifteen of our own making.

One type system from the database to the button​

The backend exposes its API through tRPC. The frontend imports the types of that API directly. There is no generated client to publish, no OpenAPI file to keep in sync, no version negotiation between the two.

In practice, when I rename a field in a backend view, the frontend stops compiling in the same branch. I fix it in the same PR, the reviewer sees both sides of the change, and it ships together.

We lean on this hard, and our coding rules are written to make the compiler do as much work as possible. Two examples from the rules that apply to every file:

  • No type assertions. An as tells the compiler to stop checking at the exact place the author was least sure.
  • Branch on a union with a Record or an exhaustive switch, never an if on one value. When we add a product, the compiler must point at every place that needs a decision.

That second rule has a story behind it. A product variant once gained a feature and stayed out of an export for more than a year, because a filter somewhere read if (product === 'X'). Nothing failed. The new value quietly fell into the branch nobody chose for it. In a monorepo, one rule plus one compiler closes that class of bug across the whole company. Across fifteen repositories, the same union would be redeclared in each one, and no compiler would see them all.

Boundaries without a network​

"But a monolith turns into a big ball of mud." It can. A network boundary is one way to prevent that, and it's the most expensive one. We use cheaper ones.

Modules have a fixed shape. Every backend module has the same folders: services, routers, views, jobs, dispatchers, and a module.ts that declares what it contains. Only views are allowed to read from a store. Dependencies are injected through one container, and every entrypoint lists what it needs, so a process only loads its own closure.

Events are the contract. The backend is event-sourced (we wrote about it here). A deployed event is never modified. That gives us the durable, append-only contract people usually want from a service API, without the HTTP.

New business logic goes into single-purpose packages. Most of the new business logic surface is added in packages that do one thing and declare their dependencies: one package for the dimensions of a product, one for its subscription logic, one for pricing, one for invoices. A package can only import what its manifest lists. So a dependency from one domain to another never appears by accident. Someone adds it on purpose, and a reviewer sees it in the diff.

Import cycles are forbidden, between files and between frontend domains. A frontend domain shares a capability with another one through an explicit public/ folder. Its screen state stays private.

Dead code fails the build. An export that nothing imports is reported by CI. In a multi-repo setup you can never delete a public function with confidence, because you can't see who calls it. Here, the tool tells us.

One process doesn't mean one scaling unit either. The same codebase starts as an API server, as a worker, or as a data pipeline process, and each one loads only the jobs it is responsible for.

The rules live next to the code​

This is the part I'd miss most in a multi-repo world.

Our mandatory coding rules are stored in CODING_RULES.md files spread through the source tree. They are hierarchical and cumulative: the rules for a file are the union of every CODING_RULES.md in its directory and in every parent directory. Today that's 193 rules in 8 files. The root file covers error handling, TypeScript, naming, logging, tests and Git. The backend file adds event store and migration rules. The frontend file adds composition and routing rules. The data team has its own for dbt.

Every rule has the same format: a stable slug, a requirement, and a rationale.

### backend/use-injected-clock — Use the injected clock

Requirement: obtain the current application time through the injected `timeService`.

Rationale: application time must stay controllable in tests and in time-shifted
scenarios. Reading the system clock directly bypasses that control and makes
behaviour inconsistent and tests non-deterministic.

The rationale is mandatory, and it does real work. Departing from a rule is allowed, with one standard for all of them: explain specifically why the rationale doesn't apply here. "It was more convenient" doesn't pass.

We also keep a strict split between what a human reviews and what a machine checks. If a linter, the type checker or the formatter can fully enforce something, it isn't a review rule. Each file ends with a table of those requirements and the check that owns them, so nobody argues in a PR about what CI already decided. CI even validates the rule files themselves: a malformed rule or a duplicated slug fails the build.

Because the format is regular, a program can read it. Which brings me to review.

GitHub does the policing, so people don't have to​

Branch protection on main requires exactly three checks: the test pipeline, the UI tests, and a check called Code owners review. Nobody pushes to main. Everything else is built on those three.

A merge queue​

Last December, at 15 people, we were hitting semantic conflicts a few times a month. Developer A adds a field to a store and updates every caller. Developer B adds a new caller on another branch. Both PRs are green. Merged one after the other, main is broken.

We turned on GitHub's merge queue. Clicking merge puts the PR in a queue, and it is tested against the exact state of main it will land on, including the PRs ahead of it. Since then, PR checks run on the branch head (your code, and only your code), and the queue owns the question "does it still work once merged?".

People often list this problem as a reason to avoid monorepos. I read it the other way. In a monorepo, a semantic conflict is caught by a queue before it reaches production. Between two services, the same conflict is a production incident, because no pipeline ever tests the two changes together.

Review rules as code​

GitHub's native CODEOWNERS file maps paths to people. We needed more than that, so the real rules are a typed list in the repo, evaluated by a small check of our own:

{
rationale: 'Invoicing module must be reviewed by an invoicing expert',
condition: { $and: [targetsMain, { matchesPathGlobs: ['packages/apps/backend/src/modules/invoicing/**', ...] }] },
team: 'invoicing-experts',
minimumApprovals: 1,
authorCountsAsApproval: true,
aiApprovalCounts: false,
}

Any change needs one contributor approval. Changes to data, infrastructure, pricing or invoicing also need someone from the matching expert team. The files that define the review rules and the CI are themselves protected by a stricter rule, where the author's own expertise doesn't count.

This is how we get the ownership that microservices promise. The invoicing experts own invoicing. It's enforced on every PR. And they didn't have to become the operators of an invoicing service to get it.

An AI reviewer that reads the rulebook​

We have a reviewer named Orusaurus. It's a GitHub user backed by an AI pipeline. You request its review like you would a colleague's. For every changed file, it loads the rules that apply (always from main, so a PR can't relax the rules it is judged by), checks them one by one, and separately looks for defects: concurrency, edge cases, effects on contracts and invoices, design. A final step re-validates every finding against the code before anything is posted.

Its approval counts as one contributor approval. It doesn't count for data, infrastructure, pricing or invoicing. Those keep a human expert.

This only works because of the monorepo. The rules, the code they govern, the architecture docs and the 36 decision records (ADRs) all sit in the same tree. A coding agent or a reviewer opening any file can walk up the directories and find everything that applies. Changing how 23 people and their agents write code is one merged PR to one Markdown file.

CI that scales with the change​

One repo doesn't mean every PR runs everything. Our CI pipeline is generated per commit. It asks the build tool which packages are affected by the diff and creates test steps for those only. A dbt-only PR runs the dbt checks. A change in a product library runs that library and what depends on it. Build results are cached and shared.

What it costs us​

It would be dishonest to stop here. The monorepo has a price. We pay it in tooling.

  • CI is a product. The dynamic pipeline, the change detection, the caching and the review check are code we wrote and maintain. The infrastructure experts spend real time on it.
  • A flaky test is everyone's problem. With a merge queue, a flaky test can eject an innocent PR. We decided to treat that as a feature: it forces us to track and fix flaky tests instead of living with them. Every flaky test gets a tracked issue, CI recognises a failure caused only by known flaky tests, and a nightly build runs every step to catch new ones.
  • Merging isn't instant. A PR waits its turn in the queue. Admins can bypass it for a hotfix.
  • Local tooling has to keep up. Type-checking a codebase this size took work, including moving to TypeScript 7, the Go rewrite of the compiler.
  • We still have one distributed boundary. A customer can keep an old frontend open in a tab long after we deploy. So we have a rule for contracts consumed by a separately deployed artifact: ship the change in two PRs, 24 hours apart, with a compatibility layer in between. It reminds us weekly what every change would feel like with fifteen services.

We aren't dogmatic about it either. Metabase and our workflow orchestrator run as their own deployments, because they are off-the-shelf products. The data team writes Python where Python is the right tool. They still live in the same repo, under the same review rules and the same CI.

When we would split​

I can think of two reasons that would make us extract a service:

  1. A component with a radically different runtime or scaling profile, which the worker split can't absorb.
  2. A hard isolation requirement, regulatory or security, that a module boundary can't satisfy.

Neither is true today. If one becomes true, the module structure, the clear module definitions and the forbidden cycles mean the cut lines already exist. So if at some point we need it, switching to a microservices deployment strategy would be quite simple.

The short version​

At 23 engineers, the scarce resource isn't deploy independence. It's attention, and microservices would spend it on overhead. Our monorepo gives us one type system, one rulebook, one review policy and one pipeline, and each of them improves for everyone with a single PR. We get code ownership through review rules, boundaries through modules and the compiler, and safety through a merge queue.

It's the same method I described in my previous article: build what the business needs, keep it as simple as possible, and wait for a real problem before paying for its solution. Microservices solve a problem we don't have yet. We'd rather keep shipping insurance products.

Like the way we think?

We're based in Paris and we're hiring software engineers.