# Monoliths and Modular Monoliths

> Build a single deployable application with clear internal boundaries, the right starting point for most products. Free notes, key concepts, resources and a...

Canonical: https://www.internhack.in/roadmaps/tracks/backend/monolith-modular
Last updated: 2026-11-28

Build a single deployable application with clear internal boundaries, the right starting point for most products.

Intermediate · about 4 hours · difficulty 3/5

Learn first: [Resource-Oriented REST APIs](https://www.internhack.in/roadmaps/tracks/backend/rest-api-design), [Unit Testing Fundamentals](https://www.internhack.in/roadmaps/tracks/backend/unit-testing)

A **monolith** is one deployable application containing all features. The word gets used as an insult, but most successful products started as one, and many still are. The real enemy is not the monolith, it is the **big ball of mud**: code where everything calls everything.

### Why start here

- One codebase, one deploy, one database: easy to develop, test, debug and refactor.
- Function calls instead of network calls: no partial failures, no distributed transactions.
- Small teams move fastest when they do not have to coordinate service contracts.

### The modular monolith

Keep one deployable, but organize code into **modules by business capability** (billing, catalog, accounts) instead of by technical layer alone:

- Each module has a small **public interface**; other modules may not reach into its internals or its tables.
- Enforce boundaries with folder rules, package visibility or lint rules (for example dependency-cruiser in TypeScript, ArchUnit in Java).
- Communicate between modules through interfaces or in-process events.

### Layering inside a module

A common arrangement is **controller** (HTTP concerns) to **service** (business logic) to **repository** (data access). Keep business rules out of controllers and SQL out of services so each piece is testable on its own. Hexagonal or "ports and adapters" architecture is a more formal version of the same idea.

### When a monolith hurts

Very large teams stepping on each other, parts with wildly different scaling or reliability needs, or deploys that take hours. A well-modularized monolith makes extracting a service later straightforward.

You are ready to move on when your project has modules with explicit public interfaces and a check that fails the build if one module imports another's internals.

## Key concepts

- **Monolith vs big ball of mud**
- **Modules by business capability**
- **Controller, service, repository layers**
- **Enforcing module boundaries**
- **Hexagonal architecture (ports and adapters)**
- **When to split a monolith**

## Mini project

Refactor an existing API into three modules with public interfaces, add a lint rule that forbids cross-module internal imports, and document each module's responsibilities.

## Check yourself

What is the difference between a monolith and a big ball of mud?

## Free resources

- [MonolithFirst](https://martinfowler.com/bliki/MonolithFirst.html) (Martin Fowler)
- [Hexagonal architecture](https://alistair.cockburn.us/hexagonal-architecture/) (Alistair Cockburn)
- [Architecture styles](https://learn.microsoft.com/en-us/azure/architecture/guide/architecture-styles/) (Microsoft Learn)

Previous: [Apache HTTP Server](https://www.internhack.in/roadmaps/tracks/backend/apache-httpd) · Next: [Microservices and Service-Oriented Architecture](https://www.internhack.in/roadmaps/tracks/backend/microservices-soa)

## More in Architecture and Design Patterns

- [Monoliths and Modular Monoliths](https://www.internhack.in/roadmaps/tracks/backend/monolith-modular)
- [Microservices and Service-Oriented Architecture](https://www.internhack.in/roadmaps/tracks/backend/microservices-soa)
- [Serverless and Functions as a Service](https://www.internhack.in/roadmaps/tracks/backend/serverless)
- [Twelve-Factor Apps and Cloud-Native Habits](https://www.internhack.in/roadmaps/tracks/backend/twelve-factor-apps)
- [Service Mesh](https://www.internhack.in/roadmaps/tracks/backend/service-mesh)
- [Design Patterns for Backend Code](https://www.internhack.in/roadmaps/tracks/backend/design-patterns-gof)
- [Domain-Driven Design](https://www.internhack.in/roadmaps/tracks/backend/domain-driven-design)
- [CQRS and Event Sourcing](https://www.internhack.in/roadmaps/tracks/backend/cqrs-event-sourcing)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Backend Developer Roadmap](https://www.internhack.in/roadmaps/tracks/backend)
