# odrotbohm/cqrs-spring-modulith architecture

> Architecture diagram of the GitHub repository odrotbohm/cqrs-spring-modulith, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/odrotbohm/cqrs-spring-modulith
- Repository: https://github.com/odrotbohm/cqrs-spring-modulith

## Overview

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: [`src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandService.java`](https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandService.java) (Command Service), [`src/main/java/gae/piaz/modulith/cqrs/products/query/ProductEventHandler.java`](https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/query/ProductEventHandler.java) (View Event Handler), [`src/main/java/gae/piaz/modulith/cqrs/products/query/ProductViewRepository.java`](https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/query/ProductViewRepository.java) (View Repository), [`src/main/java/gae/piaz/modulith/cqrs/products/command/Review.java`](https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/command/Review.java) (Review Entity)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_command_api["Command Controller"]
  node_view_api["View Controller"]
end

subgraph group_write["Product Commands"]
  node_command_service["Command Service"]
  node_product_repo["Product Repository"]
end

subgraph group_read["Product Queries"]
  node_event_handler["View Event Handler"]
  node_view["Product View<br/>[ProductView.java]"]
  node_view_repo["View Repository"]
end

subgraph group_domain["Domain Model"]
  node_product["Product Aggregate<br/>[Product.java]"]
  node_review["Review Entity<br/>[Review.java]"]
  node_review_id["Review Identifier"]
  node_events["Product Events<br/>[ProductEvents.java]"]
end

node_client(("API Client"))

node_client -->|"submits commands"| node_command_api
node_client -->|"requests views"| node_view_api
node_command_api -->|"delegates writes"| node_command_service
node_command_service -->|"loads and saves"| node_product_repo
node_command_service -->|"publishes events"| node_events
node_command_service -->|"creates reviews"| node_review
node_product -->|"contains reviews"| node_review
node_review -->|"uses identifier"| node_review_id
node_event_handler -->|"handles events"| node_events
node_event_handler -->|"updates read model"| node_view_repo
node_event_handler -->|"constructs and updates"| node_view
node_view_api -->|"queries views"| node_view_repo
node_view_repo -->|"stores views"| node_view

click node_command_api "https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandController.java"
click node_view_api "https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/query/ProductViewController.java"
click node_command_service "https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandService.java"
click node_product_repo "https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/command/ProductRepository.java"
click node_product "https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/command/Product.java"
click node_review "https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/command/Review.java"
click node_review_id "https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/command/ReviewIdentifier.java"
click node_events "https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/command/ProductEvents.java"
click node_event_handler "https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/query/ProductEventHandler.java"
click node_view "https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/query/ProductView.java"
click node_view_repo "https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/query/ProductViewRepository.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_command_api,node_view_api,node_client toneBlue
class node_command_service,node_product_repo toneAmber
class node_event_handler,node_view,node_view_repo toneMint
class node_product,node_review,node_review_id,node_events toneRose
```

## Components

### HTTP API

- [Command Controller](https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandController.java): `src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandController.java`
- [View Controller](https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/query/ProductViewController.java): `src/main/java/gae/piaz/modulith/cqrs/products/query/ProductViewController.java`

### Product Commands

- [Command Service](https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandService.java): `src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandService.java`
- [Product Repository](https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/command/ProductRepository.java): `src/main/java/gae/piaz/modulith/cqrs/products/command/ProductRepository.java`

### Product Queries

- [View Event Handler](https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/query/ProductEventHandler.java): `src/main/java/gae/piaz/modulith/cqrs/products/query/ProductEventHandler.java`
- [Product View](https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/query/ProductView.java): `src/main/java/gae/piaz/modulith/cqrs/products/query/ProductView.java`
- [View Repository](https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/query/ProductViewRepository.java): `src/main/java/gae/piaz/modulith/cqrs/products/query/ProductViewRepository.java`

### Domain Model

- [Product Aggregate](https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/command/Product.java): `src/main/java/gae/piaz/modulith/cqrs/products/command/Product.java`
- [Review Entity](https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/command/Review.java): `src/main/java/gae/piaz/modulith/cqrs/products/command/Review.java`
- [Review Identifier](https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/command/ReviewIdentifier.java): `src/main/java/gae/piaz/modulith/cqrs/products/command/ReviewIdentifier.java`
- [Product Events](https://github.com/odrotbohm/cqrs-spring-modulith/blob/main/src/main/java/gae/piaz/modulith/cqrs/products/command/ProductEvents.java): `src/main/java/gae/piaz/modulith/cqrs/products/command/ProductEvents.java`

### Other components

- **API Client**

## Connections

- API Client → Command Controller: submits commands (evidence: `src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandController.java`)
- API Client → View Controller: requests views (evidence: `src/main/java/gae/piaz/modulith/cqrs/products/query/ProductViewController.java`)
- Command Controller → Command Service: delegates writes (evidence: `src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandController.java`)
- Command Service → Product Repository: loads and saves (evidence: `src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandService.java`)
- Command Service → Product Events: publishes events (evidence: `src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandService.java`)
- Command Service → Review Entity: creates reviews (evidence: `src/main/java/gae/piaz/modulith/cqrs/products/command/ProductCommandService.java`)
- Product Aggregate → Review Entity: contains reviews (evidence: `src/main/java/gae/piaz/modulith/cqrs/products/command/Product.java`)
- Review Entity → Review Identifier: uses identifier (evidence: `src/main/java/gae/piaz/modulith/cqrs/products/command/Review.java`)
- View Event Handler → Product Events: handles events (evidence: `src/main/java/gae/piaz/modulith/cqrs/products/query/ProductEventHandler.java`)
- View Event Handler → View Repository: updates read model (evidence: `src/main/java/gae/piaz/modulith/cqrs/products/query/ProductEventHandler.java`)
- View Event Handler → Product View: constructs and updates (evidence: `src/main/java/gae/piaz/modulith/cqrs/products/query/ProductEventHandler.java`)
- View Controller → View Repository: queries views (evidence: `src/main/java/gae/piaz/modulith/cqrs/products/query/ProductViewController.java`)
- View Repository → Product View: stores views (evidence: `src/main/java/gae/piaz/modulith/cqrs/products/query/ProductViewRepository.java`)
