# afroxpress/inventario-reporting architecture

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

- Interactive diagram: https://gitdiagram.com/afroxpress/inventario-reporting
- Repository: https://github.com/afroxpress/inventario-reporting

## Overview

1. **Aplicación de escritorio monolítica, centrada en GUI**
   - El repositorio es una app desktop en Python, no un servicio web.
   - `main.py` actúa como punto de entrada y controlador principal de navegación entre pantallas.
   - La interfaz se construye con `tkinter` + `ttkbootstrap`, lo que sugiere una sola ventana principal con módulos intercambiables.

2. **Flujo principal de arranque y autenticación**
   - La primera barrera es `login.py`, que autentica al usuario antes de mostrar el resto del sistema.
   - El acceso está basado en roles: **Administrador** y **Estándar**.
   - Las credenciales y roles se validan contra la base local de usuarios; las contraseñas están hasheadas con `bcrypt`.

3. **Módulo de inventario como núcleo funcional**
   - `inventario.py` es el módulo central de negocio para consultar, importar, exportar y eliminar productos.
   - `models.py` probablemente encapsula la estructura y operaciones de datos del inventario.
   - El inventario se persiste en `data/inventario.csv`, por lo que el almacenamiento principal es archivo plano, no base relacional.

4. **Importación/exportación con Excel como borde de integración**
   - La app integra archivos `.xlsx` para cargar y exportar inventario y reportes.
   - `pandas` y `openpyxl` son la capa de procesamiento de hojas de cálculo.
   - El flujo típico es: Excel entra al módulo de inventario, se normaliza/combina con el CSV local, y luego se persiste el resultado actualizado.

5. **Dashboard y alertas derivadas del mismo inventario**
   - `dashboard.py` presenta métricas agregadas: total de productos, unidades y stock bajo.
   - `alerts.py` expone una vista filtrada de productos por debajo del umbral configurable.
   - Ambos módulos consumen el mismo dataset de inventario, pero con distintas proyecciones: resumen vs. lista operativa.

6. **Configuración global de la aplicación**
   - `settings.py` permite cambiar parámetros transversales, especialmente el umbral de “stock bajo” y el tema visual.
   - `config.py` gestiona la lectura/escritura de `data/config.json`.
   - La configuración afecta a varios módulos a la vez, sobre todo inventario, dashboard y alertas.

7. **Gestión de usuarios separada del inventario**
   - `usuarios.py` contiene la lógica de persistencia/negocio de usuarios.
   - `user_management.py` es la pantalla administrativa para crear, borrar y cambiar contraseñas.
   - Esta área está restringida por rol y usa la base local `data/usuarios.db` (SQLite).

8. **Auditoría y trazabilidad**
   - `log.py` registra acciones importantes en un historial persistente.
   - `history.py` muestra ese historial dentro de la app.
   - El log funciona como capa transversal: captura eventos como altas/bajas de productos y cambios de contraseña, con usuario y fecha.

9. **Persistencia local en carpeta `data/`**
   - Toda la información vive en el sistema de archivos local bajo `data/`.
   - Hay cuatro artefactos clave: `inventario.csv`, `usuarios.db`, `config.json` y el historial de cambios.
   - Esto significa que la arquitectura depende de almacenamiento local, sin backend remoto ni base de datos centralizada.

10. **Capa de utilidades y organización del código**
   - `utils.py` probablemente concentra rutas, helpers y funciones compartidas entre módulos.
   - La separación entre vistas (`dashboard.py`, `login.py`, `settings.py`, etc.) y lógica de datos (`models.py`, `usuarios.py`, `config.py`, `log.py`) sugiere una arquitectura modular, pero dentro de un solo proceso desktop.
   - No parece haber una capa de red ni servicios externos; las dependencias relevantes son locales y de interfaz.

11. **Seguridad y control de acceso**
   - La seguridad está enfocada en autenticación local, hashing de contraseñas y permisos por rol.
   - El administrador tiene acceso a módulos sensibles: gestión de usuarios, configuración y acciones de mantenimiento.
   - El usuario estándar consume principalmente dashboard, inventario y alertas.

12. **Tecnologías que sí impactan la arquitectura**
   - Python 3.8+, `tkinter`/`ttkbootstrap` para UI, `pandas`/`openpyxl` para Excel, `sqlite3` para usuarios y `bcrypt` para seguridad.
   - `PyInstaller` indica que la distribución prevista es un ejecutable de escritorio empaquetado, reforzando que el sistema está pensado para operar localmente.

Main entry points: [`main.py`](https://github.com/afroxpress/inventario-reporting/blob/main/main.py) (Main shell), [`inventario.py`](https://github.com/afroxpress/inventario-reporting/blob/main/inventario.py) (Inventory), [`utils.py`](https://github.com/afroxpress/inventario-reporting/blob/main/utils.py) (Utilities), [`usuarios.py`](https://github.com/afroxpress/inventario-reporting/blob/main/usuarios.py) (Users)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Desktop app"]
  node_main["Main shell<br/>entrypoint<br/>[main.py]"]
  node_dashboard["Dashboard<br/>summary view<br/>[dashboard.py]"]
  node_alerts["Alerts<br/>filtered view<br/>[alerts.py]"]
  node_utils["Utilities<br/>shared helpers<br/>[utils.py]"]
end

subgraph group_inventory["Inventory core"]
  node_inventario["Inventory<br/>business logic<br/>[inventario.py]"]
  node_models["Models<br/>data model<br/>[models.py]"]
end

subgraph group_identity["Access and admin"]
  node_login["Login<br/>auth view<br/>[login.py]"]
  node_settings["Settings<br/>config view<br/>[settings.py]"]
  node_user_mgmt["User admin<br/>admin view<br/>[user_management.py]"]
  node_usuarios["Users<br/>user store<br/>[usuarios.py]"]
  node_history["History<br/>audit view<br/>[history.py]"]
end

subgraph group_storage["Local storage"]
  node_config["Config<br/>settings store<br/>[config.py]"]
  node_log["Audit log<br/>event log<br/>[log.py]"]
  node_inventory_csv[("Inventory CSV<br/>flat file<br/>[inventario.csv]")]
  node_users_db[("Users DB<br/>sqlite db")]
  node_config_json["Config JSON<br/>json file<br/>[config.json]"]
end

node_main -->|"opens"| node_login
node_main -->|"navigates"| node_dashboard
node_main -->|"routes"| node_inventario
node_main -->|"routes"| node_alerts
node_main -->|"routes"| node_settings
node_main -->|"routes"| node_user_mgmt
node_main -->|"routes"| node_history
node_login -->|"verifies"| node_usuarios
node_dashboard -->|"reads"| node_inventario
node_alerts -->|"filters"| node_inventario
node_inventario -->|"uses"| node_models
node_inventario -->|"persists"| node_inventory_csv
node_inventario -->|"reads"| node_config
node_inventario -->|"records"| node_log
node_settings -->|"edits"| node_config
node_settings -->|"persists"| node_config_json
node_user_mgmt -->|"modifies"| node_usuarios
node_user_mgmt -->|"persists"| node_users_db
node_history -->|"reads"| node_log
node_usuarios -->|"stores"| node_users_db
node_config -->|"stores"| node_config_json
node_main -->|"shares"| node_utils
node_inventario -->|"shares"| node_utils
node_usuarios -->|"shares"| node_utils
node_config -->|"shares"| node_utils
node_log -->|"shares"| node_utils

click node_main "https://github.com/afroxpress/inventario-reporting/blob/main/main.py"
click node_login "https://github.com/afroxpress/inventario-reporting/blob/main/login.py"
click node_dashboard "https://github.com/afroxpress/inventario-reporting/blob/main/dashboard.py"
click node_alerts "https://github.com/afroxpress/inventario-reporting/blob/main/alerts.py"
click node_settings "https://github.com/afroxpress/inventario-reporting/blob/main/settings.py"
click node_user_mgmt "https://github.com/afroxpress/inventario-reporting/blob/main/user_management.py"
click node_inventario "https://github.com/afroxpress/inventario-reporting/blob/main/inventario.py"
click node_models "https://github.com/afroxpress/inventario-reporting/blob/main/models.py"
click node_usuarios "https://github.com/afroxpress/inventario-reporting/blob/main/usuarios.py"
click node_config "https://github.com/afroxpress/inventario-reporting/blob/main/config.py"
click node_log "https://github.com/afroxpress/inventario-reporting/blob/main/log.py"
click node_history "https://github.com/afroxpress/inventario-reporting/blob/main/history.py"
click node_utils "https://github.com/afroxpress/inventario-reporting/blob/main/utils.py"
click node_inventory_csv "https://github.com/afroxpress/inventario-reporting/blob/main/data/inventario.csv"
click node_config_json "https://github.com/afroxpress/inventario-reporting/blob/main/data/config.json"

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_main,node_dashboard,node_alerts,node_utils toneBlue
class node_inventario,node_models toneAmber
class node_login,node_settings,node_user_mgmt,node_usuarios,node_history toneMint
class node_config,node_log,node_inventory_csv,node_users_db,node_config_json toneRose
```

## Components

### Desktop app

GUI entrypoint and user-facing screens.

- [Main shell](https://github.com/afroxpress/inventario-reporting/blob/main/main.py): entrypoint · Application entrypoint and screen navigator. · `main.py`
- [Dashboard](https://github.com/afroxpress/inventario-reporting/blob/main/dashboard.py): summary view · Shows inventory metrics and stock status. · `dashboard.py`
- [Alerts](https://github.com/afroxpress/inventario-reporting/blob/main/alerts.py): filtered view · Lists products below the low-stock threshold. · `alerts.py`
- [Utilities](https://github.com/afroxpress/inventario-reporting/blob/main/utils.py): shared helpers · Common paths and helper functions used across modules. · `utils.py`

### Inventory core

Product data, reporting, and stock alerts.

- [Inventory](https://github.com/afroxpress/inventario-reporting/blob/main/inventario.py): business logic · Core inventory operations: query, import, export, delete. · `inventario.py`
- [Models](https://github.com/afroxpress/inventario-reporting/blob/main/models.py): data model · Inventory data structures and shared operations. · `models.py`

### Access and admin

Authentication, roles, users, and administrative screens.

- [Login](https://github.com/afroxpress/inventario-reporting/blob/main/login.py): auth view · Authenticates users before entering the app. · `login.py`
- [Settings](https://github.com/afroxpress/inventario-reporting/blob/main/settings.py): config view · Lets admins adjust global thresholds and theme. · `settings.py`
- [User admin](https://github.com/afroxpress/inventario-reporting/blob/main/user_management.py): admin view · Creates, deletes, and changes user passwords. · `user_management.py`
- [Users](https://github.com/afroxpress/inventario-reporting/blob/main/usuarios.py): user store · User persistence and role-aware user operations. · `usuarios.py`
- [History](https://github.com/afroxpress/inventario-reporting/blob/main/history.py): audit view · Displays recorded actions inside the app. · `history.py`

### Local storage

File-based persistence used by the app.

- [Config](https://github.com/afroxpress/inventario-reporting/blob/main/config.py): settings store · Reads and writes application configuration. · `config.py`
- [Audit log](https://github.com/afroxpress/inventario-reporting/blob/main/log.py): event log · Records important actions with user and date. · `log.py`
- [Inventory CSV](https://github.com/afroxpress/inventario-reporting/blob/main/data/inventario.csv): flat file · Primary inventory dataset on disk. · `data/inventario.csv`
- **Users DB**: sqlite db · Local SQLite database for credentials and roles.
- [Config JSON](https://github.com/afroxpress/inventario-reporting/blob/main/data/config.json): json file · Persisted application settings. · `data/config.json`

## Connections

- Main shell → Login: opens · Initial gate before the rest of the UI.
- Main shell → Dashboard: navigates · Loads the main operational view after login.
- Main shell → Inventory: routes · Switches into inventory workflows.
- Main shell → Alerts: routes · Opens the low-stock view.
- Main shell → Settings: routes · Opens application settings.
- Main shell → User admin: routes · Opens admin-only user management.
- Main shell → History: routes · Opens audit history.
- Login → Users: verifies · Checks credentials and roles locally.
- Dashboard → Inventory: reads · Consumes inventory data for metrics.
- Alerts → Inventory: filters · Derives low-stock items from inventory.
- Inventory → Models: uses · Relies on shared inventory structures.
- Inventory → Inventory CSV: persists · Loads and updates the main inventory file.
- Inventory → Config: reads · Uses the stock threshold and shared settings.
- Inventory → Audit log: records · Logs product changes and maintenance actions.
- Settings → Config: edits · Updates global application parameters.
- Settings → Config JSON: persists · Stores configuration changes locally.
- User admin → Users: modifies · Creates, removes, and updates users.
- User admin → Users DB: persists · Writes user and role changes to SQLite.
- History → Audit log: reads · Displays the stored audit trail.
- Users → Users DB: stores · Backs user data with SQLite.
- Config → Config JSON: stores · Backs settings with JSON on disk.
- Main shell → Utilities: shares · Uses common helpers and path logic.
- Inventory → Utilities: shares · Uses common helpers and path logic.
- Users → Utilities: shares · Uses common helpers and path logic.
- Config → Utilities: shares · Uses common helpers and path logic.
- Audit log → Utilities: shares · Uses common helpers and path logic.
