A Third Option, Neither MSA Nor Monolith: Spring Modulith
Key point
Yeogieotae used Spring Modulith to enforce module boundaries and event flows in code.
Details
As services grow, monoliths accumulate tangled dependencies, and MSA increases distributed complexity. Yeogieotae's product development team chose Modular Monolith and Spring Modulith as a middle-ground solution. Spring Modulith went through incubation in 2022 and reached 1.0 GA in November 2023, and it now continues through the 2.x stable version. The team runs 1.3.x on top of Spring Boot 3.4 and plans to upgrade to 2.x when they move to Boot 4.
Module boundaries are declared with @ApplicationModule and allowedDependencies, and ApplicationModules.of(...).verify() is put into CI to block disallowed references at the build stage. The default is CLOSED, but early in adoption they start with OPEN to first fix the direction of dependencies, and public APIs are exposed only through @NamedInterface.
Communication between modules is divided based on transactions.
- Reads that need validation within the same transaction call the query port directly.
- Follow-up processing after a change is published as an event and handled asynchronously after commit via @ApplicationModuleListener.
- The Search module receives change events from Room, RatePlan, RoomRate, CancellationPolicy, and ChildPolicy to update its read model.
spring-modulith-events-jdbcrecords state in theevent_publicationtable, enabling republishing of unprocessed events.
The Stay Product Service places property/shared at Layer 0, room/cancellationpolicy/childpolicy at Layer 1, rateplan/inventory at Layer 2, roomrate at Layer 3, rate at Layer 4, and search/booking at Layer 5, controlling both reference direction and change frequency together. Each module's internals are built with hexagonal architecture, and documentation is auto-generated as PlantUML and AsciiDoc using Documenter. Naming collisions from identical class names were resolved with a custom BeanNameGenerator, tests verify asynchronous event flows using the Scenario API, and spring-modulith-actuator and spring-modulith-observability are used to check /actuator/modulith as well.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.