# elpocho304/api_rest-poncho_digital architecture

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

- Interactive diagram: https://gitdiagram.com/elpocho304/api_rest-poncho_digital
- Repository: https://github.com/elpocho304/api_rest-poncho_digital

## Overview

Poncho Digital is a REST API for public catalog browsing and administrator-managed artisan registration and fair layout, plus artisan-owned product management. Requests enter through Express route modules, which dispatch to controllers and services; Prisma provides persistence. Authentication checks current account state and role on protected routes. The README documents the registration-approval and stand-assignment workflows; some service implementations were not sampled, so those internal links are omitted where call evidence is unavailable.

Main entry points: [`src/app.js`](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/app.js) (Express app), [`src/config/prisma.js`](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/config/prisma.js) (PostgreSQL via Prisma), [`src/middlewares/autenticacion.js`](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/middlewares/autenticacion.js) (Token and role checks), [`src/routes/productos.routes.js`](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/productos.routes.js) (Product routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry and routing"]
  node_app["Express app<br/>[app.js]"]
  node_artisan_routes["Artisan routes"]
  node_product_routes["Product routes"]
  node_venue_routes["Venue routes"]
  node_sector_routes["Sector routes<br/>[sectores.routes.js]"]
  node_stand_routes["Stand routes<br/>[stands.routes.js]"]
  node_auth_routes["Authentication routes"]
  node_request_routes["Registration request routes"]
  node_assignment_routes["Assignment routes"]
  node_user_routes["User administration routes<br/>[usuarios.routes.js]"]
  node_validators["Request validation"]
  node_schemas["API schemas<br/>[esquemas.js]"]
end

subgraph group_identity["Identity and registration"]
  node_auth_middleware["Token and role checks<br/>[autenticacion.js]"]
  node_auth_service["Login and registration"]
  node_token_service["JWT tokens<br/>[tokens.service.js]"]
  node_request_service["Registration decisions"]
end

subgraph group_catalog["Catalog and venue"]
  node_artisans["Artisan profiles"]
  node_products["Product catalog"]
  node_pavilions["Pavilions"]
  node_sectors["Sectors"]
  node_stands["Stands<br/>[stands.services.js]"]
end

subgraph group_operations["Administration and assignment"]
  node_assignments["Stand assignments"]
  node_users["Account administration"]
  node_db[("PostgreSQL via Prisma<br/>[prisma.js]")]
end

node_client(("API clients"))
node_admin(("Administrator"))
node_artisan(("Artisan"))

node_client -->|"sends requests"| node_app
node_app -->|"mounts routes"| node_artisan_routes
node_app -->|"mounts routes"| node_product_routes
node_app -->|"mounts routes"| node_venue_routes
node_app -->|"mounts routes"| node_sector_routes
node_app -->|"mounts routes"| node_stand_routes
node_app -->|"mounts routes"| node_auth_routes
node_app -->|"mounts routes"| node_request_routes
node_app -->|"mounts routes"| node_assignment_routes
node_app -->|"mounts routes"| node_user_routes
node_artisan_routes -->|"dispatches profile actions"| node_artisans
node_product_routes -->|"dispatches product actions"| node_products
node_venue_routes -->|"dispatches pavilion actions"| node_pavilions
node_sector_routes -->|"dispatches sector actions"| node_sectors
node_stand_routes -->|"dispatches stand actions"| node_stands
node_auth_routes -->|"dispatches authentication"| node_auth_service
node_request_routes -->|"dispatches decisions"| node_request_service
node_assignment_routes -->|"dispatches assignments"| node_assignments
node_user_routes -->|"dispatches account actions"| node_users
node_auth_routes -->|"validates login"| node_auth_middleware
node_product_routes -->|"checks artisan role"| node_auth_middleware
node_request_routes -->|"requires admin"| node_auth_middleware
node_assignment_routes -->|"requires admin"| node_auth_middleware
node_auth_middleware -->|"verifies token"| node_token_service
node_auth_middleware -->|"rechecks account"| node_db
node_products -->|"reads and writes"| node_db
node_artisans -->|"reads and writes"| node_db
node_pavilions -->|"reads and writes"| node_db
node_stands -->|"reads and writes"| node_db
node_assignments -->|"updates assignments"| node_db
node_request_service -->|"persists decisions"| node_db
node_client -.->|"documents API"| node_schemas
node_admin -->|"resolves applications"| node_request_routes
node_admin -->|"assigns stands"| node_assignment_routes
node_artisan -->|"registers and logs in"| node_auth_routes
node_artisan -->|"manages own products"| node_product_routes
node_admin -->|"manages accounts"| node_user_routes

click node_app "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/app.js"
click node_artisan_routes "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/artesanos.routes.js"
click node_product_routes "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/productos.routes.js"
click node_venue_routes "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/pabellones.routes.js"
click node_sector_routes "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/sectores.routes.js"
click node_stand_routes "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/stands.routes.js"
click node_auth_routes "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/autenticacion.routes.js"
click node_request_routes "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/solicitudRegistro.routes.js"
click node_assignment_routes "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/asignacionesStand.routes.js"
click node_user_routes "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/usuarios.routes.js"
click node_auth_middleware "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/middlewares/autenticacion.js"
click node_auth_service "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/autenticacion.services.js"
click node_token_service "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/tokens.service.js"
click node_request_service "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/solicitudRegistro.services.js"
click node_artisans "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/artesanos.services.js"
click node_products "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/productos.services.js"
click node_pavilions "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/pabellones.services.js"
click node_sectors "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/sectores.services.js"
click node_stands "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/stands.services.js"
click node_assignments "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/asignacionesStand.services.js"
click node_users "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/usuarios.services.js"
click node_validators "https://github.com/elpocho304/api_rest-poncho_digital/tree/main/src/validators"
click node_schemas "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/documentacion/esquemas.js"
click node_db "https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/config/prisma.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_app,node_artisan_routes,node_product_routes,node_venue_routes,node_sector_routes,node_stand_routes,node_auth_routes,node_request_routes,node_assignment_routes,node_user_routes,node_validators,node_schemas,node_client toneBlue
class node_auth_middleware,node_auth_service,node_token_service,node_request_service toneAmber
class node_artisans,node_products,node_pavilions,node_sectors,node_stands toneMint
class node_assignments,node_users,node_db toneRose
class node_admin,node_artisan toneIndigo
```

## Components

### API entry and routing

- [Express app](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/app.js): `src/app.js`
- [Artisan routes](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/artesanos.routes.js): `src/routes/artesanos.routes.js`
- [Product routes](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/productos.routes.js): `src/routes/productos.routes.js`
- [Venue routes](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/pabellones.routes.js): `src/routes/pabellones.routes.js`
- [Sector routes](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/sectores.routes.js): `src/routes/sectores.routes.js`
- [Stand routes](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/stands.routes.js): `src/routes/stands.routes.js`
- [Authentication routes](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/autenticacion.routes.js): `src/routes/autenticacion.routes.js`
- [Registration request routes](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/solicitudRegistro.routes.js): `src/routes/solicitudRegistro.routes.js`
- [Assignment routes](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/asignacionesStand.routes.js): `src/routes/asignacionesStand.routes.js`
- [User administration routes](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/routes/usuarios.routes.js): `src/routes/usuarios.routes.js`
- [Request validation](https://github.com/elpocho304/api_rest-poncho_digital/tree/main/src/validators): `src/validators`
- [API schemas](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/documentacion/esquemas.js): `src/documentacion/esquemas.js`

### Identity and registration

- [Token and role checks](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/middlewares/autenticacion.js): `src/middlewares/autenticacion.js`
- [Login and registration](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/autenticacion.services.js): `src/services/autenticacion.services.js`
- [JWT tokens](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/tokens.service.js): `src/services/tokens.service.js`
- [Registration decisions](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/solicitudRegistro.services.js): `src/services/solicitudRegistro.services.js`

### Catalog and venue

- [Artisan profiles](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/artesanos.services.js): `src/services/artesanos.services.js`
- [Product catalog](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/productos.services.js): `src/services/productos.services.js`
- [Pavilions](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/pabellones.services.js): `src/services/pabellones.services.js`
- [Sectors](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/sectores.services.js): `src/services/sectores.services.js`
- [Stands](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/stands.services.js): `src/services/stands.services.js`

### Administration and assignment

- [Stand assignments](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/asignacionesStand.services.js): `src/services/asignacionesStand.services.js`
- [Account administration](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/services/usuarios.services.js): `src/services/usuarios.services.js`
- [PostgreSQL via Prisma](https://github.com/elpocho304/api_rest-poncho_digital/blob/main/src/config/prisma.js): `src/config/prisma.js`

### Other components

- **API clients**
- **Administrator**
- **Artisan**

## Connections

- API clients → Express app: sends requests (evidence: `src/app.js`)
- Express app → Artisan routes: mounts routes (evidence: `src/app.js`)
- Express app → Product routes: mounts routes (evidence: `src/app.js`)
- Express app → Venue routes: mounts routes (evidence: `src/app.js`)
- Express app → Sector routes: mounts routes (evidence: `src/app.js`)
- Express app → Stand routes: mounts routes (evidence: `src/app.js`)
- Express app → Authentication routes: mounts routes (evidence: `src/app.js`)
- Express app → Registration request routes: mounts routes (evidence: `src/app.js`)
- Express app → Assignment routes: mounts routes (evidence: `src/app.js`)
- Express app → User administration routes: mounts routes (evidence: `src/app.js`)
- Artisan routes → Artisan profiles: dispatches profile actions
- Product routes → Product catalog: dispatches product actions
- Venue routes → Pavilions: dispatches pavilion actions
- Sector routes → Sectors: dispatches sector actions (evidence: `src/routes/sectores.routes.js`)
- Stand routes → Stands: dispatches stand actions
- Authentication routes → Login and registration: dispatches authentication (evidence: `src/routes/autenticacion.routes.js`)
- Registration request routes → Registration decisions: dispatches decisions
- Assignment routes → Stand assignments: dispatches assignments
- User administration routes → Account administration: dispatches account actions
- Authentication routes → Token and role checks: validates login (evidence: `src/routes/autenticacion.routes.js`)
- Product routes → Token and role checks: checks artisan role (evidence: `src/routes/productos.routes.js`)
- Registration request routes → Token and role checks: requires admin (evidence: `src/routes/solicitudRegistro.routes.js`)
- Assignment routes → Token and role checks: requires admin (evidence: `src/routes/asignacionesStand.routes.js`)
- Token and role checks → JWT tokens: verifies token (evidence: `src/middlewares/autenticacion.js`)
- Token and role checks → PostgreSQL via Prisma: rechecks account (evidence: `src/middlewares/autenticacion.js`)
- Product catalog → PostgreSQL via Prisma: reads and writes (evidence: `src/services/productos.services.js`)
- Artisan profiles → PostgreSQL via Prisma: reads and writes (evidence: `src/services/artesanos.services.js`)
- Pavilions → PostgreSQL via Prisma: reads and writes (evidence: `src/services/pabellones.services.js`)
- Stands → PostgreSQL via Prisma: reads and writes (evidence: `src/services/stands.services.js`)
- Stand assignments → PostgreSQL via Prisma: updates assignments (evidence: `src/services/asignacionesStand.services.js`)
- Registration decisions → PostgreSQL via Prisma: persists decisions (evidence: `src/services/solicitudRegistro.services.js`)
- API clients → API schemas: documents API
- Administrator → Registration request routes: resolves applications
- Administrator → Assignment routes: assigns stands
- Artisan → Authentication routes: registers and logs in
- Artisan → Product routes: manages own products
- Administrator → User administration routes: manages accounts
