# nardoroman/backend-inteligente architecture

> Architecture diagram of the GitHub repository nardoroman/backend-inteligente, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nardoroman/backend-inteligente
- Repository: https://github.com/nardoroman/backend-inteligente

## Overview

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: [`src/server.ts`](https://github.com/nardoroman/backend-inteligente/blob/main/src/server.ts) (Express server), [`src/controllers/productController.ts`](https://github.com/nardoroman/backend-inteligente/blob/main/src/controllers/productController.ts) (Collection seed endpoint), [`src/models/Product.ts`](https://github.com/nardoroman/backend-inteligente/blob/main/src/models/Product.ts) (Dynamic product model), [`src/routes/productRoutes.ts`](https://github.com/nardoroman/backend-inteligente/blob/main/src/routes/productRoutes.ts) (Product routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API routing"]
  node_server["Express server<br/>[server.ts]"]
  node_product_routes["Product routes<br/>[productRoutes.ts]"]
  node_health["Health endpoint<br/>[server.ts]"]
end

subgraph group_inventory["Inventory operations"]
  node_product_controller["Product controller"]
  node_seed_endpoint["Collection seed endpoint"]
end

subgraph group_persistence["Persistence"]
  node_product_model["Dynamic product model<br/>[Product.ts]"]
  node_mongo[("MongoDB")]
  node_db_connection["DB connection<br/>[db.ts]"]
end

node_student(("Student frontend"))

node_student -->|"sends API requests"| node_server
node_server -->|"mounts routes"| node_product_routes
node_product_routes -->|"dispatches product requests"| node_product_controller
node_product_controller -->|"gets dynamic model"| node_product_model
node_product_model -->|"reads and writes"| node_mongo
node_server -->|"connects at startup"| node_db_connection
node_db_connection -->|"connects"| node_mongo
node_server -->|"serves health check"| node_health
node_server -->|"routes seed requests"| node_seed_endpoint
node_seed_endpoint -->|"deletes and inserts samples"| node_product_model
node_student -->|"requests seed"| node_seed_endpoint

click node_server "https://github.com/nardoroman/backend-inteligente/blob/main/src/server.ts"
click node_product_routes "https://github.com/nardoroman/backend-inteligente/blob/main/src/routes/productRoutes.ts"
click node_product_controller "https://github.com/nardoroman/backend-inteligente/blob/main/src/controllers/productController.ts"
click node_product_model "https://github.com/nardoroman/backend-inteligente/blob/main/src/models/Product.ts"
click node_db_connection "https://github.com/nardoroman/backend-inteligente/blob/main/src/config/db.ts"
click node_health "https://github.com/nardoroman/backend-inteligente/blob/main/src/server.ts"
click node_seed_endpoint "https://github.com/nardoroman/backend-inteligente/blob/main/src/controllers/productController.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_product_routes,node_health,node_student toneBlue
class node_product_controller,node_seed_endpoint toneAmber
class node_product_model,node_mongo,node_db_connection toneMint
```

## Components

### API routing

- [Express server](https://github.com/nardoroman/backend-inteligente/blob/main/src/server.ts): `src/server.ts`
- [Product routes](https://github.com/nardoroman/backend-inteligente/blob/main/src/routes/productRoutes.ts): `src/routes/productRoutes.ts`
- [Health endpoint](https://github.com/nardoroman/backend-inteligente/blob/main/src/server.ts): `src/server.ts`

### Inventory operations

- [Product controller](https://github.com/nardoroman/backend-inteligente/blob/main/src/controllers/productController.ts): `src/controllers/productController.ts`
- [Collection seed endpoint](https://github.com/nardoroman/backend-inteligente/blob/main/src/controllers/productController.ts): `src/controllers/productController.ts`

### Persistence

- [Dynamic product model](https://github.com/nardoroman/backend-inteligente/blob/main/src/models/Product.ts): `src/models/Product.ts`
- **MongoDB**
- [DB connection](https://github.com/nardoroman/backend-inteligente/blob/main/src/config/db.ts): `src/config/db.ts`

### Other components

- **Student frontend**

## Connections

- Student frontend → Express server: sends API requests (evidence: `README.md`)
- Express server → Product routes: mounts routes (evidence: `src/server.ts`)
- Product routes → Product controller: dispatches product requests (evidence: `src/routes/productRoutes.ts`)
- Product controller → Dynamic product model: gets dynamic model (evidence: `src/controllers/productController.ts`)
- Dynamic product model → MongoDB: reads and writes
- Express server → DB connection: connects at startup (evidence: `src/server.ts`)
- DB connection → MongoDB: connects (evidence: `src/config/db.ts`)
- Express server → Health endpoint: serves health check (evidence: `src/server.ts`)
- Express server → Collection seed endpoint: routes seed requests (evidence: `src/server.ts`)
- Collection seed endpoint → Dynamic product model: deletes and inserts samples (evidence: `src/controllers/productController.ts`)
- Student frontend → Collection seed endpoint: requests seed (evidence: `README.md`)
