# rodo1302/tpf_rodolfo_samudio architecture

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

- Interactive diagram: https://gitdiagram.com/rodo1302/tpf_rodolfo_samudio
- Repository: https://github.com/rodo1302/tpf_rodolfo_samudio

## Overview

This is an Express product-catalog API with a hard-coded admin login that issues JWTs. Its main workflow routes product requests through controllers and a service/model layer to Firestore; write routes apply JWT verification first. Authentication is a separate login-to-token branch. The excerpts show route registration and component calls; no README is present, so capabilities beyond the sampled routes are not assumed.

Main entry points: [`index.js`](https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/index.js) (Express server), [`src/routers/products.routes.js`](https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/routers/products.routes.js) (Product routes), [`src/models/products.model.js`](https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/models/products.model.js) (Product model), [`src/routers/auth.routes.js`](https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/routers/auth.routes.js) (Auth routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["Express server<br/>[index.js]"]
  node_authroutes["Auth routes<br/>[auth.routes.js]"]
  node_productroutes["Product routes<br/>[products.routes.js]"]
end

subgraph group_auth["Authentication"]
  node_login["Login handler<br/>[auth.controller.js]"]
  node_token["JWT issuer<br/>[token.js]"]
  node_authmw["JWT middleware<br/>[authentication.js]"]
end

subgraph group_catalog["Product catalog"]
  node_productcontroller["Product handlers"]
  node_productservice["Product service"]
  node_productmodel["Product model<br/>[products.model.js]"]
end

subgraph group_data["Persistence"]
  node_firestore[("Firestore")]
  node_firebaseconfig["Firebase setup<br/>[firebase.data.js]"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_server
node_server -->|"mounts /auth"| node_authroutes
node_server -->|"mounts /api"| node_productroutes
node_authroutes -->|"dispatches login"| node_login
node_productroutes -->|"dispatches requests"| node_productcontroller
node_productroutes -->|"guards writes"| node_authmw
node_login -->|"generates token"| node_token
node_productcontroller -->|"calls operations"| node_productservice
node_productservice -->|"delegates operations"| node_productmodel
node_productmodel -->|"reads and writes"| node_firestore
node_productmodel -->|"uses database"| node_firebaseconfig
node_firebaseconfig -->|"initializes client"| node_firestore

click node_server "https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/index.js"
click node_authroutes "https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/routers/auth.routes.js"
click node_productroutes "https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/routers/products.routes.js"
click node_login "https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/controllers/auth.controller.js"
click node_token "https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/data/token.js"
click node_authmw "https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/middleware/authentication.js"
click node_productcontroller "https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/controllers/products.controller.js"
click node_productservice "https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/services/products.service.js"
click node_productmodel "https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/models/products.model.js"
click node_firebaseconfig "https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/data/firebase.data.js"

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_authroutes,node_productroutes,node_client toneBlue
class node_login,node_token,node_authmw toneAmber
class node_productcontroller,node_productservice,node_productmodel toneMint
class node_firestore,node_firebaseconfig toneRose
```

## Components

### HTTP API

- [Express server](https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/index.js): `index.js`
- [Auth routes](https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/routers/auth.routes.js): `src/routers/auth.routes.js`
- [Product routes](https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/routers/products.routes.js): `src/routers/products.routes.js`

### Authentication

- [Login handler](https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/controllers/auth.controller.js): `src/controllers/auth.controller.js`
- [JWT issuer](https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/data/token.js): `src/data/token.js`
- [JWT middleware](https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/middleware/authentication.js): `src/middleware/authentication.js`

### Product catalog

- [Product handlers](https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/controllers/products.controller.js): `src/controllers/products.controller.js`
- [Product service](https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/services/products.service.js): `src/services/products.service.js`
- [Product model](https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/models/products.model.js): `src/models/products.model.js`

### Persistence

- **Firestore**
- [Firebase setup](https://github.com/rodo1302/tpf_rodolfo_samudio/blob/main/src/data/firebase.data.js): `src/data/firebase.data.js`

### Other components

- **API client**

## Connections

- API client → Express server: sends requests (evidence: `index.js`)
- Express server → Auth routes: mounts /auth (evidence: `index.js`)
- Express server → Product routes: mounts /api (evidence: `index.js`)
- Auth routes → Login handler: dispatches login (evidence: `src/routers/auth.routes.js`)
- Product routes → Product handlers: dispatches requests (evidence: `src/routers/products.routes.js`)
- Product routes → JWT middleware: guards writes (evidence: `src/routers/products.routes.js`)
- Login handler → JWT issuer: generates token (evidence: `src/controllers/auth.controller.js`)
- Product handlers → Product service: calls operations (evidence: `src/controllers/products.controller.js`)
- Product service → Product model: delegates operations (evidence: `src/services/products.service.js`)
- Product model → Firestore: reads and writes (evidence: `src/models/products.model.js`)
- Product model → Firebase setup: uses database (evidence: `src/models/products.model.js`)
- Firebase setup → Firestore: initializes client (evidence: `src/data/firebase.data.js`)
