/api global prefix, and a single Socket.IO gateway handles real-time kitchen display.
Layered architecture
Each feature module follows a strict three-layer pattern:Modules
auth
JWT-based authentication. Issues and validates bearer tokens used by every protected route.
usuarios
User management. Creates, updates, and soft-deletes staff accounts with roles (e.g.
cajero).caja
Cash register shifts (
caja_turno). Tracks opening/closing amounts, bill denominations, and cash-out records.productos
Non-dish retail products with stock tracking and unit pricing.
ingredientes
Ingredient inventory with quantity and minimum-stock thresholds.
platos
Menu dishes and their ingredient compositions (
plato_ingredientes).transacciones
Sales transactions, order status, kitchen state, line items, extras, and payments. Also owns the
CocinaGateway WebSocket.dashboard
Aggregated reporting queries used by the front-end dashboard.
Module responsibilities
| Module | Controller routes | Key tables |
|---|---|---|
auth | POST /api/auth/login | usuarios |
usuarios | GET/POST/PUT/DELETE /api/usuarios | usuarios |
caja | GET/POST/PATCH /api/caja | caja_turno, gastos_caja |
productos | GET/POST/PATCH/DELETE /api/productos | productos |
ingredientes | GET/POST/PATCH/DELETE /api/ingredientes | ingredientes |
platos | GET/POST/PATCH/DELETE /api/platos | platos, plato_ingredientes |
transacciones | GET/POST/PATCH/DELETE /api/transacciones | transacciones, detalle_items, detalle_item_extras, pagos |
dashboard | GET /api/dashboard/* | all tables (read-only) |
NestJS module structure
The rootAppModule imports all feature modules and the shared infrastructure modules:
src/app.module.ts
Global configuration
Global prefix
All routes are prefixed with/api:
CORS
The server accepts requests from the following origins:src/main.ts
Global validation pipe
Every incoming request body is validated and transformed before it reaches a controller:Date formatter interceptor
All API responses pass through the globalDateFormatterInterceptor (src/common/interceptors/date-formatter.interceptor.ts). It recursively walks every response object and formats any date/timestamp field into the HH:mm - dd/MM/yyyy pattern using the America/La_Paz timezone.
The timezone is also set at process level so that Node.js date operations default to Bolivia time: