How arunadhithyagowthaman/springboot-rest-crud-learning works
Project type and purpose (from README + minimal tree)
This is a Spring Boot REST API learning project focused on:
• RESTful CRUD endpoints
• Layered architecture: Controller → Service → Repository
• Spring Data JPA persistence
• Database: H2 (dev) and/or MySQL
• Global exception handling via @ControllerAdvice
• Custom runtime exceptions
• Validation logic explicitly in the service layer
• Manual testing via Postman (i.e., an API client)
Spring Boot Application (single deployable)
• Controllers (REST layer)
• Services (business logic + validation)
• Repositories (data access abstraction via Spring Data JPA)
• Global Exception Handler (@ControllerAdvice)
• (Optional but typical) DTO mapping / response models
Database
• H2 (in-memory or file) for local/dev
• MySQL for external persistence
Key cross-cutting concerns to make explicit
• Dependency Injection (constructor injection)
• Exception flow (custom runtime exceptions → controller advice → error response)
• Validation in Service layer (call out that validation is not only annotations at controller boundary)
Purpose: show external actors and the deployed application + DB.
Nodes
• Postman / API Consumer
• Spring Boot REST API (single container)
• H2 or MySQL DB
• Client → API: HTTP requests (GET/POST/PUT/DELETE)
• API → DB: JDBC/JPA persistence operations
Purpose: show internal layering and dependencies.
• Controller layer (REST endpoints)
• Service layer (business rules + validation)
• Repository layer (Spring Data JPA interfaces)
• Entity model (JPA entities)
• GlobalExceptionHandler (@ControllerAdvice)
• CustomExceptions (domain-specific runtime exceptions)
Dependency direction (important)
• Controllers depend on Services
• Services depend on Repositories
• Repositories depend on JPA/EntityManager (implicit) and map Entities
• ExceptionHandler depends on Exceptions (and is invoked by Spring MVC on throw)
• Controller → Service: “DTO → domain call” / “invoke use-case”
• Service → Repository: “CRUD + queries”
• Service → (throws) CustomException → ControllerAdvice: “mapped to error response”
• Repository → DB: “JPA/Hibernate SQL”
Purpose: make exception handling and validation concrete.
Happy path sequence
Controller returns HTTP response (JSON)
Failure path sequence
Error response returned (status code + error body)
• Client → Controller: HTTP (JSON)
• Controller → Service: method calls (use-case invocation)
• Service → Repository: data access calls
• Repository → DB: persistence
• Service → Custom Exceptions: throws
• Spring MVC runtime → ControllerAdvice: exception interception
• ControllerAdvice → Client: consistent error payload + HTTP status
That constructor injection implies:
• Controller has Service as a constructor dependency
• Service has Repository as a constructor dependency
What “very detailed” means for this project (without overthinking)
• REST Controllers
• Service layer (validation lives here)
• Repository layer (Spring Data JPA)
• JPA Entities
• Exception handling:
• Custom exceptions
• Global handler (@ControllerAdvice)
• Configuration (optional but common): “DB config: H2/MySQL” (even if not shown in tree)
• Left: Postman
• Center: Spring Boot app split into Controller/Service/Repository + ControllerAdvice
• Right: DB (H2/MySQL)
• Two flows: “Happy path” and “Error path”