How odrotbohm/cqrs-spring-modulith works
This Spring Modulith application exposes product write operations and product-view queries through HTTP. The write workflow validates and persists product or review changes, then publishes domain events; listeners update a separate read model that supports listing and category, price, and rating queries. The graph distinguishes those domain stages and includes the aggregate and repositories as an internal layer. Source excerpts show the command and event-handler calls; API/query capabilities also come from the README and sampled controller. Database wiring details were not sampled.
Main entry points: ProductCommandService.java Command Service · ProductEventHandler.java View Event Handler · ProductViewRepository.java View Repository · Review.java Review Entity
Components 12
HTTP API
- Command Controller
src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandController.java - View Controller
src/main/java/gae/piaz/modulith/cqrs/products/query/ProductViewController.java
Product Commands
- Command Service
src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandService.java - Product Repository
src/main/java/gae/piaz/modulith/cqrs/products/command/ProductRepository.java
Product Queries
- View Event Handler
src/main/java/gae/piaz/modulith/cqrs/products/query/ProductEventHandler.java - Product View
src/main/java/gae/piaz/modulith/cqrs/products/query/ProductView.java - View Repository
src/main/java/gae/piaz/modulith/cqrs/products/query/ProductViewRepository.java
Domain Model
- Product Aggregate
src/main/java/gae/piaz/modulith/cqrs/products/command/Product.java - Review Entity
src/main/java/gae/piaz/modulith/cqrs/products/command/Review.java - Review Identifier
src/main/java/gae/piaz/modulith/cqrs/products/command/ReviewIdentifier.java - Product Events
src/main/java/gae/piaz/modulith/cqrs/products/command/ProductEvents.java
Other components
- API Client
Connections 13
- API Client → Command Controller: submits commands
src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandController.java - API Client → View Controller: requests views
src/main/java/gae/piaz/modulith/cqrs/products/query/ProductViewController.java - Command Controller → Command Service: delegates writes
src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandController.java - Command Service → Product Repository: loads and saves
src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandService.java - Command Service → Product Events: publishes events
src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandService.java - Command Service → Review Entity: creates reviews
src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandService.java - Product Aggregate → Review Entity: contains reviews
src/main/java/gae/piaz/modulith/cqrs/products/command/Product.java - Review Entity → Review Identifier: uses identifier
src/main/java/gae/piaz/modulith/cqrs/products/command/Review.java - View Event Handler → Product Events: handles events
src/main/java/gae/piaz/modulith/cqrs/products/query/ProductEventHandler.java - View Event Handler → View Repository: updates read model
src/main/java/gae/piaz/modulith/cqrs/products/query/ProductEventHandler.java - View Event Handler → Product View: constructs and updates
src/main/java/gae/piaz/modulith/cqrs/products/query/ProductEventHandler.java - View Controller → View Repository: queries views
src/main/java/gae/piaz/modulith/cqrs/products/query/ProductViewController.java - View Repository → Product View: stores views
src/main/java/gae/piaz/modulith/cqrs/products/query/ProductViewRepository.java