# stredes/app_control_negocio architecture

> Architecture diagram of the GitHub repository stredes/app_control_negocio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stredes/app_control_negocio
- Repository: https://github.com/stredes/app_control_negocio

## Overview

##### Project type and purpose
- This is a standalone, desktop‐based management system (“Control de Tu Negocio”) written in Python.
- It follows an MVC-like layering: a UI layer (views), a controller layer (business logic), a model/data layer (ORM and database), plus auxiliary utilities (exporter, DB checker).

##### File structure
- Top-level scripts:
- main.py – application entry point (initializes UI and orchestrates startup)
- verificar_db.py – checks/initializes the SQLite database
- app/db – database setup module (app/db/database.py) pointing at app/data/negocio.db
- app/models – domain models (Cliente, Producto, Venta, Compra, Inventario, etc.)
- app/controllers – controllers that implement use cases by invoking models and DB routines
- app/ui – view classes for each screen (clientes_view, ventas_view, inventario_view, etc.) plus main_window
- app/utils – helper modules (e.g., exportador.py for data export)
- ControlNegocio.spec – a specification/test file

##### Key insights from README
- “Sistema de gestión integral en Python” implies full coverage of business workflows (sales, purchases, inventory, finances)
- No external services – data is stored locally in an SQLite file

##### Detailed breakdown of components
– UI Layer: main_window.py (launches the app), individual “*_view.py” screens
– Controllers: one controller per domain area (clientes, productos, ventas, etc.)
– Models: one class per table (Cliente, Producto, Compra, Venta, Inventario, Proveedor, Finanzas, etc.)
– DB Access: database.py exposing get_session() or execute_query() methods
– Utilities: exportador.py (generates CSV/Excel), verificar_db.py (handles migrations or initial schema check)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Startup"
        Main["main.py"]:::entry
        VerifDB["verificar_db.py"]:::util
    end
    Main -->|"init DB"| VerifDB
    VerifDB -->|"check/init schema"| DBFile((negocio.db)):::db
    Main -->|"launch UI"| MainWindow["app/ui/main_window.py"]:::ui

    subgraph "Presentation (UI Layer)"
        MainWindow
        subgraph "Views"
            Categorias["app/ui/categorias_view.py"]:::ui
            Clientes["app/ui/clientes_view.py"]:::ui
            Compras["app/ui/compras_view.py"]:::ui
            ConsultaIngresos["app/ui/consulta_ingresos_view.py"]:::ui
            CtasPorCobrar["app/ui/ctas_por_cobrar_view.py"]:::ui
            CtasPorPagar["app/ui/ctas_por_pagar_view.py"]:::ui
            EstadoResultados["app/ui/estado_resultados_view.py"]:::ui
            FinanzasView["app/ui/finanzas_view.py"]:::ui
            Gastos["app/ui/gastos_view.py"]:::ui
            IngresoInventarioView["app/ui/ingreso_inventario_view.py"]:::ui
            InventarioView["app/ui/inventario_view.py"]:::ui
            ProductsView["app/ui/productos_view.py"]:::ui
            ProveedoresView["app/ui/proveedores_view.py"]:::ui
            VentasView["app/ui/ventas_view.py"]:::ui
        end
    end

    MainWindow -->|"open View"| Clientes
    Clientes -->|"user action"| Controllers
    Categorias -->|"user action"| Controllers
    Compras -->|"user action"| Controllers
    ConsultaIngresos -->|"user action"| Controllers
    CtasPorCobrar -->|"user action"| Controllers
    CtasPorPagar -->|"user action"| Controllers
    EstadoResultados -->|"user action"| Controllers
    FinanzasView -->|"user action"| Controllers
    Gastos -->|"user action"| Controllers
    IngresoInventarioView -->|"user action"| Controllers
    InventarioView -->|"user action"| Controllers
    ProductsView -->|"user action"| Controllers
    ProveedoresView -->|"user action"| Controllers
    VentasView -->|"user action"| Controllers

    subgraph "Controller Layer"
        Controllers["app/controllers"]:::controller
    end

    Controllers -->|"invoke CRUD"| CategoriaModel
    Controllers -->|"invoke CRUD"| ClienteModel
    Controllers -->|"invoke CRUD"| CompraModel
    Controllers -->|"invoke CRUD"| FacturaModel
    Controllers -->|"invoke CRUD"| FinanzasModel
    Controllers -->|"invoke CRUD"| IngresoInventarioModel
    Controllers -->|"invoke CRUD"| InventarioModel
    Controllers -->|"invoke CRUD"| MovimientoInventarioModel
    Controllers -->|"invoke CRUD"| ProductoModel
    Controllers -->|"invoke CRUD"| ProveedorModel
    Controllers -->|"invoke CRUD"| VentaModel

    subgraph "Model/Data Layer"
        subgraph "Models"
            CategoriaModel["app/models/categoria.py"]:::model
            ClienteModel["app/models/cliente.py"]:::model
            CompraModel["app/models/compra.py"]:::model
            FacturaModel["app/models/factura.py"]:::model
            FinanzasModel["app/models/finanzas.py"]:::model
            IngresoInventarioModel["app/models/ingreso_inventario.py"]:::model
            InventarioModel["app/models/inventario.py"]:::model
            MovimientoInventarioModel["app/models/movimiento_inventario.py"]:::model
            ProductoModel["app/models/producto.py"]:::model
            ProveedorModel["app/models/proveedor.py"]:::model
            VentaModel["app/models/venta.py"]:::model
        end
        DBAccess["app/db/database.py"]:::dbAccess
    end

    CategoriaModel -->|"SQL via DBAccess"| DBAccess
    ClienteModel -->|"SQL via DBAccess"| DBAccess
    CompraModel -->|"SQL via DBAccess"| DBAccess
    FacturaModel -->|"SQL via DBAccess"| DBAccess
    FinanzasModel -->|"SQL via DBAccess"| DBAccess
    IngresoInventarioModel -->|"SQL via DBAccess"| DBAccess
    InventarioModel -->|"SQL via DBAccess"| DBAccess
    MovimientoInventarioModel -->|"SQL via DBAccess"| DBAccess
    ProductoModel -->|"SQL via DBAccess"| DBAccess
    ProveedorModel -->|"SQL via DBAccess"| DBAccess
    VentaModel -->|"SQL via DBAccess"| DBAccess

    DBAccess -->|"reads/writes"| DBFile

    subgraph "Utilities"
        Export["app/utils/exportador.py"]:::util
    end
    Controllers -->|"export_to_csv()"| Export
    Clientes -->|"trigger export"| Export

    classDef ui fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef controller fill:#d4edda,stroke:#333,stroke-width:1px
    classDef model fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef dbAccess fill:#f8d7da,stroke:#333,stroke-width:1px
    classDef db fill:#d6d8db,stroke:#333,stroke-width:1px,stroke-dasharray:5 5
    classDef util fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef entry fill:#e2e3e5,stroke:#333,stroke-width:1px

    click Main "https://github.com/stredes/app_control_negocio/blob/main/main.py"
    click VerifDB "https://github.com/stredes/app_control_negocio/blob/main/verificar_db.py"
    click MainWindow "https://github.com/stredes/app_control_negocio/blob/main/app/ui/main_window.py"
    click Categorias "https://github.com/stredes/app_control_negocio/blob/main/app/ui/categorias_view.py"
    click Clientes "https://github.com/stredes/app_control_negocio/blob/main/app/ui/clientes_view.py"
    click Compras "https://github.com/stredes/app_control_negocio/blob/main/app/ui/compras_view.py"
    click ConsultaIngresos "https://github.com/stredes/app_control_negocio/blob/main/app/ui/consulta_ingresos_view.py"
    click CtasPorCobrar "https://github.com/stredes/app_control_negocio/blob/main/app/ui/ctas_por_cobrar_view.py"
    click CtasPorPagar "https://github.com/stredes/app_control_negocio/blob/main/app/ui/ctas_por_pagar_view.py"
    click EstadoResultados "https://github.com/stredes/app_control_negocio/blob/main/app/ui/estado_resultados_view.py"
    click FinanzasView "https://github.com/stredes/app_control_negocio/blob/main/app/ui/finanzas_view.py"
    click Gastos "https://github.com/stredes/app_control_negocio/blob/main/app/ui/gastos_view.py"
    click IngresoInventarioView "https://github.com/stredes/app_control_negocio/blob/main/app/ui/ingreso_inventario_view.py"
    click InventarioView "https://github.com/stredes/app_control_negocio/blob/main/app/ui/inventario_view.py"
    click ProductsView "https://github.com/stredes/app_control_negocio/blob/main/app/ui/productos_view.py"
    click ProveedoresView "https://github.com/stredes/app_control_negocio/blob/main/app/ui/proveedores_view.py"
    click VentasView "https://github.com/stredes/app_control_negocio/blob/main/app/ui/ventas_view.py"
    click Controllers "https://github.com/stredes/app_control_negocio/blob/main/app/controllers/__init__.py"
    click CategoriaModel "https://github.com/stredes/app_control_negocio/blob/main/app/models/categoria.py"
    click ClienteModel "https://github.com/stredes/app_control_negocio/blob/main/app/models/cliente.py"
    click CompraModel "https://github.com/stredes/app_control_negocio/blob/main/app/models/compra.py"
    click FacturaModel "https://github.com/stredes/app_control_negocio/blob/main/app/models/factura.py"
    click FinanzasModel "https://github.com/stredes/app_control_negocio/blob/main/app/models/finanzas.py"
    click IngresoInventarioModel "https://github.com/stredes/app_control_negocio/blob/main/app/models/ingreso_inventario.py"
    click InventarioModel "https://github.com/stredes/app_control_negocio/blob/main/app/models/inventario.py"
    click MovimientoInventarioModel "https://github.com/stredes/app_control_negocio/blob/main/app/models/movimiento_inventario.py"
    click ProductoModel "https://github.com/stredes/app_control_negocio/blob/main/app/models/producto.py"
    click ProveedorModel "https://github.com/stredes/app_control_negocio/blob/main/app/models/proveedor.py"
    click VentaModel "https://github.com/stredes/app_control_negocio/blob/main/app/models/venta.py"
    click DBAccess "https://github.com/stredes/app_control_negocio/blob/main/app/db/database.py"
    click DBFile "https://github.com/stredes/app_control_negocio/blob/main/app/data/negocio.db"
    click Export "https://github.com/stredes/app_control_negocio/blob/main/app/utils/exportador.py"
```
