# sebastian-acha/chatarreria-app architecture

> Architecture diagram of the GitHub repository sebastian-acha/chatarreria-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sebastian-acha/chatarreria-app
- Repository: https://github.com/sebastian-acha/chatarreria-app

## Overview

This is a scrap-metal purchasing and price-management application: staff sign in, record purchases, and review transaction history and daily reports; administrators also manage metals, branches, users, settings, and published prices. The React dashboard calls an Express API, whose controllers use PostgreSQL. A separate WordPress price plugin is present, but the sampled files do not show its connection to the API, so that relationship is left unverified. The README is empty; the map uses the source index and excerpts, and omits uncertain wiring for unsampled features.

Main entry points: [`frontend/src/api/axios.js`](https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/api/axios.js) (API client), [`frontend/src/components/Dashboard.jsx`](https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/Dashboard.jsx) (Dashboard), [`frontend/src/App.jsx`](https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/App.jsx) (App routing), [`backend/index.js`](https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/index.js) (API server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["App routing<br/>[App.jsx]"]
  node_login["Sign in<br/>[Login.jsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_purchase_ui["New purchase<br/>[NuevaCompra.jsx]"]
  node_history_ui["Transaction history"]
  node_report_ui["Daily report<br/>[ReporteDiario.jsx]"]
  node_metals_ui["Metal management<br/>[GestionMetales.jsx]"]
  node_branches_ui["Branch management"]
  node_users_ui["User management"]
  node_config_ui["Configuration<br/>[Configuracion.jsx]"]
  node_webprices_ui["Web prices<br/>[PreciosWeb.jsx]"]
  node_api_client["API client<br/>[axios.js]"]
  node_config_context["Settings context"]
end

subgraph group_api["API and access"]
  node_server["API server<br/>[index.js]"]
  node_auth_routes["Auth routes<br/>[authRoutes.js]"]
  node_transaction_routes["Transaction routes"]
  node_price_routes["Web price routes<br/>[precioWebRoutes.js]"]
  node_auth_controller["Authentication<br/>[authController.js]"]
  node_auth_middleware["Token validation<br/>[authMiddleware.js]"]
  node_admin_middleware["Admin authorization<br/>[adminMiddleware.js]"]
  node_database[("PostgreSQL<br/>[db.js]")]
end

subgraph group_operations["Purchasing and reporting"]
  node_transaction_controller["Transactions and reports"]
end

subgraph group_management["Business administration"]
  node_price_controller["Published prices"]
  node_business_controllers["Business data controllers"]
end

node_staff(("Staff"))
node_wordpress["WordPress price plugin<br/>[metal-prices.php]"]

node_staff -->|"opens"| node_app
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_dashboard
node_dashboard -->|"renders"| node_purchase_ui
node_dashboard -->|"renders"| node_history_ui
node_dashboard -->|"renders"| node_report_ui
node_dashboard -->|"renders"| node_metals_ui
node_dashboard -->|"renders"| node_branches_ui
node_dashboard -->|"renders"| node_users_ui
node_dashboard -->|"renders"| node_config_ui
node_dashboard -->|"renders"| node_webprices_ui
node_app -->|"provides settings"| node_config_context
node_login -->|"calls"| node_api_client
node_purchase_ui -->|"calls"| node_api_client
node_history_ui -->|"calls"| node_api_client
node_report_ui -.->|"calls"| node_api_client
node_metals_ui -->|"calls"| node_api_client
node_config_ui -->|"calls"| node_api_client
node_branches_ui -.->|"calls"| node_api_client
node_users_ui -.->|"calls"| node_api_client
node_webprices_ui -.->|"calls"| node_api_client
node_config_context -->|"fetches settings"| node_api_client
node_api_client -.->|"sends API requests"| node_server
node_server -->|"mounts"| node_auth_routes
node_server -->|"mounts"| node_transaction_routes
node_server -->|"mounts"| node_price_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_transaction_routes -->|"validates token"| node_auth_middleware
node_transaction_routes -->|"dispatches"| node_transaction_controller
node_price_routes -->|"guards admin routes"| node_auth_middleware
node_price_routes -->|"guards admin routes"| node_admin_middleware
node_price_routes -->|"dispatches"| node_price_controller
node_auth_controller -->|"queries"| node_database
node_transaction_controller -->|"queries and writes"| node_database
node_price_controller -->|"queries and writes"| node_database
node_business_controllers -.->|"uses"| node_database
node_wordpress -.->|"may consume prices"| node_price_controller

click node_app "https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/App.jsx"
click node_login "https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/Login.jsx"
click node_dashboard "https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/Dashboard.jsx"
click node_purchase_ui "https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/NuevaCompra.jsx"
click node_history_ui "https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/HistorialTransacciones.jsx"
click node_report_ui "https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/ReporteDiario.jsx"
click node_metals_ui "https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/GestionMetales.jsx"
click node_branches_ui "https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/GestionSucursales.jsx"
click node_users_ui "https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/GestionUsuarios.jsx"
click node_config_ui "https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/Configuracion.jsx"
click node_webprices_ui "https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/PreciosWeb.jsx"
click node_api_client "https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/api/axios.js"
click node_config_context "https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/context/ConfiguracionContext.jsx"
click node_server "https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/index.js"
click node_auth_routes "https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/routes/authRoutes.js"
click node_transaction_routes "https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/routes/transaccionRoutes.js"
click node_price_routes "https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/routes/precioWebRoutes.js"
click node_auth_controller "https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/controllers/authController.js"
click node_auth_middleware "https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/middleware/authMiddleware.js"
click node_admin_middleware "https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/middleware/adminMiddleware.js"
click node_transaction_controller "https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/controllers/transaccionController.js"
click node_price_controller "https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/controllers/precioWebController.js"
click node_business_controllers "https://github.com/sebastian-acha/chatarreria-app/tree/main/backend/controllers"
click node_database "https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/config/db.js"
click node_wordpress "https://github.com/sebastian-acha/chatarreria-app/blob/main/wp/metal-prices/metal-prices.php"

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_login,node_dashboard,node_purchase_ui,node_history_ui,node_report_ui,node_metals_ui,node_branches_ui,node_users_ui,node_config_ui,node_webprices_ui,node_api_client,node_config_context toneBlue
class node_server,node_auth_routes,node_transaction_routes,node_price_routes,node_auth_controller,node_auth_middleware,node_admin_middleware,node_database toneAmber
class node_transaction_controller toneMint
class node_price_controller,node_business_controllers toneRose
class node_staff toneIndigo
class node_wordpress toneTeal
```

## Components

### Web client

- [App routing](https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Sign in](https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/Login.jsx): `frontend/src/components/Login.jsx`
- [Dashboard](https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/Dashboard.jsx): `frontend/src/components/Dashboard.jsx`
- [New purchase](https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/NuevaCompra.jsx): `frontend/src/components/NuevaCompra.jsx`
- [Transaction history](https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/HistorialTransacciones.jsx): `frontend/src/components/HistorialTransacciones.jsx`
- [Daily report](https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/ReporteDiario.jsx): `frontend/src/components/ReporteDiario.jsx`
- [Metal management](https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/GestionMetales.jsx): `frontend/src/components/GestionMetales.jsx`
- [Branch management](https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/GestionSucursales.jsx): `frontend/src/components/GestionSucursales.jsx`
- [User management](https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/GestionUsuarios.jsx): `frontend/src/components/GestionUsuarios.jsx`
- [Configuration](https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/Configuracion.jsx): `frontend/src/components/Configuracion.jsx`
- [Web prices](https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/components/PreciosWeb.jsx): `frontend/src/components/PreciosWeb.jsx`
- [API client](https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/api/axios.js): `frontend/src/api/axios.js`
- [Settings context](https://github.com/sebastian-acha/chatarreria-app/blob/main/frontend/src/context/ConfiguracionContext.jsx): `frontend/src/context/ConfiguracionContext.jsx`

### API and access

- [API server](https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/index.js): `backend/index.js`
- [Auth routes](https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/routes/authRoutes.js): `backend/routes/authRoutes.js`
- [Transaction routes](https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/routes/transaccionRoutes.js): `backend/routes/transaccionRoutes.js`
- [Web price routes](https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/routes/precioWebRoutes.js): `backend/routes/precioWebRoutes.js`
- [Authentication](https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`
- [Token validation](https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/middleware/authMiddleware.js): `backend/middleware/authMiddleware.js`
- [Admin authorization](https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/middleware/adminMiddleware.js): `backend/middleware/adminMiddleware.js`
- [PostgreSQL](https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/config/db.js): `backend/config/db.js`

### Purchasing and reporting

- [Transactions and reports](https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/controllers/transaccionController.js): `backend/controllers/transaccionController.js`

### Business administration

- [Published prices](https://github.com/sebastian-acha/chatarreria-app/blob/main/backend/controllers/precioWebController.js): `backend/controllers/precioWebController.js`
- [Business data controllers](https://github.com/sebastian-acha/chatarreria-app/tree/main/backend/controllers): `backend/controllers`

### Other components

- **Staff**
- [WordPress price plugin](https://github.com/sebastian-acha/chatarreria-app/blob/main/wp/metal-prices/metal-prices.php): `wp/metal-prices/metal-prices.php`

## Connections

- Staff → App routing: opens (evidence: `frontend/src/App.jsx`)
- App routing → Sign in: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Dashboard → New purchase: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard → Transaction history: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard → Daily report: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard → Metal management: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard → Branch management: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard → User management: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard → Configuration: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard → Web prices: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- App routing → Settings context: provides settings (evidence: `frontend/src/App.jsx`)
- Sign in → API client: calls (evidence: `frontend/src/components/Login.jsx`)
- New purchase → API client: calls (evidence: `frontend/src/components/NuevaCompra.jsx`)
- Transaction history → API client: calls (evidence: `frontend/src/components/HistorialTransacciones.jsx`)
- Daily report → API client: calls
- Metal management → API client: calls (evidence: `frontend/src/components/GestionMetales.jsx`)
- Configuration → API client: calls (evidence: `frontend/src/components/Configuracion.jsx`)
- Branch management → API client: calls
- User management → API client: calls
- Web prices → API client: calls
- Settings context → API client: fetches settings (evidence: `frontend/src/context/ConfiguracionContext.jsx`)
- API client → API server: sends API requests
- API server → Auth routes: mounts (evidence: `backend/index.js`)
- API server → Transaction routes: mounts (evidence: `backend/index.js`)
- API server → Web price routes: mounts (evidence: `backend/index.js`)
- Auth routes → Authentication: dispatches (evidence: `backend/routes/authRoutes.js`)
- Transaction routes → Token validation: validates token (evidence: `backend/routes/transaccionRoutes.js`)
- Transaction routes → Transactions and reports: dispatches (evidence: `backend/routes/transaccionRoutes.js`)
- Web price routes → Token validation: guards admin routes (evidence: `backend/routes/precioWebRoutes.js`)
- Web price routes → Admin authorization: guards admin routes (evidence: `backend/routes/precioWebRoutes.js`)
- Web price routes → Published prices: dispatches (evidence: `backend/routes/precioWebRoutes.js`)
- Authentication → PostgreSQL: queries (evidence: `backend/controllers/authController.js`)
- Transactions and reports → PostgreSQL: queries and writes (evidence: `backend/controllers/transaccionController.js`)
- Published prices → PostgreSQL: queries and writes (evidence: `backend/controllers/precioWebController.js`)
- Business data controllers → PostgreSQL: uses (evidence: `backend/controllers/transaccionController.js`)
- WordPress price plugin → Published prices: may consume prices
