A Monolith Is a Deployment Choice, Not a Code Quality Problem
Tell someone you're building a monolith and they may imagine a giant application where every module imports every other module, every table is public property, and changing a button somehow breaks billing.
That application has problems. Shipping it as one unit is only one fact about it.
A monolith describes a deployment arrangement. It doesn't tell you whether the code has clear boundaries, whether the tests are useful, or whether anyone understands who owns the data.
There are two separate design questions
The first question is how the application is organized: what owns orders, who can change inventory, and which code decides whether a refund is allowed?
The second is how the application runs: which parts can be deployed, scaled, or restarted independently?
Those questions influence each other, but they aren't interchangeable. Fowler and Lewis describe microservices around independently deployable services and discuss the organizational and operational implications. Independent deployment is a capability with consequences, not a synonym for well-organized code. Microservices
To make the distinction concrete, imagine a small commerce application. These might be its modules:
application/
orders/
public_api.py
service.py
repository.py
inventory/
public_api.py
service.py
repository.py
billing/
public_api.py
service.py
repository.py
The folder names don't create boundaries. Rules about dependencies do.
Give modules an actual contract
Suppose checkout needs to reserve stock. The orders module could import an inventory table model and update its quantity directly. That is convenient until inventory develops rules around reservations, expiration, and warehouse allocation.
Instead, make the interaction explicit:
reservation = inventory.reserve(
order_id=order.id,
items=order.items,
)
This is an illustrative interface, not a complete checkout implementation. Its purpose is to expose a business operation while leaving inventory's storage details inside inventory.
I would make three rules visible in code review:
- Other modules call the public interface rather than internal repositories.
- Inventory owns the rules governing stock changes.
- The return value and failure behavior belong to the contract.
An architecture check that rejects forbidden imports can make those rules enforceable. Otherwise, a public_api.py file is just a polite suggestion.
One database still requires ownership
Sharing a database doesn't have to mean that every module writes every table.
For this example, orders owns order records and inventory owns reservations. A checkout application service coordinates their public operations. If both updates use the same transactional database and connection, the coordinator can arrange a local transaction around them.
That is a useful simplification. It should also be an explicit dependency: extracting inventory later would remove the assumption that both changes commit together.
The design work is in identifying that assumption now. Pretending there are already remote services by adding unnecessary HTTP calls inside one application doesn't resolve it.
Extract a service when you can name the benefit
Imagine image processing starts consuming most of the application's CPU. It has a clear input, a durable job, and an output asset. Giving it an independent worker deployment could solve a measurable scaling problem.
Now imagine splitting billing into a separate HTTP service merely because the billing directory is large. If every checkout still requires coordinated releases across both applications, what improved?
For a proposed extraction, I would ask:
- Which workload or team needs independent deployment?
- Which failures should be isolated?
- What data does the new service own?
- How will callers handle timeouts and repeated requests?
- Can the change be released without synchronizing every consumer?
Good answers don't guarantee success, but they explain what the extra operational work is buying.
Keep the limits honest
A modular monolith still shares important constraints. A bad release can affect the whole application. Scaling one hot path may require scaling the larger process. Module ownership can erode unless someone checks it.
Those are reasons to evaluate the design as the system changes. They aren't reasons to distribute every new application before its boundaries are understood.
For a small team, I would usually start with boundaries that are easy to inspect and enforce in one codebase. Track where releases, resource usage, and ownership become painful. Extract a service when the evidence points to a specific boundary and a concrete operational benefit.
The architecture should make the next change understandable. Counting deployable units won't tell you whether you've achieved that.
# Comments (0)
No comments yet. Be the first.