How paul-developer-stack/tarea-4-backend works
This is an Express/MySQL inventory backend. Customers register or log in, then authenticated customers can submit purchases that validate stock and record purchase details transactionally; administrators can manage the product catalog, while product listing is public. The graph separates HTTP routing, authorization, domain controllers, and persistence. The README documents the endpoint and role boundaries; source excerpts show route dispatch and controller database operations. The SQL schema is represented as the store, but its definitions were not sampled.
Main entry points: index.js Express app · db.js MySQL pool · productosRoutes.js Product routes · comprasRoutes.js Purchase routes
Components 13
HTTP API
- Express app
index.js - Auth routes
src/routes/authRoutes.js - Product routes
src/routes/productosRoutes.js - Purchase routes
src/routes/comprasRoutes.js
Identity & Access
- Registration & login
src/controllers/authController.js - Token & role checks
src/middlewares/authMiddleware.js - JWT secret
src/config/auth.js
Inventory Operations
- Product catalog
src/controllers/productosController.js - Purchase processing
src/controllers/comprasController.js
Persistence
- MySQL pool
src/config/db.js - Inventory database
database.sql
Other components
- Customer
- Administrator
Connections 16
- Customer → Express app: calls API
README.md - Administrator → Express app: calls API
README.md - Express app → Auth routes: routes /api/auth
index.js - Express app → Product routes: routes /api/productos
index.js - Express app → Purchase routes: routes /api/compras
index.js - Auth routes → Registration & login: dispatches
src/routes/authRoutes.js - Product routes → Product catalog: dispatches
src/routes/productosRoutes.js - Purchase routes → Purchase processing: dispatches
src/routes/comprasRoutes.js - Product routes → Token & role checks: checks admin role
src/routes/productosRoutes.js - Purchase routes → Token & role checks: checks customer role
src/routes/comprasRoutes.js - Registration & login → JWT secret: signs tokens
src/controllers/authController.js - Token & role checks → JWT secret: verifies tokens
src/middlewares/authMiddleware.js - Registration & login → MySQL pool: queries users
src/controllers/authController.js - Product catalog → MySQL pool: queries products
src/controllers/productosController.js - Purchase processing → MySQL pool: records purchases
src/controllers/comprasController.js - MySQL pool → Inventory database: reads and writes