# moralesseba/nexo-inventario architecture

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

- Interactive diagram: https://gitdiagram.com/moralesseba/nexo-inventario
- Repository: https://github.com/moralesseba/nexo-inventario

## Overview

NEXO is a containerized inventory REST API for managing store products. The main workflow is a client request entering the Express server, passing through product routes and controller validation/query logic, and reading or changing PostgreSQL product records; low-stock queries support replenishment. The app also exposes health and service metadata endpoints and centralizes 404/error responses. The sampled source establishes runtime wiring; other README-described delivery and infrastructure capabilities are intentionally excluded from this runtime architecture.

Main entry points: [`src/app.js`](https://github.com/moralesseba/nexo-inventario/blob/main/src/app.js) (Express app), [`src/server.js`](https://github.com/moralesseba/nexo-inventario/blob/main/src/server.js) (HTTP listener), [`src/db.js`](https://github.com/moralesseba/nexo-inventario/blob/main/src/db.js) (Postgres pool), [`src/config.js`](https://github.com/moralesseba/nexo-inventario/blob/main/src/config.js) (Runtime config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry"]
  node_server["HTTP listener<br/>[server.js]"]
  node_app["Express app<br/>[app.js]"]
  node_config["Runtime config<br/>[config.js]"]
  node_error_middleware["Error handling<br/>[errorHandler.js]"]
end

subgraph group_inventory["Inventory domain"]
  node_product_routes["Product routes"]
  node_product_controller["Product operations"]
end

subgraph group_persistence["Persistence"]
  node_db_client["Postgres pool<br/>[db.js]"]
  node_postgres[("PostgreSQL")]
end

node_client(("API client"))

node_client -->|"sends HTTP"| node_server
node_server -->|"serves"| node_app
node_server -->|"reads settings"| node_config
node_app -->|"mounts routes"| node_product_routes
node_app -->|"reads version"| node_config
node_app -->|"handles errors"| node_error_middleware
node_product_routes -->|"dispatches requests"| node_product_controller
node_product_controller -->|"queries"| node_db_client
node_db_client -->|"builds connection"| node_config
node_db_client -->|"executes SQL"| node_postgres

click node_server "https://github.com/moralesseba/nexo-inventario/blob/main/src/server.js"
click node_app "https://github.com/moralesseba/nexo-inventario/blob/main/src/app.js"
click node_config "https://github.com/moralesseba/nexo-inventario/blob/main/src/config.js"
click node_product_routes "https://github.com/moralesseba/nexo-inventario/blob/main/src/routes/productos.routes.js"
click node_product_controller "https://github.com/moralesseba/nexo-inventario/blob/main/src/controllers/productos.controller.js"
click node_error_middleware "https://github.com/moralesseba/nexo-inventario/blob/main/src/middleware/errorHandler.js"
click node_db_client "https://github.com/moralesseba/nexo-inventario/blob/main/src/db.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_app,node_config,node_error_middleware,node_client toneBlue
class node_product_routes,node_product_controller toneAmber
class node_db_client,node_postgres toneMint
```

## Components

### API entry

- [HTTP listener](https://github.com/moralesseba/nexo-inventario/blob/main/src/server.js): `src/server.js`
- [Express app](https://github.com/moralesseba/nexo-inventario/blob/main/src/app.js): `src/app.js`
- [Runtime config](https://github.com/moralesseba/nexo-inventario/blob/main/src/config.js): `src/config.js`
- [Error handling](https://github.com/moralesseba/nexo-inventario/blob/main/src/middleware/errorHandler.js): `src/middleware/errorHandler.js`

### Inventory domain

- [Product routes](https://github.com/moralesseba/nexo-inventario/blob/main/src/routes/productos.routes.js): `src/routes/productos.routes.js`
- [Product operations](https://github.com/moralesseba/nexo-inventario/blob/main/src/controllers/productos.controller.js): `src/controllers/productos.controller.js`

### Persistence

- [Postgres pool](https://github.com/moralesseba/nexo-inventario/blob/main/src/db.js): `src/db.js`
- **PostgreSQL**

### Other components

- **API client**

## Connections

- API client → HTTP listener: sends HTTP (evidence: `README.md`)
- HTTP listener → Express app: serves (evidence: `src/server.js`)
- HTTP listener → Runtime config: reads settings (evidence: `src/server.js`)
- Express app → Product routes: mounts routes (evidence: `src/app.js`)
- Express app → Runtime config: reads version (evidence: `src/app.js`)
- Express app → Error handling: handles errors (evidence: `src/app.js`)
- Product routes → Product operations: dispatches requests (evidence: `src/routes/productos.routes.js`)
- Product operations → Postgres pool: queries (evidence: `src/controllers/productos.controller.js`)
- Postgres pool → Runtime config: builds connection (evidence: `src/db.js`)
- Postgres pool → PostgreSQL: executes SQL (evidence: `README.md`)
