How briansilent/mejorarecibocaducidades works
1. Overall shape
- This is a two-tier system: a Spring Boot 3.5 backend and a React/Vite frontend.
- The backend exposes a REST API under /api; the frontend is a separate client that consumes those endpoints.
- Persistent state lives in PostgreSQL.
2. Backend architecture style
- The backend follows a classic layered design:
Controller → Service → Repository → Database
- Domain logic is concentrated in services, while controllers are thin HTTP adapters.
- Data passed across the API boundary is mostly shaped with DTOs, not entities.
3. Main business domains
- The codebase is organized around several warehouse/logistics domains:
- Producto: master product catalog
- Inventario: stock, alerts, movements, expiry handling
- Recepción: warehouse receiving workflow
- Recepción CEDIS: inbound truck/CEDIS receiving with discrepancies
- RPC: transport cycle control for delivery/return tracking
- Orden Compra: purchase orders
- Surtido / Auditoría / Discrepancias: picking, audit, and mismatch tracking
- Dashboard: aggregated operational KPIs
4. Primary request flow
- A frontend screen calls a controller endpoint.
- The controller delegates to a domain service.
- The service reads/writes through Spring Data repositories.
- Repositories persist JPA entities to PostgreSQL.
- Responses are returned as DTOs or wrapped API responses, keeping entity internals out of the API.
5. Security boundary
- Authentication is JWT-based.
- AuthController, JwtService, CustomUserDetailsService, JwtAuthFilter, and SecurityConfig form the security subsystem.
- The JWT filter sits in the request path before business controllers, so authenticated and role-protected endpoints are enforced centrally.
- Usuario and Role are part of the identity model.
6. Inventory and expiry intelligence
- Inventory is not just stock counting; it includes expiry-aware alerting and movement tracking.
- AlertaService, AlertaCaducidadSheduler, and inventory-related DTOs/repositories indicate automated detection of near-expiry or expired goods.
- Inventory updates likely cascade into movement records via MovimientoInventarioService and MovimientoInventarioRepository.
7. Receiving and discrepancy processing
- The receiving flow is split between regular recepciones and CEDIS-specific recepciones.
- CEDIS receiving appears to validate physical receipt against expected shipment data, generating discrepancies when counts or conditions differ.
- DiscrepanciaService, DiscrepanciaRecepcion, and related controllers/repositories form the audit trail for mismatches.
8. RPC logistics module
- The RPC subsystem is a separate operational track for transport control.
- It has its own controller, service, model, repository, and DTOs, suggesting it is a first-class workflow rather than a small feature.
- The readme’s endpoints imply lifecycle management: delivery, return, pending closures, and summaries.
9. Data model boundaries
- Model contains the JPA entities that map directly to persisted business objects.
- DTO contains API-facing shapes for requests, responses, and summaries.
- mapper classes convert between entity and DTO forms for selected domains such as inventario, producto, and recepcion.
10. Error handling and API consistency
- GlobalExceptionHandler and ErrorResponse provide centralized exception translation.
- This means controllers likely return consistent error payloads instead of exposing stack traces or ad hoc failures.
11. Frontend boundary
- The frontend is a Vite-built React app with pages for login, dashboard, inventory, recepciones, discrepancies, and RPC control.
- It is a client-driven UI that calls the backend API rather than containing core business logic.
- PrivateRoute suggests protected navigation based on authentication state.
12. Infrastructure and deployment
- The backend is containerized with a Dockerfile, and the repo includes docker-compose.yml for local orchestration.
- The readme states the backend container connects to a PostgreSQL instance on the host via host.docker.internal:5432.
- This means the DB is an external runtime dependency rather than another service managed inside the backend codebase.
13. What to show in an architecture diagram
- Show the frontend as a separate client.
- Show JWT auth as a cross-cutting gate in front of all protected backend endpoints.
- Show the backend split into domain modules, each with controller/service/repository layers.
- Show PostgreSQL as the single system of record.
- Show the scheduler as a background actor feeding inventory alert logic.
Main entry points: Controller REST API · Service Services · InventarioController.java Inventario · RecepcionController.java Recepción
Components 23
Frontend
React/Vite client UI
- React app · Vite-built frontend that consumes the API
frontend-vite/src/App.jsx - Login · Authentication entry point
frontend-vite/src/pages/Login.jsx - Dashboard · Operational KPI overview
frontend-vite/src/pages/Dashboard.jsx - Inventario · Inventory browsing and actions
frontend-vite/src/pages/Inventario.jsx - Recepción · Standard receiving workflow
frontend-vite/src/pages/Recepcion.jsx - Recepción CEDIS · Inbound CEDIS receiving workflow
frontend-vite/src/pages/RecepcionCedis.jsx - RPC Control · Transport cycle control UI
frontend-vite/src/pages/RpcControl.jsx
Backend
Spring Boot API and domain services
- REST API · HTTP boundary for all business domains
Backend/src/main/java/com/bodegaaurrera/perecederos_demo/Controller - Auth · JWT authentication and authorization
Backend/src/main/java/com/bodegaaurrera/perecederos_demo/Config/SecurityConfig.java - Producto · Product catalog management
Backend/src/main/java/com/bodegaaurrera/perecederos_demo/Controller/ProductoController.java - Inventario · Stock, movements, alerts, and expiry handling
Backend/src/main/java/com/bodegaaurrera/perecederos_demo/Controller/InventarioController.java - Recepción · Warehouse receiving workflow
Backend/src/main/java/com/bodegaaurrera/perecederos_demo/Controller/RecepcionController.java - Recepción CEDIS · CEDIS receiving and discrepancy capture
Backend/src/main/java/com/bodegaaurrera/perecederos_demo/Controller/RecepcionCedisController.java - RPC · Delivery and return cycle tracking
Backend/src/main/java/com/bodegaaurrera/perecederos_demo/Controller/RpcController.java - Orden/Surtido · Purchase orders, picking, and audit flows
Backend/src/main/java/com/bodegaaurrera/perecederos_demo/Controller/OrdenCompraController.java - Dashboard · Aggregated operational reporting
Backend/src/main/java/com/bodegaaurrera/perecederos_demo/Controller/DashboardController.java - DTOs · Request, response, and summary shapes
Backend/src/main/java/com/bodegaaurrera/perecederos_demo/DTO - Services · Domain rules and orchestration
Backend/src/main/java/com/bodegaaurrera/perecederos_demo/Service - Repositories · Spring Data access layer
Backend/src/main/java/com/bodegaaurrera/perecederos_demo/Repository - Entities · Persisted domain entities
Backend/src/main/java/com/bodegaaurrera/perecederos_demo/Model - Expiry job · Periodic inventory expiry alert generation
Backend/src/main/java/com/bodegaaurrera/perecederos_demo/Sheduler/AlertaCaducidadSheduler.java - Errors · Centralized API error translation
Backend/src/main/java/com/bodegaaurrera/perecederos_demo/exception/GlobalExceptionHandler.java
Infrastructure
Runtime, database, and deployment support
- PostgreSQL · System of record
Backend/src/main/resources/application.properties
Connections 28
- React app → Auth: login · Frontend sends credentials and receives JWT
- React app → REST API: calls · React screens consume backend endpoints
- Login → Auth: auth flow · Login page uses authentication subsystem
- Dashboard → Dashboard: data · Dashboard page reads KPI endpoints
- Inventario → Inventario: data · Inventory page drives stock and alert queries
- Recepción → Recepción: data · Receiving page uses receiving endpoints
- Recepción CEDIS → Recepción CEDIS: data · CEDIS page uses inbound discrepancy workflow
- RPC Control → RPC: data · RPC control page uses transport lifecycle endpoints
- REST API → Auth: secured by · JWT filter and security config guard protected routes
- REST API → Producto: routes · API exposes product management controller
- REST API → Inventario: routes · API exposes inventory controller
- REST API → Recepción: routes · API exposes receiving controller
- REST API → Recepción CEDIS: routes · API exposes CEDIS receiving controller
- REST API → RPC: routes · API exposes RPC controller
- REST API → Orden/Surtido: routes · API exposes order, picking, and audit controllers
- REST API → Dashboard: routes · API exposes dashboard endpoints
- Producto → Services: delegates · Controllers delegate domain work to services
- Inventario → Services: delegates · Inventory controller uses service layer
- Recepción → Services: delegates · Receiving controller uses service layer
- Recepción CEDIS → Services: delegates · CEDIS controller uses service layer
- RPC → Services: delegates · RPC controller uses service layer
- Services → Repositories: reads/writes · Business logic persists through repositories
- Repositories → Entities: maps · Repositories manage JPA entities
- Entities → PostgreSQL: persists · Entities are stored in PostgreSQL
- Services → DTOs: shapes · Services and controllers exchange DTOs
- Expiry job → Inventario: triggers · Background job feeds expiry alert logic
- Expiry job → Services: runs · Scheduled job invokes alert service
- REST API → Errors: handles · Central exception handler standardizes failures