How daparamo/homecenter-prueba-tecnica--etq-lpn works
Purpose and Entry Points
ETQ is a warehouse label-printing submodule. It resolves an LPN to its source document, applies document and inventory rules, produces simulated ZPL output, and records every outcome for traceability. Primary API bootstrap and routing are backend/src/index.ts and backend/src/routes/print.routes.ts. The operator-facing SPA starts at frontend/src/main.tsx and composes the UI in frontend/src/App.tsx.
Deployment Topology and Gateway
The system runs as separate frontend and backend containers orchestrated by docker-compose.yml. The frontend is served through Nginx and acts as the API gateway: api-gateway/nginx.conf proxies browser /api/v1/... calls to the backend while exposing the UI on port 8888. Backend Swagger is configured in backend/src/docs/swagger.ts; containers are defined by frontend/Dockerfile and backend/Dockerfile.
Backend HTTP Boundary
backend/src/controllers/print.controller.ts is the REST boundary for label-print requests and audit-history retrieval. Routes in backend/src/routes/print.routes.ts map HTTP input to controller operations. The controller should remain responsible for request/response translation and status codes, while domain orchestration stays in services.
Print Processing and Rules Engine
backend/src/services/print.service.ts is the core application service. Its processing flow is: accept LPN/zone/request metadata; find the associated label/order; reject unknown LPNs; reject disallowed document states (ANULADA, DEVUELTA); verify requested products are supplied and sufficiently stocked for the target zone; classify a successful repeat as REIMPRESION; generate and return ZPL; audit either success or rejection. Source data boundaries are local JSON mock stores: backend/src/data/tableOrders.json and backend/src/data/inventory.json.
Audit and Reprint Semantics
backend/src/services/audit.service.ts owns audit read/write operations and prior-success detection. It persists each attempt—successful and rejected—to backend/src/data/audit.json, allowing the print service to convert subsequent successful requests for the same LPN into reprints and preserve an optional reason. History retrieval is exposed through the same controller/API surface rather than direct frontend file access.
Frontend Interaction Flow
The React SPA collects print input, calls the gateway-backed API, and renders loading, success/error, ZPL, and reprint state. frontend/src/components/PrintForm.tsx is the request interaction boundary; frontend/src/components/ResultCard.tsx presents processing output. frontend/src/components/HistoryTable.tsx fetches/displays the audit stream, making backend audit persistence the source of truth.
Material Boundaries and Dependencies
Runtime stack: Node.js/Express backend, React/Vite frontend, Nginx proxy, Docker Compose orchestration, and filesystem JSON persistence. There is no indicated production database, message broker, or physical printer integration: ZPL is returned as API data and the printer is simulated. The externally consumable API contract is also represented by HomeCenter-ETQ-API.postman_collection.json.
Main entry points: App.tsx App Composition · print.service.ts Print Service · nginx.conf Nginx API Gateway · index.ts Express Bootstrap
Components 19
Deployment
- Docker Compose · Runs the frontend and backend containers.
docker-compose.yml - Nginx API Gateway · Serves the SPA and proxies /api/v1 requests.
api-gateway/nginx.conf - Frontend Container
frontend/Dockerfile - Backend Container
backend/Dockerfile
Frontend SPA
- React Entry
frontend/src/main.tsx - App Composition
frontend/src/App.tsx - Print Form · Collects LPN, zone, and request metadata.
frontend/src/components/PrintForm.tsx - Result Card · Displays outcome, ZPL, errors, and reprint state.
frontend/src/components/ResultCard.tsx - History Table · Fetches and displays audit history.
frontend/src/components/HistoryTable.tsx
Backend API
- Express Bootstrap
backend/src/index.ts - Print Routes
backend/src/routes/print.routes.ts - Print Controller · Translates print and history HTTP requests.
backend/src/controllers/print.controller.ts - Print Service · Validates documents and inventory, generates simulated ZPL, and audits outcomes.
backend/src/services/print.service.ts - Audit Service · Persists attempts and detects prior successful prints.
backend/src/services/audit.service.ts - Orders Store
backend/src/data/tableOrders.json - Inventory Store
backend/src/data/inventory.json - Audit Store · Stores successful and rejected print attempts.
backend/src/data/audit.json - Swagger Docs
backend/src/docs/swagger.ts
Other components
- Postman Collection
HomeCenter-ETQ-API.postman_collection.json
Connections 20
- Docker Compose → Frontend Container: runs
- Docker Compose → Backend Container: runs
- Frontend Container → Nginx API Gateway: serves via
- Nginx API Gateway → Express Bootstrap: proxies /api/v1
- React Entry → App Composition: mounts
- App Composition → Print Form: composes
- App Composition → Result Card: composes
- App Composition → History Table: composes
- Print Form → Nginx API Gateway: print request
- History Table → Nginx API Gateway: history request
- Express Bootstrap → Print Routes: registers
- Express Bootstrap → Swagger Docs: configures
- Print Routes → Print Controller: maps requests
- Print Controller → Print Service: process print
- Print Controller → Audit Service: retrieve history
- Print Service → Orders Store: resolve LPN and state
- Print Service → Inventory Store: verify zone stock
- Print Service → Audit Service: record outcome and reprint check
- Audit Service → Audit Store: read/write attempts
- Postman Collection → Print Routes: documents API