How rey9530/api_administracion works
Project Type and Purpose
• This is a Node.js + TypeScript monolithic backend service exposing RESTful endpoints for modules such as facturación (invoicing), inventario (inventory), reservas (reservations), usuarios (users), perfil (profiles) and authentication.
• It uses Express (via index.ts), Prisma ORM against a relational database (likely PostgreSQL via Docker Compose), file uploads, JWT auth, and includes a Jest-based test suite.
Main Architectural Components
a. API Server (Express.js + TypeScript)
• index.ts: boots the app, loads middleware, routes, error handlers
• src/routes/*.ts: define HTTP routes per domain (facturación, inventario, etc.)
• src/controllers/*.ts: handle route logic, call helpers or database
• src/middlewares: common concerns (JWT validation, input validation)
• src/helpers: JWT utilities, image upload/update logic
b. Persistence Layer
• Prisma schema (prisma/schema.prisma) & migrations folder
• prisma client invoked within controllers or a data-access layer
• Database container managed via docker-compose.yaml
c. File Storage
• uploads folder for storing user‐uploaded files (images, docs)
• helpers handle file naming/storing
d. Orchestration & DevOps
• docker-compose.yaml: brings up database and any auxiliary services
• .env.template: environment variables
• GitHub Actions workflows (.github/workflows/*.yml) for CI
e. Testing
• Jest config (jest.config.js) and test files (test/prisma.test.ts)
Component Interactions & Data Flows
• Client (frontend or API consumer) → (HTTP/S) → Express Router
• Router → Middleware (e.g., validar-jwt) → Controller
• Controller → Prisma Client → Database (CRUD operations)
• Controller → Helper (e.g., uploads) → File system
• DB migrations & seeding happen via CLI (npx prisma migrate, seed script)
• CI workflow triggers lint/test/build on push or PR
Architectural Patterns & Principles
• Layered structure:
1) Presentation (Routes)
2) Application (Controllers)
3) Domain/Utility (Helpers, Services)
4) Infrastructure (Prisma, File system, Docker, External services)
• Separation of concerns: each domain folder (facturación, inventario, reservas) encapsulates its routes & controllers
• Configuration-as-code: Docker Compose, .env, Prisma migrations
• Modular extensibility: adding a new domain simply involves new route/controller modules