How josephmn/msv-maven-student works
Project type and purpose
• This is a standalone backend REST API built with Java 17, Spring Boot WebFlux, R2DBC (reactive MySQL), and Vault.
• It exposes endpoints to manage Student and Teacher records (CRUD-lite for registration and retrieval).
High-level architecture pattern
• The codebase follows a layered (“hexagonal/onion”) architecture:
• presentation (controllers)
• application (use-case interfaces)
• domain (entities + business-logic implementations)
• infrastructure/adapters (DB adapters, mappers, configuration)
Key components (to include
A. External Actors & Services
• Client (e.g., Postman, Browser)
• Vault (secret management)
• MySQL database (R2DBC driver)
B. API Gateway layer (optional, for future)
C. Presentation Layer
• StudentController
• TeacherController
D. Application Layer (Ports)
• StudentUseCase (interface)
• TeacherUseCase (interface)
E. Domain Layer (Core business logic)
• StudentUseCaseImpl
• TeacherUseCaseImpl
• Entities: StudentEntity, TeacherEntity
F. Domain Ports (Repository Interfaces)
• StudentRepositoryReactive
• TeacherRepositoryReactive
G. Infrastructure Layer (Adapters)
• R2DBC MySQL Adapter (provided by Spring Data R2DBC)
• MapStruct mappers: StudentMapper, TeacherMapper
• Configuration: JacksonConfig, ConstantsConfig
• Exception handling: GlobalExceptionHandler + ErrorResponse
Interactions & data flow
1. Client → HTTP(S) request → Controller
2. Controller → invoke UseCase interface
3. UseCaseImpl (business logic) → validate/transform data → call Repository interface
4. Repository interface → Spring Data R2DBC → MySQL
5. Response bubbles back up: DB → Repository → UseCaseImpl → Controller → Client
6. At startup, application → Vault client reads DB credentials → JacksonConfig/Properties
Architectural patterns & design principles
• Hexagonal (Ports & Adapters): use‐case interfaces decouple business logic from frameworks.
• Reactive programming (Spring WebFlux + R2DBC).
• Separation of concerns: Controllers vs. UseCases vs. Domain vs. Infrastructure.
• Exception translation layer for consistent error responses.
• Externalized configuration & secret management via Vault.
Technologies & frameworks callouts
• Java 17
• Spring Boot 3.x (WebFlux, Data R2DBC)
• MySQL (R2DBC driver)
• Vault (HashiCorp Vault client)
• MapStruct (DTO↔Entity mapping)
• Lombok (boilerplate reduction)
• OpenAPI spec (openapi.yaml)