Modular Monolith Explained: The Middle Ground Between Monolith and Microservices
What a modular monolith is, how it differs from a classic monolith and microservices, its benefits, the rules that make it work, and when to choose it.
Published November 27, 2026
For years the debate was framed as monolith versus microservices: one big tangled codebase or dozens of independently deployed services. The modular monolith takes the best of both. It is a single deployable application, but internally it is divided into well-defined modules with strict boundaries, each owning its own logic and data. Companies such as Shopify have written publicly about running large modular monoliths successfully.
The concept
A classic monolith becomes painful not because it is deployed as one unit, but because anything can call anything and every part shares every table. A modular monolith keeps the single deployment, single runtime and (usually) single database server, but organises code into modules aligned with business capabilities, such as catalogue, checkout, billing and accounts. Modules talk to each other only through public interfaces or events, and each module owns its tables.
This gives most of the organisational benefits people seek from microservices (clear ownership, independent evolution, smaller mental models) without the costs of a distributed system (network failures, eventual consistency between services, distributed tracing, many pipelines). And because boundaries are already clean, a module can later be extracted into a service if a real need appears.
Anatomy of a modular monolith
How it compares
| Classic monolith | Modular monolith | Microservices | |
|---|---|---|---|
| Deployment | One unit | One unit | Many units |
| Internal boundaries | Weak or none | Strict, enforced | Network boundaries |
| Data ownership | Shared tables | Per module | Per service (separate DBs) |
| Communication | Any call, any table | Public interfaces, in-process events | HTTP/gRPC, messaging |
| Transactions | ACID everywhere | ACID (careful across modules) | Sagas, eventual consistency |
| Operational cost | Low | Low | High |
| Path to services | Hard (tangled) | Extract a module | Already there |
The five rules
- Each module exposes a small public API; everything else is internal
- No module reads or writes another module's tables
- Cross-module side effects go through events where possible
- Boundaries are enforced automatically in CI
- Each module has a clear owning team
Why it is a sweet spot for many teams
Practical examples
Folder structure (generic)
Each module has a public entry point; internals are private by convention and by enforced rules.
src/
modules/
catalog/
api.ts ← public interface other modules may import
events.ts ← events this module publishes
internal/ ← domain, persistence, handlers (private)
checkout/
api.ts
events.ts
internal/
billing/
...
shared/ ← tiny shared kernel: Money, IDs, auth contextCalling another module the right way
Through its public API, never its repository or tables.
// checkout/internal/placeOrder.ts
import { catalog } from '../../catalog/api'
const product = await catalog.getProductForCheckout(sku) // returns a DTO, not an ORM entity
if (!product.available) throw new OutOfStockError(sku)In-process event between modules
Billing reacts to checkout without checkout knowing about billing.
// checkout publishes
events.publish({ type: 'checkout.OrderPlaced', orderId, customerId, totalPaise })
// billing subscribes in its module setup
events.subscribe('checkout.OrderPlaced', billing.createInvoice)Common mistakes
- Calling it modular while modules still query each other's tables.
- A bloated "shared" or "common" module that everything depends on.
- Modules split by technical layer (controllers, services) instead of business capability.
- No automated enforcement, so boundaries erode under deadline pressure.
- Extracting services before boundaries inside the monolith are clean.
Key takeaways
- A modular monolith is one deployable app with strongly bounded business modules.
- Modules own their data and communicate via public interfaces and events.
- It delivers most of the organisational benefits of microservices without distributed-system costs.
- Clean modules can be extracted into services later if needed.
FAQ
Is a modular monolith just a well-written monolith?
Essentially yes, with the key difference that boundaries and data ownership are explicit and enforced, not just hoped for.
Can a modular monolith scale?
Yes. It scales horizontally like any stateless app, and specific modules can be extracted if they need independent scaling.
Does each module need its own database?
Not necessarily its own server. Separate schemas or table prefixes with strict ownership rules are usually enough.