Spring Boot Domain Scaffold
Rule: One class per responsibility. Never put logic in controllers, never map manually in services — always MapStruct.
Before Starting
- Run project-scan to check existing domain structure:
bash ~/.claude/skills/project-scan/scripts/scan.sh - Load
references/conventions.md— structure, naming, and patterns
Steps
Identify database — JPA (SQL) or MongoDB (check
pom.xmlandconfig/)Create files in this order:
- Entity / Document
- Repository interface
- Request + Response DTOs (in
dtos/request/anddtos/response/) - MapStruct Mapper
- Service
- Controller
Naming —
PascalCasefor all classes. DTOs:CreateEntityRequest,GetEntityResponseController — returns
ResponseEntity<ApiResponse<T>>. Constructor injection only. Logic only in services.Service —
@Transactionalon write methods (SQL). ThrowApiExceptionfor controlled errors. Use mapper for all conversions.Test — unit test for service (
EntityServiceTest) mocking the repository with Mockito.