Monolithic Architecture
How monoliths work, why they are the right starting point for most systems, and what a well-structured monolith looks like.
Anatomy of a monolith
A monolith is a single deployable unit: one codebase, one build artifact, one process (or several identical replicas), and typically one shared database. All features — users, orders, payments, notifications — live in the same deployment.
Why monoliths are a great default
Monoliths get an unfair reputation. For most teams and most products, a monolith is the correct starting architecture.
- Simple to develop — one repo, one IDE, one debugger, in-process function calls.
- Simple to test — end-to-end tests run against a single process.
- Simple to deploy — copy one artifact, run it.
- ACID transactions — a single database gives strong consistency for free.
- No network overhead — module calls are nanoseconds, not milliseconds.
The modular monolith
The key to a healthy monolith is internal modularity. Organize code around business capabilities (orders, billing, catalog) instead of technical layers, enforce boundaries between modules, and let each module own its tables.
A modular monolith is also the best launchpad for microservices: if boundaries are clean, extracting a module into a service later is a mechanical exercise rather than an archaeology project.
src/
modules/
catalog/ # owns product tables
api/
domain/
persistence/
orders/ # owns order tables
api/
domain/
persistence/
billing/ # owns invoice tables
shared/
events/ # in-process event bus between modulesKey takeaways
- A monolith is one deployable unit with (usually) one shared database.
- Monoliths maximize development speed, testability, and consistency for small teams.
- Structure monoliths around business capabilities, not technical layers.
- A modular monolith is the ideal launchpad for future service extraction.
Knowledge check
What is the defining characteristic of a monolithic architecture?
Which is a genuine advantage of a monolith over microservices?
Your monolith's modules all reach directly into each other's database tables. What is the biggest long-term risk?