Modular Monolith
One deployable application split internally into modules by business capability, each with its own code, data and public interface.
Description
A modular monolith is deployed as one unit, but inside it's divided along business lines (orders, billing, catalog), not technical layers. Each module owns its data (its own tables or schema) and exposes a small public interface; other modules may only use that interface, never its internals or its tables.
You get most of the design benefits of microservices, such as clear ownership, independent evolution and enforced boundaries, without the operational cost of a distributed system: one deployment, one database server, in-process calls and simple transactions. If a module later needs to scale or deploy separately, it can be extracted along a boundary that already exists.
System design
Modular Monolith system design diagram
- HTTP API (gateway).
- Orders module (service): public interface only.
- Billing module (service).
- Catalog module (service).
- One database server (database): a schema per module.
- Step 1: HTTP API → Orders module: route.
- Step 2: Orders module → Billing module: billing.charge().
- Step 3: Orders module → Catalog module: catalog.price().
- Step 4: Billing module → One database server: billing schema only.
- One application receives the request and routes it to the module that owns it.
- Modules call each other only through public interfaces, as in-process function calls with no network.
- No module reads another's tables; it asks the owner.
- Each module stores data in its own schema. The boundary is ready if the module ever needs to become a separate service.
When to use it
Use it when
- Most new products and growing teams. It's the recommended starting point before microservices.
- The domain has clear business areas, but the team is too small to run many services.
- You've got a tangled monolith and want to restore structure without a risky rewrite.
Avoid it when
- Parts of the system need very different scaling, runtimes or release cadences right now.
- Many independent teams step on each other in one deployment pipeline. That's when extracting services pays off.
Pitfalls
- Boundaries only by convention, which erode under deadline pressure. Enforce them with build tooling (module visibility, lint rules, architecture tests).
- Shared tables between modules, which turn the modules back into one ball of mud. Each module owns its own data.
- Cutting modules by technical layer instead of business capability.
- One module calling deep into another's internals instead of its public API.
Alternatives
Microservices
Choose it when teams need truly independent deployment and scaling, and you can afford the operations.
Layered Architecture
Choose it when the app is small and one team owns everything; layers alone are enough.
Hexagonal Architecture
Choose it when you want to structure the inside of each module around its domain logic. They combine well.