# dils02/prueba architecture

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

- Interactive diagram: https://gitdiagram.com/dils02/prueba
- Repository: https://github.com/dils02/prueba

## Overview

##### Project Type and Purpose
- This is a monolithic, full-stack internal web application built with Python and Streamlit.
- Purpose: Automate the monthly calculation of production bonuses and fill out an Excel budget file for HR.

##### High-Level Architecture Analysis
- Single deployment unit (no microservices).
- Layers:
a. Presentation Layer (Streamlit UI)
b. Business Logic Layer (feature modules)
c. Data Access Layer (SQLite + Excel files on disk)

##### Main Components
A. User & Browser
- The HR user accesses the app via a browser pointing at the Streamlit server.
B. Streamlit Application
- Entry point scripts (`Interfaz_DB.py`, `PROYECTO_MENU/Interfaz_DB.py`)
- UI pages and menus under each feature folder:
- archivo_excel/visualizar_excel.py
- armado_de_tabla/interfaz.py
- calculo_de_bono/interfaz.py
- calculo_mensual/interfaz.py
- gestion_parametros/interfaz.py
- Static assets: `assets/styles.css`
C. Business Logic Modules
- calculos/…: core computational routines (bono.py, promedios.py, etc.)
- armado_de_tabla/: orchestrates Excel table building
- calculo_mensual/: monthly bonus & overtime calculators + JSON mappings
- calculo_de_bono/: overall bonus budget estimations
D. Data Access & Persistence
- SQLite file `gestion_parametros/parametros.db` for parameter storage
- Excel files on disk (input & output under archivo_excel folder)
- JSON mapping file `calculo_mensual/mapeo_bonos.json`
E. File System
- Stores generated Excel budgets and reads source spreadsheets.

##### Interactions and Data Flow
1. User → Browser → HTTP request to Streamlit server
2. Streamlit UI layer determines which feature to invoke
3. UI calls into Business Logic modules
- For parameter management: logic_parametros.py ↔ db.py ↔ SQLite
- For Excel operations: procesar_excel.py, rellenar_*.py → read/write .xlsx
- For calculations: functions in cálculos/ invoked by calculo_mensual or calculo_de_bono
4. Business Logic returns results to UI
5. UI renders results and offers download link for generated Excel

##### Architectural Patterns & Principles
- Layered pattern (Presentation → Logic → Data)
- Single responsibility: each folder handles one major feature
- Reuse of calculos module for all numeric computations
- File-based persistence for Excel and lightweight relational DB for parameters

##### Technologies & Frameworks
- Python 3.x
- Streamlit for web UI
- SQLite (`sqlite3` in db.py)
- pandas / openpyxl or similar (implied by Excel processing)
- CSS for styling (`assets/styles.css`)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External
    UserBrowser["User & Browser"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        StreamlitApp["Streamlit App (Streamlit vX.X)"]:::presentation
        MainEntry["Interfaz_DB.py"]:::presentation
        MenuEntry["PROYECTO_MENU/Interfaz_DB.py"]:::presentation
        ArchExcelUI["Archivo Excel Viewer"]:::presentation
        TableUI["Armado de Tabla UI"]:::presentation
        BonoUI["Cálculo de Bono UI"]:::presentation
        MensUI["Cálculo Mensual UI"]:::presentation
        ParamUI["Gestión de Parámetros UI"]:::presentation
        StaticCSS["assets/styles.css"]:::presentation
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        direction TB
        CalculosMod["calculos Module"]:::business
        TablaProc["armado_de_tabla Processing"]:::business
        MensProc["calculo_mensual Processing"]:::business
        BonoProc["calculo_de_bono Processing"]:::business
        ParamLog["gestion_parametros Logic"]:::business
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        SqlDB["SQLite DB"]:::data
        ExcelFS["Excel File System"]:::data
    end

    %% Flows
    UserBrowser -->|HTTP request| StreamlitApp
    StreamlitApp --> MainEntry
    StreamlitApp --> MenuEntry
    MainEntry --> ArchExcelUI
    MainEntry --> TableUI
    MainEntry --> BonoUI
    MainEntry --> MensUI
    MainEntry --> ParamUI
    StreamlitApp --> StaticCSS

    ArchExcelUI -->|load spreadsheets| ExcelFS
    ArchExcelUI -->|calls| TablaProc

    TableUI -->|process Excel| TablaProc
    TablaProc -->|write/read| ExcelFS

    BonoUI -->|invoke| BonoProc
    BonoProc -->|calculations| CalculosMod
    BonoProc -->|read/write| ExcelFS

    MensUI -->|invoke| MensProc
    MensProc -->|calculations| CalculosMod
    MensProc -->|read/write| ExcelFS

    ParamUI -->|invoke| ParamLog
    ParamLog -->|read/write| SqlDB

    CalculosMod -->|results| BonoProc
    CalculosMod -->|results| MensProc

    %% Click Events
    click MainEntry "https://github.com/dils02/prueba/blob/main/Interfaz_DB.py"
    click MenuEntry "https://github.com/dils02/prueba/blob/main/PROYECTO_MENU/Interfaz_DB.py"
    click ArchExcelUI "https://github.com/dils02/prueba/blob/main/PROYECTO_MENU/archivo_excel/visualizar_excel.py"
    click TableUI "https://github.com/dils02/prueba/blob/main/PROYECTO_MENU/armado_de_tabla/interfaz.py"
    click BonoUI "https://github.com/dils02/prueba/blob/main/PROYECTO_MENU/calculo_de_bono/interfaz.py"
    click MensUI "https://github.com/dils02/prueba/blob/main/PROYECTO_MENU/calculo_mensual/interfaz.py"
    click ParamUI "https://github.com/dils02/prueba/blob/main/PROYECTO_MENU/gestion_parametros/interfaz.py"
    click StaticCSS "https://github.com/dils02/prueba/blob/main/PROYECTO_MENU/assets/styles.css"
    click CalculosMod "https://github.com/dils02/prueba/tree/main/PROYECTO_MENU/calculos/"
    click TablaProc "https://github.com/dils02/prueba/blob/main/PROYECTO_MENU/armado_de_tabla/procesar_excel.py"
    click MensProc "https://github.com/dils02/prueba/blob/main/PROYECTO_MENU/calculo_mensual/calculo_mensual.py"
    click ParamLog "https://github.com/dils02/prueba/blob/main/PROYECTO_MENU/gestion_parametros/db.py"

    %% Styles
    classDef presentation fill:#BBDEFB,stroke:#1E88E5,color:#0D47A1;
    classDef business fill:#C8E6C9,stroke:#43A047,color:#1B5E20;
    classDef data fill:#FFE0B2,stroke:#FB8C00,color:#E65100;
    classDef external fill:#E0E0E0,stroke:#9E9E9E,color:#424242;
```
