# tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg architecture

> Architecture diagram of the GitHub repository tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg
- Repository: https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg

## Overview

This is a Spring MVC REST example for managing beers and customers. Clients send CRUD requests to the resource controllers, which delegate to service APIs and return DTOs or HTTP status responses. The service layer has in-memory and JPA-backed implementations; the latter maps DTOs to entities and uses Spring Data repositories. Bootstrap data and SQL migrations support initializing and evolving the database. The source index and excerpts establish these components, but do not show how the application selects a service implementation or configures its database.

Main entry points: [`src/main/java/guru/springframework/spring7restmvc/bootstrap/BootstrapData.java`](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/bootstrap/BootstrapData.java) (Bootstrap Data), [`src/main/java/guru/springframework/spring7restmvc/controller/BeerController.java`](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/controller/BeerController.java) (Beer Controller), [`src/main/java/guru/springframework/spring7restmvc/controller/CustomerController.java`](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/controller/CustomerController.java) (Customer Controller), [`src/main/java/guru/springframework/spring7restmvc/repositories/BeerRepository.java`](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/repositories/BeerRepository.java) (Beer Repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["REST API"]
  node_beer_controller["Beer Controller"]
  node_customer_controller["Customer Controller"]
  node_not_found["Not Found Error"]
  node_custom_error["Error Responses"]
end

subgraph group_domain["Domain and Mapping"]
  node_beer_dto["Beer DTO<br/>[BeerDTO.java]"]
  node_customer_dto["Customer DTO<br/>[CustomerDTO.java]"]
  node_beer_entity["Beer Entity<br/>[Beer.java]"]
  node_customer_entity["Customer Entity<br/>[Customer.java]"]
  node_beer_style["Beer Style<br/>[BeerStyle.java]"]
  node_beer_mapper["Beer Mapper<br/>[BeerMapper.java]"]
  node_customer_mapper["Customer Mapper"]
end

subgraph group_services["Service Layer"]
  node_beer_service_api["Beer Service API<br/>[BeerService.java]"]
  node_beer_memory["Beer Memory Service"]
  node_beer_jpa["Beer JPA Service"]
  node_customer_service_api["Customer Service API"]
  node_customer_memory["Customer Memory Service"]
  node_customer_jpa["Customer JPA Service"]
end

subgraph group_persistence["Persistence"]
  node_bootstrap["Bootstrap Data<br/>[BootstrapData.java]"]
  node_beer_repo["Beer Repository"]
  node_customer_repo["Customer Repository"]
  node_database[("Relational Database")]
  node_migrations["Database Migrations"]
end

node_client(("API Client"))

node_client -->|"sends requests"| node_beer_controller
node_client -->|"sends requests"| node_customer_controller
node_beer_controller -->|"calls"| node_beer_service_api
node_customer_controller -->|"calls"| node_customer_service_api
node_beer_controller -->|"throws"| node_not_found
node_customer_controller -->|"throws"| node_not_found
node_beer_controller -->|"accepts and returns"| node_beer_dto
node_customer_controller -->|"accepts and returns"| node_customer_dto
node_beer_memory -->|"implements"| node_beer_service_api
node_beer_jpa -->|"implements"| node_beer_service_api
node_customer_memory -->|"implements"| node_customer_service_api
node_customer_jpa -->|"implements"| node_customer_service_api
node_beer_memory -->|"stores in memory"| node_beer_dto
node_beer_jpa -->|"maps through"| node_beer_mapper
node_beer_jpa -->|"uses"| node_beer_repo
node_customer_jpa -->|"maps through"| node_customer_mapper
node_customer_jpa -->|"uses"| node_customer_repo
node_beer_mapper -->|"maps"| node_beer_entity
node_beer_mapper -->|"maps"| node_beer_dto
node_customer_mapper -->|"maps"| node_customer_entity
node_customer_mapper -->|"maps"| node_customer_dto
node_beer_repo -->|"persists"| node_beer_entity
node_customer_repo -->|"persists"| node_customer_entity
node_beer_entity -->|"uses"| node_beer_style
node_beer_dto -->|"uses"| node_beer_style
node_bootstrap -->|"seeds"| node_beer_repo
node_bootstrap -->|"seeds"| node_customer_repo
node_bootstrap -->|"creates"| node_beer_entity
node_bootstrap -->|"creates"| node_customer_entity
node_beer_repo -.->|"reads and writes"| node_database
node_customer_repo -.->|"reads and writes"| node_database
node_migrations -.->|"defines schema"| node_database

click node_beer_controller "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/controller/BeerController.java"
click node_customer_controller "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/controller/CustomerController.java"
click node_not_found "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/controller/NotFoundException.java"
click node_custom_error "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/controller/CustomErrorController.java"
click node_beer_dto "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/model/BeerDTO.java"
click node_customer_dto "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/model/CustomerDTO.java"
click node_beer_entity "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/entities/Beer.java"
click node_customer_entity "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/entities/Customer.java"
click node_beer_style "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/model/BeerStyle.java"
click node_beer_mapper "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/mappers/BeerMapper.java"
click node_customer_mapper "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/mappers/CustomerMapper.java"
click node_beer_service_api "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/services/BeerService.java"
click node_beer_memory "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/services/BeerServiceImpl.java"
click node_beer_jpa "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/services/BeerServiceJPA.java"
click node_customer_service_api "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/services/CustomerService.java"
click node_customer_memory "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/services/CustomerServiceImpl.java"
click node_customer_jpa "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/services/CustomerServiceJPA.java"
click node_bootstrap "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/bootstrap/BootstrapData.java"
click node_beer_repo "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/repositories/BeerRepository.java"
click node_customer_repo "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/repositories/CustomerRepository.java"
click node_migrations "https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/resources/db.migration/V1__init-postgresql-database.sql"

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_beer_controller,node_customer_controller,node_not_found,node_custom_error,node_client toneBlue
class node_beer_dto,node_customer_dto,node_beer_entity,node_customer_entity,node_beer_style,node_beer_mapper,node_customer_mapper toneAmber
class node_beer_service_api,node_beer_memory,node_beer_jpa,node_customer_service_api,node_customer_memory,node_customer_jpa toneMint
class node_bootstrap,node_beer_repo,node_customer_repo,node_database,node_migrations toneRose
```

## Components

### REST API

- [Beer Controller](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/controller/BeerController.java): `src/main/java/guru/springframework/spring7restmvc/controller/BeerController.java`
- [Customer Controller](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/controller/CustomerController.java): `src/main/java/guru/springframework/spring7restmvc/controller/CustomerController.java`
- [Not Found Error](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/controller/NotFoundException.java): `src/main/java/guru/springframework/spring7restmvc/controller/NotFoundException.java`
- [Error Responses](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/controller/CustomErrorController.java): `src/main/java/guru/springframework/spring7restmvc/controller/CustomErrorController.java`

### Domain and Mapping

- [Beer DTO](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/model/BeerDTO.java): `src/main/java/guru/springframework/spring7restmvc/model/BeerDTO.java`
- [Customer DTO](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/model/CustomerDTO.java): `src/main/java/guru/springframework/spring7restmvc/model/CustomerDTO.java`
- [Beer Entity](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/entities/Beer.java): `src/main/java/guru/springframework/spring7restmvc/entities/Beer.java`
- [Customer Entity](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/entities/Customer.java): `src/main/java/guru/springframework/spring7restmvc/entities/Customer.java`
- [Beer Style](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/model/BeerStyle.java): `src/main/java/guru/springframework/spring7restmvc/model/BeerStyle.java`
- [Beer Mapper](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/mappers/BeerMapper.java): `src/main/java/guru/springframework/spring7restmvc/mappers/BeerMapper.java`
- [Customer Mapper](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/mappers/CustomerMapper.java): `src/main/java/guru/springframework/spring7restmvc/mappers/CustomerMapper.java`

### Service Layer

- [Beer Service API](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/services/BeerService.java): `src/main/java/guru/springframework/spring7restmvc/services/BeerService.java`
- [Beer Memory Service](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/services/BeerServiceImpl.java): `src/main/java/guru/springframework/spring7restmvc/services/BeerServiceImpl.java`
- [Beer JPA Service](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/services/BeerServiceJPA.java): `src/main/java/guru/springframework/spring7restmvc/services/BeerServiceJPA.java`
- [Customer Service API](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/services/CustomerService.java): `src/main/java/guru/springframework/spring7restmvc/services/CustomerService.java`
- [Customer Memory Service](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/services/CustomerServiceImpl.java): `src/main/java/guru/springframework/spring7restmvc/services/CustomerServiceImpl.java`
- [Customer JPA Service](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/services/CustomerServiceJPA.java): `src/main/java/guru/springframework/spring7restmvc/services/CustomerServiceJPA.java`

### Persistence

- [Bootstrap Data](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/bootstrap/BootstrapData.java): `src/main/java/guru/springframework/spring7restmvc/bootstrap/BootstrapData.java`
- [Beer Repository](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/repositories/BeerRepository.java): `src/main/java/guru/springframework/spring7restmvc/repositories/BeerRepository.java`
- [Customer Repository](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/java/guru/springframework/spring7restmvc/repositories/CustomerRepository.java): `src/main/java/guru/springframework/spring7restmvc/repositories/CustomerRepository.java`
- **Relational Database**
- [Database Migrations](https://github.com/tranbaotri2412-star/spring-7-rest-mvc-68-jpa-validation-error-msg/blob/master/src/main/resources/db.migration/V1__init-postgresql-database.sql): `src/main/resources/db.migration/V1__init-postgresql-database.sql`

### Other components

- **API Client**

## Connections

- API Client → Beer Controller: sends requests (evidence: `src/main/java/guru/springframework/spring7restmvc/controller/BeerController.java`)
- API Client → Customer Controller: sends requests (evidence: `src/main/java/guru/springframework/spring7restmvc/controller/CustomerController.java`)
- Beer Controller → Beer Service API: calls (evidence: `src/main/java/guru/springframework/spring7restmvc/controller/BeerController.java`)
- Customer Controller → Customer Service API: calls (evidence: `src/main/java/guru/springframework/spring7restmvc/controller/CustomerController.java`)
- Beer Controller → Not Found Error: throws (evidence: `src/main/java/guru/springframework/spring7restmvc/controller/BeerController.java`)
- Customer Controller → Not Found Error: throws (evidence: `src/main/java/guru/springframework/spring7restmvc/controller/CustomerController.java`)
- Beer Controller → Beer DTO: accepts and returns (evidence: `src/main/java/guru/springframework/spring7restmvc/controller/BeerController.java`)
- Customer Controller → Customer DTO: accepts and returns (evidence: `src/main/java/guru/springframework/spring7restmvc/controller/CustomerController.java`)
- Beer Memory Service → Beer Service API: implements (evidence: `src/main/java/guru/springframework/spring7restmvc/services/BeerServiceImpl.java`)
- Beer JPA Service → Beer Service API: implements (evidence: `src/main/java/guru/springframework/spring7restmvc/services/BeerServiceJPA.java`)
- Customer Memory Service → Customer Service API: implements (evidence: `src/main/java/guru/springframework/spring7restmvc/services/CustomerServiceImpl.java`)
- Customer JPA Service → Customer Service API: implements (evidence: `src/main/java/guru/springframework/spring7restmvc/services/CustomerServiceJPA.java`)
- Beer Memory Service → Beer DTO: stores in memory (evidence: `src/main/java/guru/springframework/spring7restmvc/services/BeerServiceImpl.java`)
- Beer JPA Service → Beer Mapper: maps through (evidence: `src/main/java/guru/springframework/spring7restmvc/services/BeerServiceJPA.java`)
- Beer JPA Service → Beer Repository: uses (evidence: `src/main/java/guru/springframework/spring7restmvc/services/BeerServiceJPA.java`)
- Customer JPA Service → Customer Mapper: maps through (evidence: `src/main/java/guru/springframework/spring7restmvc/services/CustomerServiceJPA.java`)
- Customer JPA Service → Customer Repository: uses (evidence: `src/main/java/guru/springframework/spring7restmvc/services/CustomerServiceJPA.java`)
- Beer Mapper → Beer Entity: maps (evidence: `src/main/java/guru/springframework/spring7restmvc/mappers/BeerMapper.java`)
- Beer Mapper → Beer DTO: maps (evidence: `src/main/java/guru/springframework/spring7restmvc/mappers/BeerMapper.java`)
- Customer Mapper → Customer Entity: maps (evidence: `src/main/java/guru/springframework/spring7restmvc/mappers/CustomerMapper.java`)
- Customer Mapper → Customer DTO: maps (evidence: `src/main/java/guru/springframework/spring7restmvc/mappers/CustomerMapper.java`)
- Beer Repository → Beer Entity: persists (evidence: `src/main/java/guru/springframework/spring7restmvc/repositories/BeerRepository.java`)
- Customer Repository → Customer Entity: persists (evidence: `src/main/java/guru/springframework/spring7restmvc/repositories/CustomerRepository.java`)
- Beer Entity → Beer Style: uses (evidence: `src/main/java/guru/springframework/spring7restmvc/entities/Beer.java`)
- Beer DTO → Beer Style: uses (evidence: `src/main/java/guru/springframework/spring7restmvc/model/BeerDTO.java`)
- Bootstrap Data → Beer Repository: seeds (evidence: `src/main/java/guru/springframework/spring7restmvc/bootstrap/BootstrapData.java`)
- Bootstrap Data → Customer Repository: seeds (evidence: `src/main/java/guru/springframework/spring7restmvc/bootstrap/BootstrapData.java`)
- Bootstrap Data → Beer Entity: creates (evidence: `src/main/java/guru/springframework/spring7restmvc/bootstrap/BootstrapData.java`)
- Bootstrap Data → Customer Entity: creates (evidence: `src/main/java/guru/springframework/spring7restmvc/bootstrap/BootstrapData.java`)
- Beer Repository → Relational Database: reads and writes
- Customer Repository → Relational Database: reads and writes
- Database Migrations → Relational Database: defines schema
