The modular monolith vs microservices SERP stops at the folder diagram
Every recent modular monolith vs microservices page recommends the middle option and then shows you a folder tree. The one thing almost none of them names is the mechanism that fails the build when someone crosses a boundary — and that mechanism is the entire difference.
Search the term in 2026 and you get two shapes of result. Three-way comparisons that end at start modular, extract later.
Consultancies with a decision framework and a percentage no reader can check. Both land on the middle. Neither shows you how the middle stops being a monolith with folders.
Let me state the thesis once, then let the rest of this post pay for it: a modular monolith is not a compromise between a monolith and microservices. It is a monolith with a bill attached, and the bill is enforcement. Pay it and your modules are real. Skip it and you have folders with a naming convention.
The scope is narrow on purpose. This is not the trade-off ledger — that is monolith vs microservices: the trade-offs, and it stays there. It is not a trigger list for when your organization should split. The method all of this sits inside is the system design practical guide. The part I own is how you make a module boundary real, and when the middle is the right call; the ADD 3.0 walkthrough is the design loop that chooses the structure first.
One correction before anything else, because half the search results get it wrong. Modular monolith
is not Martin Fowler's term. It is Simon Brown's — the ideas date to about 2013, and the talk is Brown's Modular Monoliths
at GOTO Berlin 2018. Fowler's actual 2015 writing on this axis is Monolith First
, and it never uses the phrase.
Is a modular monolith just a monolith with folders?
No — and the difference is not the layout. A modular monolith is a monolith whose module boundaries can be detected and enforced. Without an enforcement mechanism, it is a directory with a naming convention.
Simon Brown draws the line precisely. If you mark every type public, he writes on his own page, the packages are simply an organisation mechanism (a grouping, like folders)
— and all four architectural approaches he presents are exactly the same
. A folder is not a boundary. A folder with a convention is still not a boundary.
Kamil Grzybek gives you three tests for a module that is real rather than decorative. It is independent — few and weak dependencies on stable modules. It contains everything needed to deliver its business function. And it has a well-defined interface: everything that we share outside becomes the public API of the module.
Fail any one of those and you have a folder.
The rule to remember is one sentence: a module is a boundary only when crossing it is detectable. Detection can be the compiler, a static check, or a database grant. There must be a mechanism, or it is a directory.
And draw the lines by business capability, not technical layer. Grzybek's vertical slices group code as orders and shipping, not as controllers and services and repositories. That is the difference between a change that touches one module and a change that touches all of them.
What does a modular monolith vs microservices decision actually split?
It splits two questions the search results collapse into one: how modular the code is, and how many deployment units the system runs. The modular monolith raises the first and never touches the second.
Grzybek's definition is the cleanest anchor: Monolith is nothing more than a system that has exactly one deployment unit. No less no more.
Modularity is a second, orthogonal property — independent modules, each with everything its function needs, behind a contract.
Simon Brown's framing is a quadrant, not a line. High modularity plus one deployment unit is a modular monolith. High modularity plus many deployment units is microservices. One unit plus low modularity is the thing people actually mean when they say monolith
and mean it as an insult.
You already know the starting rung. Fowler's presentation, domain, data layering is the three-bucket default, and his own page says it stops being enough as an application grows, because each layer gets complex enough on its own to need modularizing further. The modular monolith is what happens when three horizontal buckets stop being enough and you start cutting vertical.
The half of the decision I do not cover here — whether to raise the number of deployment units — is a different post. The price of that move is the trade-off ledger. This post answers the other half: raise modularity, keep one deployment unit, and make the modules honest.
How do you actually enforce module boundaries in a monolith?
You enforce a boundary by making a violation fail something. The compiler first, because it is cheapest and fastest; then a static check or an architecture test; then a database grant. Convention is not enforcement at all.
I read it as a ladder of cost and durability: compiler, then static analysis, then database grant, then convention. The higher you are on the ladder, the sooner and more cheaply the boundary breaks the build when someone crosses it.
Layer 1 — let the compiler do the gating
This is Brown's package by component,
and it is the strongest rung because the language does the gating for free. Keep everything except the component's interface package-private (or internal in C# with one assembly per component), and there's now no way that code outside of this package can use the `OrdersRepository` interface or implementation directly, so we can rely on the compiler to enforce this architectural principle.
Brown's explicit recommendation is to lean on the compiler rather than discipline, post-compilation tooling, and automated fitness functions (e.g. ArchUnit).
That is the whole hierarchy in one sentence, from the person who named the pattern.
Layer 2 — add a static check
Where the language has no package-private visibility, you add a tool. Packwerk is a static analysis tool used to enforce boundaries between groups of Ruby files we call packages.
It catches two classes of violation — dependency (referencing a private constant from a package you have not declared) and privacy (reaching into another package's private constants) — plus a check for dependency cycles. It runs locally and in CI.
Layer 3 — verify it in tests
Spring Modulith derives an application-module model from your package structure and gives you ApplicationModules.verify(). It enforces three rules: no cycles at the application-module level, external access through API packages only, and only the dependencies you explicitly allow with @ApplicationModule(allowedDependencies = …). It verifies in tests, because it cannot make compilation fail.
Layer 4 — enforce it in the database
Namespaces, roles, and grants. This is the layer most teams skip, and it is the one that decides whether the modularity of your code is real. More on that below.
The honest summary of all four: no mechanism designs your boundaries. Every mechanism only gates them. A green build tells you the rule was followed. It does not tell you the rule was right.
Packwerk vs ArchUnit vs Spring Modulith — which one do you use?
The language decides. Packwerk for Ruby and Rails. ArchUnit or Spring Modulith for the JVM. None of them designs your boundaries, all of them gate them, and only a compiler-visible mechanism can genuinely fail the build.
Packwerk, for Ruby and Rails
Static constant references only. It enforces dependency and privacy, runs packwerk check locally and in CI, and generates a deprecated-references list so a legacy app can stop the bleeding — prevent new violations while you pay down old ones. The maintainers state the limits themselves: the README says it resolves only Zeitwerk-autoloaded constants, and method calls and objects passed around the application are completely ignored.
It is deliberately biased toward false negatives to avoid false positives. GitLab uses it, and its own design document says Ruby does not provide out-of-the-box tools to effectively enforce boundaries.
ArchUnit, for Java and Kotlin
A general-purpose library, not a framework. Package and class dependency checks, layered and onion architectures, slices, and cycle detection. It runs as an ordinary unit test, so it fits the build you already have, and you can freeze it against legacy code with archunit_ignore_patterns.txt. Thoughtworks states its limit bluntly: it supports only Java-based architectures.
That is the Radar entry that put it at Trial, November 2018; it is not on the current edition.
Spring Modulith, for Spring Boot
An opinionated toolkit that maps logical modules onto packages and verifies the arrangement, with per-module integration tests, in-process application events, and module-level observability. It integrates with ArchUnit for its verification rather than replacing it. Thoughtworks: Assess, September 2023.
The distinguisher is one line, and it is why the ladder is ordered the way it is: only a compiler-visible mechanism can fail the build. Packwerk and Spring Modulith gate the violation in CI or in tests, one step later and one step softer.
What did GitLab's modular monolith program actually reveal?
GitLab is running a public, unfinished modular-monolith program against a 2.2-million-line Rails codebase, and its own design document says the hard part is organizational and that the database — not the imports — is what blocks extraction.
GitLab's handbook carries a Rails Monolith Decomposition
design document, marked status: proposed and dated 2023-05-22. Its stated goal is to evolve toward a modular monolith design, while still using a monolithic architecture with satellite services, and — for the modules where it pays off — toward independently deployable units …
The codebase is over 2.2 million lines of Ruby code and hundreds of engineers contributing to it every day,
a single Rails codebase after the Community and Enterprise editions merged into one. In the document, packages means Packwerk packages, and bounded contexts are top-level packages like Ci:: and MergeRequests::. The rule is uncompromising: A dependency that is not declared does not exist;
.
Then comes the part that makes this the honest example rather than a glossy case study. There is no isolation between existing modules. Ruby does not provide out-of-the-box tools to effectively enforce boundaries. Everything lives under the same memory space.
Nor does the modularity reach the data. Boundaries are silent on the database. Even apparently isolated domains share tables, hold cross-boundary foreign keys, and keep ORM associations that span the line. Data coupling is what actually blocks extraction.
GitLab's own conclusion is blunter still: we believe that the main challenge is organizational, rather than technical.
The strategy line is the cleanest statement of the middle position anywhere in the sources: Modularize broadly, extract selectively. Most code is modularized in place within the monolith; a module is extracted into a separately deployed service only when the ROI is clear.
Hold the honesty line, though. The document is status: proposed, not a completion report, and a later handbook merge request proposes using gems instead of Packwerk for isolation. A boundary is maintained, not declared. Shopify and GitLab are describing their own programs, Spring/Broadcom publishes its own framework, and Thoughtworks is offering an opinion — treat them all as interested parties, then read them anyway, because they are still the best primary sources there are.
Where does modularity actually die — the code or the database?
It dies in the database. You can enforce every import and still be unable to extract anything, because shared tables and cross-boundary foreign keys weld your modules together no matter how clean the code looks.
GitLab says it outright: Data coupling is what actually blocks extraction.
Shopify is the same shape — after componentization, Active Record models are shared across domains. There's no wall imposing those boundaries, just an agreed upon social contract that can be easily broken.
The mechanism is boring, and it works. One schema per module. A dedicated database role granted privileges only on that schema. One connection per module, using that role's credentials. Cross-module reads go through a published view or an API — never a cross-schema JOIN. Milan Jovanović's write-up is the concrete version, and his framing is the point: make your boundaries enforceable rather than aspirational.
Grzybek's reference implementation does the same thing — each module gets its own schema in a shared database.
I state the trade-off honestly, because it is real. Schema-per-module forces a decision about every cross-module query and makes reporting harder. A shared schema with a read-model or a view is often the pragmatic first step. The goal is ownership; the schema is the enforcement, not the reverse. There is no sourced number for how much faster this makes anything, so there is no number here.
When is a module ready to extract?
A module is ready when it already owns its data, exposes a stable public contract, tests in isolation, and has a reason to scale or change on a different curve than the rest. Miss any one of those and your extraction is a rewrite pretending to be a move.
GitLab's criterion is the anchor: extract selectively … a module is extracted into a separately deployed service only when the ROI is clear.
Thoughtworks frames the same instinct for Spring Modulith: build a well-factored monolith and only break out separately deployable units when the application reaches a scale where the benefits of microservices outweigh the additional complexity inherent in distributed systems.
Shopify shows the tooling loop working, at module level. The Shipping team used the Packwerk deprecated-references list as the checklist for pulling a domain out of the monolith into its own service — and the same list works for extracting a package into a gem. Shopify also names the only two reasons it actually extracted: storefront rendering (read-only, very high throughput) and credit-card vaulting (sensitive data that shouldn't flow through other parts of the system
). That is a module-level rationale, not an org-wide trigger list.
The org-wide version of this question — what event should start a split, and in what order — belongs to a different post, When Should You Split a Monolith?, and it is not answered here.
What does a modular monolith not fix?
It does not fix coupling, and it does not buy isolation. You keep one process, one deploy, one failure domain, and you take on a discipline bill that keeps arriving. A green build is not a decoupled system.
Go to the primary sources for this, because they volunteer it. Shopify: making a fundamental architecture change to a system that's being actively worked on is in large part a people problem,
with the Fogg ability/motivation/prompt model — Automated tooling and targeted manual code reviews provide prompts. That's the easy part.
.
The tooling surfaces violations; it does not fix coupling. Shopify's componentization started with a dense, cyclic graph — every component depended on over half of all the other components
— and much of its first round of interfaces turned out to just be an added layer of indirection in the existing control flows.
Packwerk and ArchUnit report. Humans decouple.
And the runtime is untouched. GitLab: Everything lives under the same memory space.
One process, one deploy, one failure domain, no scaling one module on its own. I state the asymmetry plainly, because it is the part teams miss: the modular monolith buys you a cheaper, enforceable boundary. It does not buy you isolation.
The enforcement bill is a multi-year productivity investment, which is slow productivity in software engineering in its natural habitat. If you need isolation, you have left the middle — and that is a legitimate reason to leave it. It also means the triage you run when things break is still the eight-step incident pipeline, one failure domain and all. The layer above that decision is how to design a highly available system.
Does a modular monolith scale?
Yes — as one unit, many identical instances. The evidence is codebase and team size, not a throughput number, and the thing it cannot do is scale or fail a single module on its own.
The size evidence is large. Shopify's core monolith: over 2.8 million lines of Ruby code and 500,000 commits.
GitLab's: over 2.2 million lines.
And the small-team anchor is Basecamp, where DHH's 2016 self-report counted roughly 200 controllers, about 900 methods and 190 model classes across six platforms with about 12 programmers, serving millions of users. Scale is not the same thing as distribution.
The honest boundary is the one that matters. A monolith scales as one unit — you run many identical instances of the whole thing. What it cannot do is scale one module independently, or fail one module independently. That is exactly the cookie-cutter-scaling trade the monolith vs microservices ledger prices. And there is no fabricated benchmark here: nobody has a sourced modular monoliths handle X requests per second
figure, so you will not read one from me.
So is the modular monolith vs microservices middle the right call?
A greenfield project should still start on a single box sized for early-stage traffic; modularity is a response to felt coupling, not a default.
Yes — when your pain is coupling rather than independence, and someone will fund the enforcement. Choose the middle when changes ripple across the codebase, tests cascade, and onboarding needs too much context, and when the domain genuinely separates into business capabilities. Then treat the module boundaries as enforced interfaces with owned data. That is my recommendation, scoped to that situation and nothing broader.
Now the honest inverse, because the middle is not a default for everyone.
Do not choose it as a greenfield first move. Fowler's Monolith First and the design-stamina hypothesis both say decide late, once you actually understand the domain, and Shopify's own conclusion was that the best time to refactor and re-architect is as late as possible.
The modular monolith is a response to felt coupling, not a starting ceremony. Small systems should stay small, which is the argument of ecommerce architecture at 100 users.
Do not choose it if your real constraint is independent deploy cadence, or a genuinely divergent scaling, data, or security profile. That is a microservices question, and the sibling post prices it.
And do not choose it if nobody will pay the bill. A modular monolith with no enforcement is strictly worse than an honest monolith: it adds ceremony and indirection with no barrier to show for either.
What should you do first?
Pick the module that hurts most, enforce one boundary with one mechanism, give it its own data, and only then consider extraction. If nobody will enforce anything, keep the honest monolith.
Your minimum viable enforcement, drawn only from the cited sources: choose the one module that changes most often and hurts most; give it a public contract (make everything else package-private or internal where the language allows); add one mechanism that fails the build or the test on a violation (Packwerk, ArchUnit, or Spring Modulith's verify()); give it its own data (schema plus role) or at least an explicit read-only API. Then consider extraction, using the violation list as the checklist.
Grzybek explains why that order is right on his Domain-Centric Design page: a genuinely modular monolith is designed so that we will be able to easily extract a particular module into a separate runtime component
later — but, he adds, only if necessary -
because extraction is not the goal of our architecture, only a great side-effect of modularity.
That is the whole point, and it keeps this a decision rather than a manifesto: the modular monolith is not a compromise, and it is not a step on a staircase anyone is obliged to climb. It is the architecture I reach for when the problem is coupling and the discipline is enforceable.
Related Reading
Monolith vs Microservices: The Trade-offs
The monolith vs microservices results are two-column tables, and the tables are the problem monolith vs microservices is
System Design: A Practical Guide for Software Engineers
Search system design and you get a diagram: a load balancer, a cache, a queue, a database, and a glossary.
ADD 3.0: A Worked Example of the Seven-Step Design Method
You have sat in the review.