# jmlopeze/comercializadora-andina architecture

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

- Interactive diagram: https://gitdiagram.com/jmlopeze/comercializadora-andina
- Repository: https://github.com/jmlopeze/comercializadora-andina

## Overview

Comercializadora Andina is a web system for managing a stationery wholesaler: users sign in, then consult sales indicators, manage products and orders, and view reports or their profile. The React client calls an Express REST API, whose resource routes apply validation and access controls and use MySQL for persistence. The README documents inventory movements, low-stock alerts, order cancellation with stock reintegration, and role-based access. Some route internals were not excerpted, so those capabilities are represented at the documented subsystem level; edges are limited to relationships shown in excerpts, the source index, or README.

Main entry points: [`frontend/src/App.jsx`](https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/App.jsx) (App and routes), [`backend/src/server.js`](https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/server.js) (Express API server), [`frontend/src/api/cliente.js`](https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/api/cliente.js) (Axios API client), [`frontend/src/pages/Dashboard.jsx`](https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/pages/Dashboard.jsx) (Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["App and routes<br/>[App.jsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_products_ui["Product management<br/>[Productos.jsx]"]
  node_orders_ui["Orders workflow<br/>[Pedidos.jsx]"]
  node_reports_ui["Sales reports<br/>[Reportes.jsx]"]
  node_profile_ui["Profile<br/>[Perfil.jsx]"]
  node_login_ui["Login<br/>[Login.jsx]"]
  node_api_client["Axios API client<br/>[cliente.js]"]
  node_order_table["Orders table<br/>[OrdersTable.jsx]"]
  node_sales_chart["Sales chart<br/>[SalesChart.jsx]"]
  node_ui_components["Shared UI<br/>[ui.jsx]"]
  node_formatting["Display formatting<br/>[formato.js]"]
end

subgraph group_identity["Identity and access"]
  node_auth_provider["Session provider<br/>[AuthProvider.jsx]"]
  node_auth_hook["Session hook<br/>[useAuth.js]"]
  node_auth_routes["Authentication and profile<br/>[auth.js]"]
  node_auth_middleware["JWT and role checks<br/>[auth.js]"]
end

subgraph group_commerce["Commerce API"]
  node_server["Express API server<br/>[server.js]"]
  node_products_api["Products API<br/>[productos.js]"]
  node_categories_api["Categories API<br/>[categorias.js]"]
  node_orders_api["Orders API<br/>[pedidos.js]"]
  node_inventory_api["Inventory API<br/>[inventario.js]"]
  node_reports_api["Reports API<br/>[reportes.js]"]
  node_customers_api["Customers API<br/>[clientes.js]"]
end

subgraph group_data["Persistence and shared services"]
  node_validation["Input validation<br/>[validaciones.js]"]
  node_errors["Error handling<br/>[errores.js]"]
  node_mysql_pool["MySQL connection pool<br/>[db.js]"]
  node_mysql[("MySQL database<br/>[schema.sql]")]
end

node_user(("Staff user"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_products_ui
node_app -->|"routes to"| node_orders_ui
node_app -->|"routes to"| node_reports_ui
node_app -->|"routes to"| node_profile_ui
node_app -->|"renders"| node_login_ui
node_app -->|"reads session"| node_auth_hook
node_auth_provider -->|"provides context"| node_auth_hook
node_login_ui -->|"calls"| node_api_client
node_dashboard -->|"calls"| node_api_client
node_products_ui -->|"calls"| node_api_client
node_orders_ui -->|"calls"| node_api_client
node_reports_ui -->|"calls"| node_api_client
node_profile_ui -->|"calls"| node_api_client
node_dashboard -->|"renders"| node_order_table
node_orders_ui -->|"renders"| node_order_table
node_dashboard -->|"renders"| node_sales_chart
node_reports_ui -->|"renders"| node_sales_chart
node_dashboard -->|"uses"| node_ui_components
node_products_ui -->|"uses"| node_ui_components
node_orders_ui -->|"uses"| node_ui_components
node_reports_ui -->|"uses"| node_ui_components
node_profile_ui -->|"uses"| node_ui_components
node_dashboard -->|"formats values"| node_formatting
node_products_ui -->|"formats values"| node_formatting
node_orders_ui -->|"formats values"| node_formatting
node_reports_ui -->|"formats values"| node_formatting
node_profile_ui -->|"formats values"| node_formatting
node_api_client -->|"HTTP JSON"| node_server
node_server -->|"mounts routes"| node_auth_routes
node_server -->|"mounts routes"| node_products_api
node_server -->|"mounts routes"| node_categories_api
node_server -->|"mounts routes"| node_customers_api
node_server -->|"mounts routes"| node_orders_api
node_server -->|"mounts routes"| node_inventory_api
node_server -->|"mounts routes"| node_reports_api
node_auth_routes -->|"queries"| node_mysql_pool
node_auth_routes -->|"protects profile"| node_auth_middleware
node_auth_middleware -->|"raises API errors"| node_errors
node_customers_api -->|"queries"| node_mysql_pool
node_products_api -->|"queries"| node_mysql_pool
node_orders_api -->|"queries"| node_mysql_pool
node_inventory_api -->|"queries"| node_mysql_pool
node_reports_api -->|"queries"| node_mysql_pool
node_categories_api -->|"queries"| node_mysql_pool
node_customers_api -->|"protects writes"| node_auth_middleware
node_orders_api -->|"checks access"| node_auth_middleware

click node_app "https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/App.jsx"
click node_dashboard "https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/pages/Dashboard.jsx"
click node_products_ui "https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/pages/Productos.jsx"
click node_orders_ui "https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/pages/Pedidos.jsx"
click node_reports_ui "https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/pages/Reportes.jsx"
click node_profile_ui "https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/pages/Perfil.jsx"
click node_login_ui "https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/pages/Login.jsx"
click node_api_client "https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/api/cliente.js"
click node_order_table "https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/components/OrdersTable.jsx"
click node_sales_chart "https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/components/SalesChart.jsx"
click node_ui_components "https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/components/ui.jsx"
click node_formatting "https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/utils/formato.js"
click node_auth_provider "https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/context/AuthProvider.jsx"
click node_auth_hook "https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/context/useAuth.js"
click node_auth_routes "https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/routes/auth.js"
click node_auth_middleware "https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/middleware/auth.js"
click node_server "https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/server.js"
click node_products_api "https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/routes/productos.js"
click node_categories_api "https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/routes/categorias.js"
click node_orders_api "https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/routes/pedidos.js"
click node_inventory_api "https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/routes/inventario.js"
click node_reports_api "https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/routes/reportes.js"
click node_customers_api "https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/routes/clientes.js"
click node_validation "https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/utils/validaciones.js"
click node_errors "https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/middleware/errores.js"
click node_mysql_pool "https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/db.js"
click node_mysql "https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/schema.sql"

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_dashboard,node_products_ui,node_orders_ui,node_reports_ui,node_profile_ui,node_login_ui,node_api_client,node_order_table,node_sales_chart,node_ui_components,node_formatting,node_user toneBlue
class node_auth_provider,node_auth_hook,node_auth_routes,node_auth_middleware toneAmber
class node_server,node_products_api,node_categories_api,node_orders_api,node_inventory_api,node_reports_api,node_customers_api toneMint
class node_validation,node_errors,node_mysql_pool,node_mysql toneRose
```

## Components

### Web client

- [App and routes](https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Dashboard](https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Product management](https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/pages/Productos.jsx): `frontend/src/pages/Productos.jsx`
- [Orders workflow](https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/pages/Pedidos.jsx): `frontend/src/pages/Pedidos.jsx`
- [Sales reports](https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/pages/Reportes.jsx): `frontend/src/pages/Reportes.jsx`
- [Profile](https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/pages/Perfil.jsx): `frontend/src/pages/Perfil.jsx`
- [Login](https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Axios API client](https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/api/cliente.js): `frontend/src/api/cliente.js`
- [Orders table](https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/components/OrdersTable.jsx): `frontend/src/components/OrdersTable.jsx`
- [Sales chart](https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/components/SalesChart.jsx): `frontend/src/components/SalesChart.jsx`
- [Shared UI](https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/components/ui.jsx): `frontend/src/components/ui.jsx`
- [Display formatting](https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/utils/formato.js): `frontend/src/utils/formato.js`

### Identity and access

- [Session provider](https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/context/AuthProvider.jsx): `frontend/src/context/AuthProvider.jsx`
- [Session hook](https://github.com/jmlopeze/comercializadora-andina/blob/main/frontend/src/context/useAuth.js): `frontend/src/context/useAuth.js`
- [Authentication and profile](https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/routes/auth.js): `backend/src/routes/auth.js`
- [JWT and role checks](https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/middleware/auth.js): `backend/src/middleware/auth.js`

### Commerce API

- [Express API server](https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/server.js): `backend/src/server.js`
- [Products API](https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/routes/productos.js): `backend/src/routes/productos.js`
- [Categories API](https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/routes/categorias.js): `backend/src/routes/categorias.js`
- [Orders API](https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/routes/pedidos.js): `backend/src/routes/pedidos.js`
- [Inventory API](https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/routes/inventario.js): `backend/src/routes/inventario.js`
- [Reports API](https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/routes/reportes.js): `backend/src/routes/reportes.js`
- [Customers API](https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/routes/clientes.js): `backend/src/routes/clientes.js`

### Persistence and shared services

- [Input validation](https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/utils/validaciones.js): `backend/src/utils/validaciones.js`
- [Error handling](https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/middleware/errores.js): `backend/src/middleware/errores.js`
- [MySQL connection pool](https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/src/db.js): `backend/src/db.js`
- [MySQL database](https://github.com/jmlopeze/comercializadora-andina/blob/main/backend/schema.sql): `backend/schema.sql`

### Other components

- **Staff user**

## Connections

- Staff user → App and routes: uses (evidence: `README.md`)
- App and routes → Dashboard: routes to (evidence: `frontend/src/App.jsx`)
- App and routes → Product management: routes to (evidence: `frontend/src/App.jsx`)
- App and routes → Orders workflow: routes to (evidence: `frontend/src/App.jsx`)
- App and routes → Sales reports: routes to (evidence: `frontend/src/App.jsx`)
- App and routes → Profile: routes to (evidence: `frontend/src/App.jsx`)
- App and routes → Login: renders (evidence: `frontend/src/App.jsx`)
- App and routes → Session hook: reads session (evidence: `frontend/src/App.jsx`)
- Session provider → Session hook: provides context (evidence: `frontend/src/context/useAuth.js`)
- Login → Axios API client: calls (evidence: `frontend/src/pages/Login.jsx`)
- Dashboard → Axios API client: calls (evidence: `frontend/src/pages/Dashboard.jsx`)
- Product management → Axios API client: calls (evidence: `frontend/src/pages/Productos.jsx`)
- Orders workflow → Axios API client: calls (evidence: `frontend/src/pages/Pedidos.jsx`)
- Sales reports → Axios API client: calls (evidence: `frontend/src/pages/Reportes.jsx`)
- Profile → Axios API client: calls (evidence: `frontend/src/pages/Perfil.jsx`)
- Dashboard → Orders table: renders (evidence: `frontend/src/pages/Dashboard.jsx`)
- Orders workflow → Orders table: renders (evidence: `frontend/src/pages/Pedidos.jsx`)
- Dashboard → Sales chart: renders (evidence: `frontend/src/pages/Dashboard.jsx`)
- Sales reports → Sales chart: renders (evidence: `frontend/src/pages/Reportes.jsx`)
- Dashboard → Shared UI: uses (evidence: `frontend/src/pages/Dashboard.jsx`)
- Product management → Shared UI: uses (evidence: `frontend/src/pages/Productos.jsx`)
- Orders workflow → Shared UI: uses (evidence: `frontend/src/pages/Pedidos.jsx`)
- Sales reports → Shared UI: uses (evidence: `frontend/src/pages/Reportes.jsx`)
- Profile → Shared UI: uses (evidence: `frontend/src/pages/Perfil.jsx`)
- Dashboard → Display formatting: formats values (evidence: `frontend/src/pages/Dashboard.jsx`)
- Product management → Display formatting: formats values (evidence: `frontend/src/pages/Productos.jsx`)
- Orders workflow → Display formatting: formats values (evidence: `frontend/src/pages/Pedidos.jsx`)
- Sales reports → Display formatting: formats values (evidence: `frontend/src/pages/Reportes.jsx`)
- Profile → Display formatting: formats values (evidence: `frontend/src/pages/Perfil.jsx`)
- Axios API client → Express API server: HTTP JSON (evidence: `README.md`)
- Express API server → Authentication and profile: mounts routes (evidence: `backend/src/server.js`)
- Express API server → Products API: mounts routes (evidence: `backend/src/server.js`)
- Express API server → Categories API: mounts routes (evidence: `backend/src/server.js`)
- Express API server → Customers API: mounts routes (evidence: `backend/src/server.js`)
- Express API server → Orders API: mounts routes (evidence: `backend/src/server.js`)
- Express API server → Inventory API: mounts routes (evidence: `backend/src/server.js`)
- Express API server → Reports API: mounts routes (evidence: `backend/src/server.js`)
- Authentication and profile → MySQL connection pool: queries (evidence: `backend/src/routes/auth.js`)
- Authentication and profile → JWT and role checks: protects profile (evidence: `backend/src/routes/auth.js`)
- JWT and role checks → Error handling: raises API errors (evidence: `backend/src/middleware/auth.js`)
- Customers API → MySQL connection pool: queries (evidence: `backend/src/routes/clientes.js`)
- Products API → MySQL connection pool: queries (evidence: `backend/src/routes/productos.js`)
- Orders API → MySQL connection pool: queries (evidence: `backend/src/routes/pedidos.js`)
- Inventory API → MySQL connection pool: queries (evidence: `backend/src/routes/inventario.js`)
- Reports API → MySQL connection pool: queries (evidence: `backend/src/routes/reportes.js`)
- Categories API → MySQL connection pool: queries (evidence: `backend/src/routes/categorias.js`)
- Customers API → JWT and role checks: protects writes (evidence: `backend/src/routes/clientes.js`)
- Orders API → JWT and role checks: checks access (evidence: `backend/src/routes/pedidos.js`)
