How it works · 8 of 49 Core

What is a modular monolith?

Boundaries without the network (Shopify)

Modular monolith: A modular monolith is one codebase that deploys as one unit but is split into packages, each owning its code and data and opening only through a public interface; a check in the build rejects any reach into another package's private parts or into a package not declared as a dependency. You keep one deploy and in-process calls, and get boundaries you can later cut along. Without the check, the boundaries are a promise and decay.

Loading the animation…

Say it like this A modular monolith ships as one unit but checks its boundaries on every change, so each package can be understood, swapped or later split out on its own.

Under the hood — for builders
The sources, in their words
Kirsten Westeinde, Shopify (2019): a modular monolith is "a system where all of the code powers a single application and there are strictly enforced boundaries between different domains". Maple Ong, Shopify (2020), on splitting into services instead: "Distributing code over multiple machines is a topology change, not an architectural change."
Shopify's monolith, in numbers
One Rails app, worked on by more than a thousand developers over a decade. When the team first drew the graph between components, "every component depended on over half of all the other components", with many cycles (Müller, 2020).
Run here: the two rules on this card's crates
Packwerk checks static references between packages: a dependency violation is a reach into a package you didn't declare; a privacy violation is a reach into its private parts. A 30-line checker with the same two rules, run here on the scene's four crates:
Why a static check won
Wedge logged every call while the full test suite ran: over an hour, and noisy. Packwerk reads constant references without running anything: a few minutes on the largest codebase, so it gates every pull request (Müller).
Existing tangles
Freeze today's violations in a to-do list per package; the check fails only on new ones. Shopify's Shipping team used its list to extract a service (Ong).
Measure it
Packages touched per pull request (should fall) · violations left in the to-do lists · cycles in the dependency graph (aim: none).
Watch out
A public interface over a dense, cyclic graph is just an extra layer to change (Müller). Static checks miss references they can't resolve: false negatives, not false alarms.
Sources
Westeinde, "Deconstructing the Monolith", 21 Feb 2019 · Müller, "Under Deconstruction: The State of Shopify's Monolith", 16 Sep 2020 · Ong, "Enforcing Modularity in Rails Apps with Packwerk", 23 Sep 2020; all Shopify Engineering, read in session · mini checker, run 18 Nov 2026.

What happens in the modular monolith animation, step by step?

Boundary check off or on: Check off

  1. One codebase, one lorry, four crates. Shopify's code was like this by 2016: one app, little stopping one part calling another.
  2. Shipping needs a tax rate and reaches straight into Tax's private table. Nothing checks it, so it merges, and the crates are strapped together.
  3. Months of shortcuts later, every crate is tied to most of the others, as Shopify found in its own graph.
  4. Now swap the old tax engine: lift Tax and the straps drag every other crate with it. Flip the check on.

Boundary check off or on: Check on

  1. Check on: it runs on every pull request. A crate may reach another only through its public hatch, and only if it declared it needs it.
  2. Your turn: Shipping needs a tax rate. Tap where it should reach in Tax.
  3. A shortcut into the private table is stopped before it merges. The lorry doesn't leave until it goes through the hatch.
  4. Shopify swapped its old tax engine this way. Only the hatch was used, so Tax lifts out alone.
  5. Still one deploy, and calls between crates never cross a network. Next: the same word meaning different things in different crates.

What everyday example explains modular monolith?

One lorry carrying sealed crates. It leaves the depot as one load, but each crate opens only by its own hatch, so one crate can be lifted out and replaced. Tie the crates together with straps and lifting one lifts them all.

Why should a team care about modular monolith?

If your team is growing and the code tangles, try packages with an enforced check before splitting into services: you keep one deploy, one database transaction and in-process calls. Run the check on every pull request, freeze existing violations in a to-do list, and only extract a service when one package needs its own scaling or release pace.