Modular Monoliths — Brief Overview
Modular monoliths are becoming a more popular architectural structure. But what is it?
A modular monolith is an architecture pattern with clearly defined and independent subunits or modules. Each module is logically separated from the others but exists within the same application. Modules are loosely coupled and communicate with a public API.
Consider a simple shopping example with users (shoppers) and books (items). There will be a separate module for both users and books that contain all the logic that is needed. If the users module needs information from the books module, it will communicate via a public API to get the specific book data it needs, but all the internals of the book module is hidden from the users module. The users module only sees the public interface that exposes the API.
If this sounds like microservices, it’s because it’s the same concept only microservices have a physical separation instead of just a logical one.
Benefits:
Modular monoliths take the best of monoliths and microservices. It has the modularity of microservices but the ease of use/development of monoliths.
Since each module is logically separated from the others, it is simple to make changes or expansions to one module without affecting the rest of the application, which is a typical pitfall of traditional monoliths.
But it is a single application, so it is one deployment and communication within is simpler since it is not having to communicate with other applications. Any changes to one module are easier to handle without having to worry about those changes affecting a separate application. If any module change requires changes in another module, it is still within a single application.