Monolith
- In Turkish
- Monolit
In short
A monolith is a software application built and deployed as a single unit, where all features share one codebase, one process, and usually one database.
What is a monolith?
In a monolithic architecture, the user interface, business logic, and data access for every feature live in one codebase and are deployed together. An online store built as a monolith would handle products, carts, payments, and user accounts inside the same application. Changing any part means building, testing, and releasing the whole application again.
Monoliths are simple to start with: there is one project to run locally, one thing to deploy, and calls between features are ordinary function calls that are fast and easy to debug. Transactions that span several features are also straightforward because everything usually uses the same database. This is why most new products and small teams begin with a monolith.
As an application and its team grow, a poorly structured monolith can become hard to change, because a small edit in one area may break another. Well-organized monoliths avoid this by dividing the code into internal modules with clear boundaries, an approach called a modular monolith.
The main alternative is microservices, where each feature runs as a separate, independently deployable service. A monolith is like one large department store under a single roof, while microservices are like a street of specialized shops. Monolith is not a synonym for bad code; it is a valid architecture with its own trade-offs.
Key takeaways
- A monolith is built, deployed, and scaled as a single unit.
- It is simple to develop, test, and deploy, especially early on.
- Large, poorly structured monoliths can become hard to change.
- A modular monolith keeps one deployment but enforces clear internal boundaries.
Example
// One codebase, one deployment: every feature is part of the same app
import { createServer } from "./server";
import { productRoutes } from "./products";
import { cartRoutes } from "./cart";
import { paymentRoutes } from "./payments";
const app = createServer();
// All features run in the same process and share one database
app.use(productRoutes);
app.use(cartRoutes);
app.use(paymentRoutes);
app.listen(3000);Readers ask
What is the difference between a monolith and microservices?
A monolith is deployed as one application, while microservices split the system into many small services that are deployed and scaled independently. Monoliths are simpler to build and run; microservices give large teams more independence at the cost of more operational complexity.
Is a monolith bad?
No. For most small and medium-sized projects, a well-structured monolith is simpler, cheaper, and faster to develop than microservices. Problems usually come from poor internal structure, not from being a monolith.
What is a modular monolith?
A modular monolith is a single deployable application whose code is split into independent modules with strict boundaries. It keeps the simplicity of one deployment while making it easier to extract separate services later if needed.
Often compared
See also
- MicroservicesSoftware Architecture, p. 27Microservices are an architectural style where an application is split into small, independently deployable services that communicate over a network.
- RefactoringSoftware Architecture, p. 33Refactoring is the process of restructuring existing code to make it cleaner and easier to maintain without changing what the code does from the outside.
- Technical DebtSoftware Architecture, p. 45Technical debt is the future cost of extra work created when developers choose a quick or limited solution now instead of a better approach that takes longer.
- DatabaseDatabases, p. 6A database is an organized collection of data stored on a computer, managed by software that lets applications save, search, and update it efficiently.
- CI/CDDevOps & Cloud, p. 9CI/CD is a set of automated practices that build, test, and release code changes frequently, so software can be delivered to users quickly and safely.
- MVCSoftware Architecture, p. 29MVC is an architectural pattern that splits an application into a Model for data and logic, a View for display, and a Controller that handles user input.
- Strangler Fig PatternSoftware Architecture, p. 43The strangler fig pattern is a way to replace a legacy system gradually by routing features to new code one at a time until the old system can be retired.
Spotted a mistake or something missing on this page?Suggest an edit