Modulith: enforce domain boundaries before distribution
Prerequisites: 01-ecosystem
What is a legitimate module dependency?
Goal & mental model verified
Spring Modulith derives application modules from a Boot application structure and supports boundary verification. Modules expose APIs/named interfaces while keeping implementation details internal.
[S54]Worked example · design exercise synthesis
Separate quotes, policies and billing into modules. Quotes calls the published policy API or emits a domain event; it should not reach directly into billing’s internal persistence package.
[S54]Engineering decision synthesis
Use a modular monolith when one deployment can satisfy operational needs. This preserves local interactions while clarifying boundaries, but independent scaling/deployment may later justify extraction.
[S54]Pitfall & diagnosis synthesis
Package names alone cannot prevent coupling if public internals are widely imported. Replacing calls with events changes consistency and failure semantics; it is not automatically an improvement.
[S54]Improve & validate synthesis
Run module dependency verification and focused module tests. Track coupling and change ownership before extracting a service; choose extraction based on an actual deployment constraint.
[S54]Check yourself: Does Modulith require microservices?
No. It is designed to structure modules within a Spring Boot application.