# ksenmay/modsen-catalog architecture

> Architecture diagram of the GitHub repository ksenmay/modsen-catalog, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ksenmay/modsen-catalog
- Repository: https://github.com/ksenmay/modsen-catalog

## Overview

MODSEN CATALOG is a Spring application for role-based administration of a product catalog, with CRUD operations and user authentication. The main workflow is an API request handled by a controller, processed by an application service, and persisted through repository ports; product, category, user, and review management are distinct stages. Price history and application events support additional workflows. The source excerpts show several service-to-port calls, but not the adapter implementations or full event wiring, so those links are omitted or marked unverified.

Main entry points: [`src/main/java/by/may/application/service/ProductService.java`](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/service/ProductService.java) (Product management), [`src/main/java/by/may/application/port/EventPublisher.java`](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/port/EventPublisher.java) (Event publisher), [`src/main/java/by/may/application/service/ReviewService.java`](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/service/ReviewService.java) (Review management), [`src/main/java/by/may/application/service/CategoryService.java`](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/service/CategoryService.java) (Category management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Web API"]
  node_product_api["Product API"]
  node_category_api["Category API"]
  node_user_api["User API"]
  node_review_api["Review API"]
  node_auth_api["Auth API"]
  node_exception_handler["Error responses"]
end

subgraph group_services["Application Services"]
  node_product_service["Product management"]
  node_category_service["Category management"]
  node_user_service["User management<br/>[UserService.java]"]
  node_review_service["Review management<br/>[ReviewService.java]"]
  node_auth_service["Authentication<br/>[AuthService.java]"]
  node_price_service["Price history"]
end

subgraph group_persistence["Persistence"]
  node_category_port["Category repository port"]
  node_product_port["Product repository port"]
  node_user_port["User repository port"]
  node_review_port["Review repository port"]
  node_history_port["History repository port"]
end

subgraph group_events["Events and Security"]
  node_event_publisher["Event publisher"]
  node_spring_publisher["Spring event adapter"]
  node_event_handlers["Event handlers"]
  node_jwt["JWT security<br/>[JwtService.java]"]
end

node_client(("API client"))
node_postgres[("PostgreSQL")]

node_client -->|"requests"| node_product_api
node_client -.->|"requests"| node_category_api
node_client -->|"requests"| node_user_api
node_client -->|"requests"| node_review_api
node_client -.->|"authenticates"| node_auth_api
node_product_api -->|"calls"| node_product_service
node_product_api -->|"calls"| node_price_service
node_user_api -->|"calls"| node_user_service
node_review_api -->|"calls"| node_review_service
node_category_api -.->|"calls"| node_category_service
node_auth_api -.->|"calls"| node_auth_service
node_product_service -->|"reads and writes"| node_product_port
node_product_service -->|"saves history"| node_history_port
node_product_service -->|"soft deletes"| node_review_port
node_category_service -->|"reads and writes"| node_category_port
node_category_service -->|"checks usage"| node_product_port
node_user_service -->|"reads and writes"| node_user_port
node_review_service -->|"reads and writes"| node_review_port
node_review_service -->|"checks user"| node_user_port
node_review_service -->|"checks product"| node_product_port
node_auth_service -->|"reads and writes"| node_user_port
node_product_service -->|"publishes events"| node_event_publisher
node_category_service -->|"publishes events"| node_event_publisher
node_user_service -->|"publishes events"| node_event_publisher
node_review_service -->|"publishes events"| node_event_publisher
node_auth_service -->|"publishes events"| node_event_publisher
node_product_service -->|"persists history"| node_history_port
node_event_publisher -.->|"implemented by"| node_spring_publisher
node_spring_publisher -.->|"dispatches events"| node_event_handlers
node_auth_service -->|"creates tokens"| node_jwt
node_product_port -.->|"persists through"| node_postgres
node_category_port -.->|"persists through"| node_postgres
node_user_port -.->|"persists through"| node_postgres
node_review_port -.->|"persists through"| node_postgres
node_history_port -.->|"persists through"| node_postgres

click node_product_api "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/web/controllers/ProductController.java"
click node_category_api "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/web/controllers/CategoryController.java"
click node_user_api "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/web/controllers/UserController.java"
click node_review_api "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/web/controllers/ReviewController.java"
click node_auth_api "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/web/controllers/AuthController.java"
click node_product_service "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/service/ProductService.java"
click node_category_service "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/service/CategoryService.java"
click node_user_service "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/service/UserService.java"
click node_review_service "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/service/ReviewService.java"
click node_auth_service "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/service/AuthService.java"
click node_price_service "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/service/PriceHistoryService.java"
click node_category_port "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/port/CategoryRepositoryPort.java"
click node_product_port "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/port/ProductRepositoryPort.java"
click node_user_port "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/port/UserRepositoryPort.java"
click node_review_port "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/port/ReviewRepositoryPort.java"
click node_history_port "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/port/PriceHistoryRepositoryPort.java"
click node_event_publisher "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/port/EventPublisher.java"
click node_spring_publisher "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/infrastructure/event/SpringEventPublisher.java"
click node_event_handlers "https://github.com/ksenmay/modsen-catalog/tree/main/src/main/java/by/may/infrastructure/listener"
click node_jwt "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/infrastructure/security/JwtService.java"
click node_exception_handler "https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/web/advice/GlobalExceptionHandler.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_product_api,node_category_api,node_user_api,node_review_api,node_auth_api,node_exception_handler,node_client toneBlue
class node_product_service,node_category_service,node_user_service,node_review_service,node_auth_service,node_price_service,node_postgres toneAmber
class node_category_port,node_product_port,node_user_port,node_review_port,node_history_port toneMint
class node_event_publisher,node_spring_publisher,node_event_handlers,node_jwt toneRose
```

## Components

### Web API

- [Product API](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/web/controllers/ProductController.java): `src/main/java/by/may/web/controllers/ProductController.java`
- [Category API](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/web/controllers/CategoryController.java): `src/main/java/by/may/web/controllers/CategoryController.java`
- [User API](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/web/controllers/UserController.java): `src/main/java/by/may/web/controllers/UserController.java`
- [Review API](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/web/controllers/ReviewController.java): `src/main/java/by/may/web/controllers/ReviewController.java`
- [Auth API](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/web/controllers/AuthController.java): `src/main/java/by/may/web/controllers/AuthController.java`
- [Error responses](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/web/advice/GlobalExceptionHandler.java): `src/main/java/by/may/web/advice/GlobalExceptionHandler.java`

### Application Services

- [Product management](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/service/ProductService.java): `src/main/java/by/may/application/service/ProductService.java`
- [Category management](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/service/CategoryService.java): `src/main/java/by/may/application/service/CategoryService.java`
- [User management](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/service/UserService.java): `src/main/java/by/may/application/service/UserService.java`
- [Review management](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/service/ReviewService.java): `src/main/java/by/may/application/service/ReviewService.java`
- [Authentication](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/service/AuthService.java): `src/main/java/by/may/application/service/AuthService.java`
- [Price history](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/service/PriceHistoryService.java): `src/main/java/by/may/application/service/PriceHistoryService.java`

### Persistence

- [Category repository port](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/port/CategoryRepositoryPort.java): `src/main/java/by/may/application/port/CategoryRepositoryPort.java`
- [Product repository port](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/port/ProductRepositoryPort.java): `src/main/java/by/may/application/port/ProductRepositoryPort.java`
- [User repository port](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/port/UserRepositoryPort.java): `src/main/java/by/may/application/port/UserRepositoryPort.java`
- [Review repository port](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/port/ReviewRepositoryPort.java): `src/main/java/by/may/application/port/ReviewRepositoryPort.java`
- [History repository port](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/port/PriceHistoryRepositoryPort.java): `src/main/java/by/may/application/port/PriceHistoryRepositoryPort.java`

### Events and Security

- [Event publisher](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/application/port/EventPublisher.java): `src/main/java/by/may/application/port/EventPublisher.java`
- [Spring event adapter](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/infrastructure/event/SpringEventPublisher.java): `src/main/java/by/may/infrastructure/event/SpringEventPublisher.java`
- [Event handlers](https://github.com/ksenmay/modsen-catalog/tree/main/src/main/java/by/may/infrastructure/listener): `src/main/java/by/may/infrastructure/listener`
- [JWT security](https://github.com/ksenmay/modsen-catalog/blob/main/src/main/java/by/may/infrastructure/security/JwtService.java): `src/main/java/by/may/infrastructure/security/JwtService.java`

### Other components

- **API client**
- **PostgreSQL**

## Connections

- API client → Product API: requests (evidence: `src/main/java/by/may/web/controllers/ProductController.java`)
- API client → Category API: requests
- API client → User API: requests (evidence: `src/main/java/by/may/web/controllers/UserController.java`)
- API client → Review API: requests (evidence: `src/main/java/by/may/web/controllers/ReviewController.java`)
- API client → Auth API: authenticates
- Product API → Product management: calls (evidence: `src/main/java/by/may/web/controllers/ProductController.java`)
- Product API → Price history: calls (evidence: `src/main/java/by/may/web/controllers/ProductController.java`)
- User API → User management: calls (evidence: `src/main/java/by/may/web/controllers/UserController.java`)
- Review API → Review management: calls (evidence: `src/main/java/by/may/web/controllers/ReviewController.java`)
- Category API → Category management: calls (evidence: `src/main/java/by/may/web/controllers/CategoryController.java`)
- Auth API → Authentication: calls
- Product management → Product repository port: reads and writes (evidence: `src/main/java/by/may/application/service/ProductService.java`)
- Product management → History repository port: saves history (evidence: `src/main/java/by/may/application/service/ProductService.java`)
- Product management → Review repository port: soft deletes (evidence: `src/main/java/by/may/application/service/ProductService.java`)
- Category management → Category repository port: reads and writes (evidence: `src/main/java/by/may/application/service/CategoryService.java`)
- Category management → Product repository port: checks usage (evidence: `src/main/java/by/may/application/service/CategoryService.java`)
- User management → User repository port: reads and writes (evidence: `src/main/java/by/may/application/service/UserService.java`)
- Review management → Review repository port: reads and writes (evidence: `src/main/java/by/may/application/service/ReviewService.java`)
- Review management → User repository port: checks user (evidence: `src/main/java/by/may/application/service/ReviewService.java`)
- Review management → Product repository port: checks product (evidence: `src/main/java/by/may/application/service/ReviewService.java`)
- Authentication → User repository port: reads and writes (evidence: `src/main/java/by/may/application/service/AuthService.java`)
- Product management → Event publisher: publishes events (evidence: `src/main/java/by/may/application/service/ProductService.java`)
- Category management → Event publisher: publishes events (evidence: `src/main/java/by/may/application/service/CategoryService.java`)
- User management → Event publisher: publishes events (evidence: `src/main/java/by/may/application/service/UserService.java`)
- Review management → Event publisher: publishes events (evidence: `src/main/java/by/may/application/service/ReviewService.java`)
- Authentication → Event publisher: publishes events (evidence: `src/main/java/by/may/application/service/AuthService.java`)
- Product management → History repository port: persists history (evidence: `src/main/java/by/may/application/service/ProductService.java`)
- Event publisher → Spring event adapter: implemented by
- Spring event adapter → Event handlers: dispatches events
- Authentication → JWT security: creates tokens (evidence: `src/main/java/by/may/application/service/AuthService.java`)
- Product repository port → PostgreSQL: persists through
- Category repository port → PostgreSQL: persists through
- User repository port → PostgreSQL: persists through
- Review repository port → PostgreSQL: persists through
- History repository port → PostgreSQL: persists through
