Modular Monolith
aka: Modulith, Majestic Monolith
Definition
- all communication is within a single process
- single binary for deployment and management with logical separation of features
- communication via functions calls defined through a class interface
- database is logically split between features with no cross-feature joins
Why?
- Software Modularity is important
- Make a Monolith modular
- Avoid the complexity of 30_Knowledge/Microservices
Popular Examples
Building a modular monolith
Code Structure
- internal modules are separated based on bounded contexts (DDD)
- each module provide an interface
Tooling
- Spring Modulith
- ArchUnit
- Checkstyle
- JDepend
- CodeAssert (GitHub)
Modularity vs. DRY – Don't repeat yourself
You must also ignore that urge of being “DRY”. You will probably end up with duplicate code in some places. And that is ok! Rather some duplication of code in independent modules, than unnecessary dependencies between modules.
— Build the modular monolith first
Resources
- Modular Monolith - Awesome Software Architecture
- MonolithFirst
- Build the modular monolith first
- kgrzybek/modular-monolith-with-ddd: Full Modular Monolith application with Domain-Driven Design approach
🔗 References
Modulith First! Der angemessene Weg zu Microservices | Informatik Aktuell
Understanding the modular monolith and its ideal use cases | TechTarget