How brandonbrandon-alt/optiplant-prueba-tecnica works
1. Top-level shape
- This is a full-stack inventory ERP with a Next.js frontend and a Spring Boot backend.
- The backend is the architectural center: a modular monolith organized by business capability, using hexagonal architecture inside each module.
2. Frontend boundary
- frontend/ is a Next.js App Router application with route groups for auth and dashboard flows.
- Pages are split by business area: login, dashboard, alerts, analytics, branches, catalog, inventory, purchases, sales, returns, transfers, and users.
- UI logic is concentrated in reusable components and modals under src/components, while API access is centralized in src/api.
- The frontend is primarily a thin presentation layer over the backend API; it does not appear to own business rules.
3. Backend application boundary
- backend/ is a single Spring Boot application (InventarioApplication) exposing REST endpoints and handling security, persistence, and domain logic.
- Each business module follows the same structure:
- application/port/in for use cases
- application/service for orchestration
- application/port/out for repositories or external dependencies
- domain for models and exceptions
- infrastructure/adapter/in/web for controllers and request/response DTOs
- infrastructure/adapter/out/persistence for JPA entities and repository implementations
4. Main business modules
- The backend is split into these domains: auth, branch, catalog, inventory, purchase, sale, transfer, alert, analytics, and pricelist.
- This separation is important for the diagram: each module is independently shaped, but all live in the same runtime and database.
- The modules are not just technical layers; they represent actual business subsystems of the ERP.
5. Core transactional flows
- Sales create sale records and reduce local inventory; returns create return requests and can restore stock.
- Purchases create purchase orders and, on reception, update inventory and cost-related data.
- Transfers manage inter-branch stock movement with a state machine-like lifecycle: request, prepare, dispatch, receive, and follow-up on exceptions.
- Inventory is the operational ledger underneath these flows, storing movements and local stock state.
- These flows are the main write paths and are the most important arrows in an architecture diagram.
6. Inventory as the shared backbone
- Inventory has its own domain entities for local stock and movement history.
- It also defines domain events such as stock drops/restorations, which likely drive alerting and operational feedback.
- Several other modules depend on inventory behavior indirectly:
- sales consume stock
- purchases replenish stock
- transfers reserve/move stock between branches
- This makes inventory the central consistency boundary of the system.
7. Alerts and event-driven behavior
- The alert module contains a web controller plus an event listener for stock alerts.
- This suggests a mixed model: alerts are stored and retrieved like normal data, but at least some are created from inventory-related events rather than only from direct API calls.
- In the diagram, alerts should be shown as a consumer of inventory signal/events, not only as an isolated CRUD feature.
8. Authentication and authorization
- auth contains login, users, roles, JWT support, and role-based access control.
- The shared security package includes a JWT authentication filter, a JWT service, and Spring Security configuration.
- The frontend login page interacts with auth endpoints, and the resulting token is then used to secure the rest of the API.
- Roles listed in the README (ADMIN, MANAGER, OPERATOR, CASHIER) are central to access boundaries across the system.
9. Catalog, branches, and pricing as reference data
- catalog manages products, suppliers, and units of measure, including product-supplier and product-unit relationships.
- branch manages store/warehouse locations.
- pricelist provides price list and product price structures used by sales and POS screens.
- These modules are mostly supporting/master-data subsystems, but they feed nearly every transaction flow.
10. Analytics as a read-only aggregation layer
- analytics is separate from the transactional modules and exposes dashboard-oriented models like summary KPIs, sales trends, top-selling products, branch performance, valuation, and replenishment insights.
- Its shape implies read-optimized queries or projections over persisted transactional data.
- In the diagram, analytics should be treated as a read side rather than a transaction source.
11. Persistence and storage
- Persistence is implemented with Spring Data JPA/Hibernate behind repository ports.
- Each module has its own JPA entities and repository adapters, but they all target the same relational database.
- Database schema is managed through Flyway migrations in src/main/resources/db/migration, with additional backup migration history preserved under @backup_migrations.
- The architecture is therefore a single DB, multi-module application, not a microservice landscape.
12. Shared infrastructure
- shared/infrastructure/web contains cross-cutting HTTP concerns like the global exception handler and error response model.
- shared/infrastructure/config includes OpenAPI setup.
- This indicates a central platform layer for consistent API behavior across modules.
13. Runtime/deployment shape
- The repo includes Dockerfiles for both backend and frontend, plus a top-level docker-compose.yml.
- That points to a containerized local deployment with at least three meaningful runtime boundaries: frontend, backend, and database.
- The README also references pgAdmin, which is part of the operational/developer environment rather than the domain architecture.
14. Testing structure
- Tests are organized by the same module boundaries as production code, with controller tests, service tests, and some persistence mapper tests.
- This reinforces that the codebase is intended to be diagrammed as a set of cohesive bounded modules, not as a flat CRUD app.
15. How to draw the system
- A good architecture diagram would show:
- Users/browser → Next.js frontend
- Frontend → Spring Boot REST API
- API controllers/security → application services/use cases
- services → domain models and ports
- ports → JPA persistence adapters → PostgreSQL
- inventory events → alerts
- transactional modules → analytics/read models
- The strongest structural idea is: one frontend, one backend monolith, many business modules, one shared relational database, with inventory at the center of operational flows.
Main entry points: InventarioApplication.java InventarioApp · inventory Inventory · app Next.js App · docker-compose.yml Docker Compose
Components 20
Frontend
Next.js App Router presentation layer
- Next.js App · App Router UI with auth and dashboard flows
frontend/app - UI Components · Reusable page widgets, modals, and layout components
frontend/src/components - API Client · Centralized HTTP access and auth helpers
frontend/src/api
Backend
Spring Boot modular monolith
- InventarioApp · Single backend runtime entrypoint
backend/src/main/java/co/com/zenvory/inventario/InventarioApplication.java - Auth · Login, users, roles, and access control
backend/src/main/java/co/com/zenvory/inventario/auth - Catalog · Products, suppliers, and units of measure
backend/src/main/java/co/com/zenvory/inventario/catalog - Branches · Branch and warehouse reference data
backend/src/main/java/co/com/zenvory/inventario/branch - Inventory · Local stock, movements, and stock events
backend/src/main/java/co/com/zenvory/inventario/inventory - Purchases · Purchase orders and receiving flow
backend/src/main/java/co/com/zenvory/inventario/purchase - Sales · Sales and return request flow
backend/src/main/java/co/com/zenvory/inventario/sale - Transfers · Inter-branch stock transfer lifecycle
backend/src/main/java/co/com/zenvory/inventario/transfer - Price Lists · Price lists and product price structures
backend/src/main/java/co/com/zenvory/inventario/pricelist - Alerts · Stock alerts and resolutions
backend/src/main/java/co/com/zenvory/inventario/alert - Analytics · Dashboard KPIs and operational aggregates
backend/src/main/java/co/com/zenvory/inventario/analytics - JPA Persistence · Module-specific JPA entities and repository adapters
Shared infra
Cross-cutting backend platform concerns
- Security · JWT filter, token service, and Spring Security config
backend/src/main/java/co/com/zenvory/inventario/shared/infrastructure/security - Flyway Migrations · Versioned database migrations and backup history
backend/src/main/resources/db/migration
Runtime
Containerized deployment boundaries
- Users · Human operators using the ERP in a browser
- PostgreSQL · Single shared relational datastore
- Docker Compose · Containerized local runtime for frontend, backend, and database
docker-compose.yml
Connections 29
- Users → Next.js App: use UI · Users interact with the ERP through the browser
- Next.js App → API Client: call API · Pages and components use the centralized HTTP client
- Next.js App → UI Components: compose UI · Route pages are built from reusable components
- Next.js App → InventarioApp: REST requests · Frontend screens consume backend endpoints
- InventarioApp → Security: protects · Requests pass through JWT authentication and authorization
- InventarioApp → Auth: hosts · Authentication and user management module
- InventarioApp → Catalog: hosts · Catalog master-data module
- InventarioApp → Branches: hosts · Branch reference-data module
- InventarioApp → Inventory: hosts · Inventory backbone module
- InventarioApp → Purchases: hosts · Purchase lifecycle module
- InventarioApp → Sales: hosts · Sales and returns module
- InventarioApp → Transfers: hosts · Transfer workflow module
- InventarioApp → Price Lists: hosts · Pricing module
- InventarioApp → Alerts: hosts · Alerting module
- InventarioApp → Analytics: hosts · Read-side analytics module
- Auth → JPA Persistence: stores · Users and roles are persisted through JPA adapters
- Catalog → JPA Persistence: stores · Products, suppliers, and units are persisted through JPA adapters
- Branches → JPA Persistence: stores · Branches are persisted through JPA adapters
- Inventory → JPA Persistence: stores · Inventory state and movement history are persisted through JPA adapters
- Purchases → Inventory: replenishes · Receiving updates inventory and cost-related data
- Sales → Inventory: consumes · Sales reduce stock and returns can restore it
- Transfers → Inventory: moves stock · Transfers reserve, dispatch, and receive inventory between branches
- Inventory → Alerts: emits events · Stock drops and restorations trigger alerting behavior
- Analytics → JPA Persistence: reads data · Analytics queries persisted transactional data
- JPA Persistence → PostgreSQL: writes · All modules target the same relational database
- Flyway Migrations → PostgreSQL: migrates · Schema is managed by versioned migrations
- Docker Compose → Next.js App: runs · Frontend is containerized for local deployment
- Docker Compose → InventarioApp: runs · Backend is containerized for local deployment
- Docker Compose → PostgreSQL: runs · Database is part of the composed runtime