3.3 KiB
AGENTS.md
Spring Boot 4.1.0 / Java 17 REST backend for an LMS (PostgreSQL). Root package aplp.backend.lms.
Commands
- Build:
./mvnw -DskipTests package - Run:
./mvnw spring-boot:run - All tests:
./mvnw test - Single test:
./mvnw test -Dtest=LmsApplicationTests - Requires JDK 17. No linter, formatter, or checkstyle is configured — don't invent one.
Build gotcha: GitLab Maven registry
aplp.backend:core:1.0-SNAPSHOT is not built here; it resolves from the GitLab package registry (repository id gitlab-maven in pom.xml). A fresh checkout needs a token for server id gitlab-maven in ~/.m2/settings.xml (or the artifact cached in ~/.m2/repository). Credentials are not in the repo.
aplp.backend.core shared types
Not defined in this repo; import them instead of recreating:
BaseEntity—@MappedSuperclassfor every entity:id,createdAt/By,updatedAt/By,deletedAt/By; timestamps set via@PrePersist/@PreUpdate.ApiResponse<T>—ok(data),ok(message, data),error(code, message).PagedResponse<T>—of(content, page, size, totalElements).ErrorCode,DomainException,ResourceNotFoundException,TokenHasher.sha256Hex.
Architecture
Vertical slices per feature under aplp.backend.lms.<feature> (currently course, lesson, section); common/ holds cross-cutting api, config, security. Layers per feature:
api/controller—@RestController, returnsResponseEntity<ApiResponse<...>>application/services,application/dtos(Java records),application/mappers(MapStruct)domain/entities,domain/enums,domain/repositories(plain interfaces)infrastructure/persistence—*RepositoryImplimplements the domain repo and delegates to a Spring Data*JpaRepository
Conventions:
- Entities extend
BaseEntity, use Lombok@Getter/@Setter/@NoArgsConstructor,@Tablesnake_case. - Controllers stay thin; services throw
ResourceNotFoundException;GlobalExceptionHandlermaps exceptions toApiResponse. - Mappers are interfaces annotated
@Mapper(componentModel = "spring"); Lombok/MapStruct annotation processing is already wired inpom.xml. - Add derived queries to
*JpaRepositoryand expose them through the domain repo interface.
Database
- PostgreSQL, Hibernate default schema
lms; datasource hardcoded insrc/main/resources/application.yaml. spring.flyway.enabled: false+spring.jpa.hibernate.ddl-auto: update: Hibernate maintains the schema at runtime. Scripts indb/migration(V{n}__desc.sql) are history only and are NOT applied on startup. A schema change needs both the entity field and a migration; don't assume Flyway runs.- jsonb columns use
@JdbcTypeCode(SqlTypes.JSON)on aStringfield.
Security
SecurityConfigdisables CSRF andpermitAlls every request — endpoints are currently unauthenticated despite OpenAPI declaring abearerAuthJWT scheme (Swagger UI at/swagger-ui).JpaAuditingConfigreads the current user fromSecurityContextHolderand expectsAuthentication.getPrincipal()to be aLonguserId.
Testing
Only LmsApplicationTests (@SpringBootTest contextLoads) exists. There is no src/test/resources or test profile, so tests use the real application.yaml datasource and require access to the remote DB — ./mvnw test fails without it.