On this page
A monolithic application is built, tested and deployed as one unit, with all its modules in a single process. A microservices architecture splits the application into small services that each run in their own process, own their data and deploy independently, talking over HTTP, gRPC or message queues. Monoliths are simpler to build and run; microservices let large teams ship and scale parts of the system on their own.
Related: what is a monorepo, and monorepo vs polyrepo covers where the code lives, which is a separate choice.
Monolith vs microservices: the short answer
Start with a monolith, keep its modules separated, and move a module out into a service only when it needs its own deploy schedule, its own scaling or its own team. James Lewis and Martin Fowler's 2014 definition describes the microservice style as "an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API."
| Monolith | Microservices | |
|---|---|---|
| Deploy unit | The whole application | Each service |
| Process | One | One or more per service |
| Communication between parts | In-process function calls | Network calls (HTTP, gRPC, events) |
| Data | Usually one shared database | Each service owns its data |
| Scaling | Scale the whole app | Scale each service on its own |
| Failure | A crash can take down everything | A service fails alone, if callers handle it |
| Transactions | Local database transactions | Sagas, outbox, eventual consistency |
| Debugging | One stack trace, one log | Distributed tracing across services |
| Team fit | One team or a few | Many teams, each owning services |
| Operations | One pipeline, one runtime | A pipeline, runtime and alerts per service |
Scroll the table sideways to see every column.
Advantages and drawbacks of each
A monolith's strength is that everything is one function call away; its weakness is that everything also ships together. Microservices reverse both.
Monolith
Advantages: one codebase to run locally, one deploy, refactors checked by the compiler or tests across the whole app, local transactions, and simple debugging. Performance is good by default, because calls between modules cost nothing over the network.
Drawbacks: every change ships the whole application, so one risky change holds up the rest. Build and test time grows with the codebase. Scaling one hot path means scaling everything. Without enforced boundaries, modules reach into each other until no part can change alone.
Microservices
Advantages: teams deploy on their own schedule, each service scales to its own load, a failure can be contained to one service, and each service can use the stack that fits it.
Drawbacks: every call between services can fail, time out or arrive twice. Data is split, so a query across services becomes an API composition or a copy, and a transaction across services needs a saga. You need service discovery, tracing, per-service CI and on-call for each service. A change that crosses services needs versioned contracts and a deploy order. Splitting too early also freezes boundaries before you know where they belong.
Martin Fowler's MonolithFirst (June 2015) puts the evidence plainly: "Almost all the successful microservice stories have started with a monolith that got too big and was broken up."
The modular monolith in between
A modular monolith is one deployable application split into modules with enforced boundaries: each module has a public interface, owns its tables and cannot import another module's internals. It keeps the monolith's single deploy and in-process calls, and gets most of the independence microservices promise for code ownership.
Boundaries are enforced in code, not by the network:
- Import rules checked in CI (for example
import-linterfor Python,dependency-cruiseror Nx module boundaries for TypeScript,ArchUnitfor Java). - One schema or table prefix per module, with no cross-module joins.
- A
CODEOWNERSentry per module directory.
A modular monolith is also the safest starting point for a split. If a module already talks to the rest only through its public interface, moving it into a service changes the transport, not the design.
Monolith vs microservices example
Take an online store with catalog, cart, orders, payments and accounts, built both ways.
As a modular monolith:
store/
catalog/ # products, search
cart/
orders/ # calls payments.charge() in-process
payments/
accounts/
main.py # one web app, one deploy, one database
Placing an order is one request, one database transaction: create the order, charge the card, reduce stock. If the charge fails, the transaction rolls back.
As microservices:
catalog-service GET /products, owns products DB
cart-service owns carts
order-service POST /orders, owns orders DB
payment-service gRPC Charge(), owns payments DB
account-service owns users
events order.placed, payment.succeeded (Kafka topic)
Placing an order is now a workflow. order-service creates a pending order and calls payment-service; on success it publishes order.placed, and catalog-service reduces stock when it consumes the event. If the charge fails after the order was created, order-service has to cancel it with a compensating step. Each service can deploy and scale on its own, and the checkout path now depends on three services and a message broker being up.
How to convert a monolith to microservices
Extract one module at a time behind a stable interface, starting with the module that has the cleanest boundary, and route traffic to the new service gradually. This is the strangler fig pattern: the new system grows around the old one until the old part can be removed.
- Map the real dependencies. Folder names describe intent. The import graph shows which modules call which, and how many files in other modules depend on each one.
- Find the seams. A good first candidate has few inbound imports from other modules, no cycles with them, and its own tables.
- Check co-change. Files in two modules that change in the same commits are coupled even when no import connects them. Extracting one without the other turns every such change into a cross-service release. See hidden coupling and co-change detection.
- Check ownership. A module that one team already owns is a natural service. A module five teams edit is not ready.
- Put an interface in front. Make the rest of the monolith call the module only through one interface, still in-process.
- Move the data. Give the module its own schema and stop other modules reading its tables.
- Swap the transport. Replace the in-process interface with an HTTP or gRPC client, route a share of traffic, then all of it.
Steps 1 to 4 are measurement, and they decide whether the rest goes well. In 195 of the most-starred public repositories indexed on repowise.dev (1,000+ GitHub stars each, November 2026), the median repository had 7 top-level modules and 3.0 import edges per production file, its single most-imported file was imported by 20% of production files, and 173 of the 195 (89%) had at least one circular import chain between files. Cycles and hub files are exactly what blocks a clean extraction, and they are rarely visible from the folder tree.
Microservices still couple: contracts between services
Splitting a monolith moves coupling from imports to contracts: HTTP routes, gRPC methods, event topics and shared tables. The coupling is still there, but the compiler no longer sees it. Removing a field from a response breaks a consumer in another repository, and nothing fails until that consumer runs.
So the map has to continue across services: which service provides each endpoint or topic, which files consume it, and whether a change removed or retyped something a consumer reads. Without that, a microservices codebase is harder to change safely than the monolith it replaced. Context-aware code review for coupled code and microservices covers reviewing changes that cross these boundaries.
See the seams with repowise
repowise builds the module and file dependency graph, co-change pairs and owners from your code and git history, so the seams for a split are measured, not guessed. The architecture view shows modules with their import edges, circular groups, hub files and a C4-style system diagram. Open Temporal's architecture map, a large Go codebase with zero circular import groups among its production files, to see what clean module boundaries look like.
After the split, a repowise workspace indexes the service repositories together. It extracts HTTP routes, gRPC services, message topics and database tables, matches each provider to its consumers across repositories, and runs a breaking-change guard on every update that flags a removed endpoint or a changed field type along with the consumer files linked to it. Dependency rules in .repowise-workspace.yaml (for example, "the frontend never calls the database directly") are checked against the live system graph, and cycles between services are reported. Setup: workspaces.
FAQ
- What are the drawbacks of microservices?
- Microservices add network calls that can fail or time out, split data across services so cross-service queries and transactions get harder, and need tracing, service discovery and a deploy pipeline per service. Changes that cross services need versioned contracts and a deploy order. Teams pay these costs from the first service, before the benefits arrive.
- Is a REST API a microservice?
- No. A REST API is an interface style; a microservice is a deployment unit. A microservice often exposes a REST API, but a monolith can expose one too. What makes a service a microservice is that it runs in its own process, owns its data and deploys independently.
- Is Kafka a microservice?
- No. Kafka is an event streaming platform. Microservices often use it to publish and consume events asynchronously, so services do not have to call each other directly. The topics on Kafka are contracts between services, just like HTTP routes.
- How do you convert a monolith to microservices?
- Extract one module at a time with the strangler fig pattern. Map the import graph, co-change and ownership first, pick the module with the fewest inbound dependencies and its own data, put an interface in front of it, move its data, then swap the in-process call for a network call and shift traffic gradually.
- Is monorepo the same as monolith?
- No. A monorepo is one repository that stores many projects. A monolith is one application deployed as a single unit. Many teams run microservices from a monorepo, and a monolith can be spread across several repositories.



