Bookmarks

Modular monolith

A monolith broken into modules with clear boundaries: it builds and deploys as a single application, but internally the modules are isolated and communicate through explicit interfaces.

Also: modular monolithic architecture, modular architecture

checked 8 Nov

All terms

A monolith built from modules with clear boundaries: one process, usually one database, but each module is a separate piece of code with a public interface and its own area of data. In 2015 Martin Fowler described the “monolith first” strategy: start a new product as a modular monolith and extract services only when a real reason for them appears.

Boundary rules

  • each module has one purpose — one domain, such as orders, billing, notifications;
  • only the public interface is visible from outside: other modules do not touch its internal classes and functions;
  • each module owns its own tables or data collections — it reads anyone else’s through the owner’s interface;
  • shared code is minimal and does not tie modules together through global models and utilities;
  • each module has its own tests, run separately from the rest — this is how you verify that the boundaries are real.

Monolith, modular monolith, microservices

AspectMonolithModular monolithMicroservices
Deploymentone processone processone service per process
Boundariesno explicit rulesmodules with a public interfaceeach service is a separate unit
Dataone schema with no ownerstables split by moduleone database per service
Module interactionsany, most often direct callscalls and events through interfacesnetwork: HTTP, queues
What the team needsminimal infrastructureboundary disciplinemature DevOps practices

Keeping boundaries in code

Technically, modules are separated at project or package level with default visibility, import rules enforced in CI and architecture checks. The structure follows the boundaries: each module has its own public interface, its own models and its own tests.

textThree modules and minimal shared code
src/  orders/        # public API: services.py, the rest — _internal  billing/  notifications/  shared/        # only what every module needs: events, base types

When to choose it

A modular monolith suits most new products: a small team, domain boundaries that have not settled yet, and a load a single node can handle. Splitting into services early often produces a distributed monolith: the same hidden coupling between parts, but now over the network and with shared releases. When a module starts to need a different scale, a different stack or a different team, it is extracted into a service — and the boundaries drawn in the modular monolith move with the code.

Sources

the term is written from these pages

Verified 8 Nov

Not to be confused with

what it is mixed up with and how it differs

  • monolith

    An ordinary monolith has no boundary rules: code and tables are connected in every direction, while the modular monolith keeps its modules isolated.

  • distributed monolith

    A distributed monolith is an anti-pattern: microservices that cannot be changed and deployed independently because of hidden coupling.

  • microservices

    Microservices are separate services with their own databases and independent deployments; a modular monolith remains a single application.

In depth in the references

where the topic is covered in detail