How nardoroman/backend-inteligente works
This is a multi-tenant inventory API for course students: a frontend sends product requests to a hosted Express backend, which selects a sanitized per-student MongoDB collection and returns JSON. The main flow includes routing, product operations, and automatic first-access seeding; a separate seed endpoint restores sample data. The README also describes health checks and deployment on Render. Connections below follow the excerpts; seed-on-first-access behavior is implemented in the model, although the README describes it as automatic.
Main entry points: server.ts Express server · productController.ts Collection seed endpoint · Product.ts Dynamic product model · productRoutes.ts Product routes
Components 9
API routing
- Express server
src/server.ts - Product routes
src/routes/productRoutes.ts - Health endpoint
src/server.ts
Inventory operations
- Product controller
src/controllers/productController.ts - Collection seed endpoint
src/controllers/productController.ts
Persistence
- Dynamic product model
src/models/Product.ts - MongoDB
- DB connection
src/config/db.ts
Other components
- Student frontend
Connections 11
- Student frontend → Express server: sends API requests
README.md - Express server → Product routes: mounts routes
src/server.ts - Product routes → Product controller: dispatches product requests
src/routes/productRoutes.ts - Product controller → Dynamic product model: gets dynamic model
src/controllers/productController.ts - Dynamic product model → MongoDB: reads and writes
- Express server → DB connection: connects at startup
src/server.ts - DB connection → MongoDB: connects
src/config/db.ts - Express server → Health endpoint: serves health check
src/server.ts - Express server → Collection seed endpoint: routes seed requests
src/server.ts - Collection seed endpoint → Dynamic product model: deletes and inserts samples
src/controllers/productController.ts - Student frontend → Collection seed endpoint: requests seed
README.md