Imported from luceroraul12/store-back (
AGENTS.md). Install upstream withnpx skills add luceroraul12/store-back. Copyright stays with the author.
AGENTS.md
Spring Boot 2.7.4 / Java 17 single-module Maven project ("scrapping"). REST backend for a distributor product catalog: products are imported from distributor Excel files or scraped from distributor websites; also customers, carts/orders, discounts, stores (client), suppliers, and JWT auth.
Build & test
./mvnwhas no exec bit and no systemmvnis installed — always runbash ./mvnw ....- Tests are stale and fail (expired hardcoded JWT in
JwtUtilServiceTest, NPEs from unset@Autowired/ExternalProductinPdfServiceImplTest/InventorySystemImplTest, andScrappingApplicationTestsneeds a live DB). Builds must usebash ./mvnw clean package -DskipTests(the Dockerfile does the same). Don't assumetestis green. - Focused verification:
bash ./mvnw test -Dtest='PdfServiceImplTest#precioNormal' -DfailIfNoTests=false. - Host JDK is 21; the project targets Java 17 and compiles fine as-is.
Database & migrations
- App requires an already-initialized Postgres:
spring.datasource.url=jdbc:postgresql://localhost:5432/pasionaria(userpostgres, passwordhomito), withspring.jpa.hibernate.ddl-auto=validate. The DB must be present or the app won't start. - Schema lives in
src/main/resources/sql/<version>/(currently1.38) as plain SQL. There is NO automatic migration runner (no Flyway/Liquibase, nospring.sql.init): scripts are applied by hand, bumping the version dir each time. When you change an entity you must also write SQL matching it, or startup validation fails. Next version is1.39. Some filenames contain spaces (e.g.01 - schema.sql). - Local dev DB:
docker compose -f dev.docker-compose.yml up -dexposes6500:5432— the app default is5432, so run with-Dspring.datasource.url=jdbc:postgresql://localhost:6500/pasionaria(or override via envSPRING_DATASOURCE_URL). The fulldocker-compose.ymluses prebuiltfront-parcial/back-parcialimages and its own DB service.
Architecture / conventions
- Everything lives under package
distribuidora.scrapping(controller,services,repositories,entities,dto,security,util/converters). Services areInterface+*ServiceImplpairs; DTO<->entity mapping is hand-written converters inutil/converters. - Field injection (
@Autowired) and Lombok throughout. - Auth is JWT (
security/SpringSecurityConfig): only/customer/**and/login/**are public;/inventory-system/**,/order/**,/lookup/**require theALLauthority; CORS allowshttp://localhost:4200. - Distributors are a pluggable system: each distributor has a
ProductSearcherimplementation registered inUpdaterServiceImpl(Villares & Indias read uploaded Excel viaMultipartFile; La Granja, Facundo, Don Gaspar scrape live sites via jsoup). To add a distributor: new*Entidadinentities/productos/especificos, a service extendingProductSearcherExcelorProductSearcherWeb, an entry inUpdaterServiceImpl, and aDatosDistribuidorarow +LOOKUPvalues. Distributor codes live inconfigs/Constants.java. src/main/resources/static/*.htmland*.xlsare site snapshots / sample import files used as parsing references.
Gotchas
- A private SSH key (
homitowen,homitowen.pub) is accidentally committed at the repo root. Don't commit new secrets or keys. - Active dev branch is
development;mainis the production/stable branch.