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

Single deployable applicationone build, one runtime, one deployCatalogue modulepublic API + events · owns catalog_* tablesCheckout modulepublic API + events · owns orders_* tablesBilling modulepublic API + events · owns billing_* tablesShared kernel (small)IDs, money type, auth contextOne database serverschemas or table prefixes per module
One deployment, many strongly bounded modules.

How it compares

Classic monolithModular monolithMicroservices
DeploymentOne unitOne unitMany units
Internal boundariesWeak or noneStrict, enforcedNetwork boundaries
Data ownershipShared tablesPer modulePer service (separate DBs)
CommunicationAny call, any tablePublic interfaces, in-process eventsHTTP/gRPC, messaging
TransactionsACID everywhereACID (careful across modules)Sagas, eventual consistency
Operational costLowLowHigh
Path to servicesHard (tangled)Extract a moduleAlready there

The five rules

  1. Each module exposes a small public API; everything else is internal
  2. No module reads or writes another module's tables
  3. Cross-module side effects go through events where possible
  4. Boundaries are enforced automatically in CI
  5. Each module has a clear owning team
The rules that make a modular monolith work.

Why it is a sweet spot for many teams

Monolithfast start, slows as it tanglesModular monolithfast start, stays manageableMicroservicesslow start, scales teams well
Conceptual developer productivity for a 5-8 team organisation (higher is better).

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 context

Calling 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.

More Architecture articles