3.0 KiB
3.0 KiB
AGENTS.md
Backend service of the gorodar project (group ru.gorodar, version 0.0.1-SNAPSHOT).
Implements the API described in docs/system-analysis.md (public catalog / user visits / admin, in Russian).
Stack
- Java 25 (Gradle toolchain; auto-downloaded if not installed locally)
- Spring Boot 4.1.1, Gradle 9.6.0 wrapper
- Spring Web MVC, Data JPA, Liquibase, OAuth2 resource server security, Validation, Actuator
- PostgreSQL (runtime driver), AWS SDK v2 S3 (MinIO-compatible, via
gorodar.s3.*config) - springdoc-openapi (Swagger UI), Lombok
Commands
./gradlew build # full build incl. tests
./gradlew test # tests only (JUnit 5 via useJUnitPlatform)
./gradlew bootRun # run the application
On Windows, gradlew.bat is equivalent (it is git-ignored but present locally).
Conventions and gotchas
- Spring Boot 4 starter names:
spring-boot-starter-webmvc,spring-boot-starter-security-oauth2-resource-server, and matching*-teststarters. Do not "fix" them to Boot 3 names (spring-boot-starter-web,spring-boot-starter-oauth2-resource-server) — those do not exist in Boot 4. Auth is resource-server only (JWT from Keycloak, clientgorodar); there is no oauth2-client. - Lombok: declared as
compileOnly+annotationProcessor(plus test variants). Keep this pattern when adding modules; plainimplementationbreaks annotation processing. - MapStruct (entity↔DTO mappers in
ru.gorodar.mapper,componentModel = "spring",unmappedTargetPolicy = ERROR):mapstructis animplementationdep,mapstruct-processorandlombok-mapstruct-bindingareannotationProcessorentries — keep all three together, order matters for Lombok interop. - Criteria queries use the generated JPA metamodel:
hibernate-jpamodelgenruns as an annotation processor and generatesX_classes next to entities; Specifications (ru.gorodar.dao.spec) must reference attributes viaEntity_.field, never string paths likeroot.get("name"). - Liquibase: schema changes go through Liquibase changelogs under
src/main/resources(defaultdb/changelog), not ad-hoc DDL. - Timestamps are UTC everywhere: DB columns are plain
timestamp(notimestamptz), entities useLocalDateTime, the JVM default timezone is forced to UTC inmain()— keep it that way when touching date/time code. - Query/multipart params are kebab-case (
parent-id,area-id,sort-order); JSON body fields stay camelCase. - Entities declare explicit column names: every field carries
@Column(name = "…")(or@JoinColumn(name = "…")) — no reliance on the implicit naming strategy. - No
settings.gradle: single-project build; the project name falls back to the directory name (back). Add one only if the build becomes multi-module. - Line endings (
.gitattributes):gradlewis forced to LF,*.batto CRLF,*.jaris binary. Preserve this when adding scripts. .idea/andgradlew.batare git-ignored; do not commit them.