<One sentence: what this service does.>
Stack
-
Java <21+> (or Kotlin), Spring Boot <3.x>, <Maven Gradle> - Spring Web, Spring Data JPA, PostgreSQL, Flyway
- Tests: JUnit 5, Mockito, Testcontainers
Commands
- Run:
./mvnw spring-boot:run<or./gradlew bootRun> - Tests:
./mvnw test(one:./mvnw test -Dtest=OrderServiceTest#refundsPartially) - Full verify:
./mvnw verify(integration tests need Docker for Testcontainers) - Format:
<./mvnw spotless:apply>
Layout
controller/(web),service/(business logic, transactions),repository/(Spring Data),domain/(entities),dto/(request/response records)- Migrations in
src/main/resources/db/migration(V<n>__<description>.sql)
Rules
- Constructor injection only (no field
@Autowired). - Controllers take and return DTOs (records), never JPA entities.
@Transactionalon service methods, not controllers; keep transactions short and avoid remote calls inside them.- Validate input with Bean Validation (
@Valid,@NotNull…) and handle errors in a@RestControllerAdvicereturning problem details. - Watch for N+1 with lazy associations: use fetch joins or entity graphs where a list endpoint needs relations.
- Schema changes only through new Flyway migrations; never edit an applied migration.
- Configuration through
application.yml+ environment variables; no secrets committed.
Definition of done
./mvnw verifypasses; new endpoints covered by a@WebMvcTestor an integration test.