# jhackisneros/dashboard_de_mando architecture

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

- Interactive diagram: https://gitdiagram.com/jhackisneros/dashboard_de_mando
- Repository: https://github.com/jhackisneros/dashboard_de_mando

## Overview

##### Project Type and Purpose
- This is a Streamlit-based interactive dashboard (“Dashboard de Mando y Control – ChronoLogistics”) that integrates three decision-support modules (Tactical Risk “Precog”, Strategic Vision “Chronos”, and Interactive Battle Manual “K-Lang”), plus a “Chatbot” page.
- Its primary function is to ingest geospatial and sensor data, run analytics/simulations, then present charts, heatmaps and maps in a browser UI.

##### File Structure Overview
- Top-level files and folders:
- `.devcontainer/` – VS Code DevContainer configuration
- `_pages/` – Streamlit multipage modules (chatbot.py, chronos.py, klang.py, precog.py)
- `app.py` – Main Streamlit launcher (or entry point renamed from run.py)
- `functions/` – Business-logic layer (ChronosLogic.py, precog.py, protocolos.py, utils.py)
- `data/` – Raw data assets (GeoJSON, CSV)
- `scripts/` – ETL/preprocessing helpers (download_distritos.py)
- `generate_geojson.py` – Standalone converter/generator
- `requirements.txt` – Python dependencies (Streamlit, pandas, numpy, matplotlib, seaborn, scikit-learn, plotly, Pillow)
- Key patterns:
- Layered separation: UI (_pages + app.py) → Service/Logic (functions/) → Data storage (data/, assets/)
- Pre-processing scripts and one-off data generators live outside the UI pipeline

a. User Interface Layer
- Browser → Streamlit Server (hosted locally or on cloud)
- `app.py` / `_pages/*.py` (each page implements a view + controller logic)
b. Application Logic Layer
- `functions/ChronosLogic.py`, `precog.py`, `protocolos.py`, `utils.py`
- Shared routines for data processing, model inference, map layering
c. Data Layer
- `data/sensores.csv` & `data/distritos_madrid.geojson` (raw inputs)
- Generated artifacts (`generate_geojson.py` output)
- Static assets (`assets/`)
d. Auxiliary & Deployment
- `.devcontainer/` for local dev
- `scripts/` for offline ETL
- External libraries: Streamlit, pandas, numpy, matplotlib/seaborn, plotly, scikit-learn, Pillow
- Optional deployment targets: Streamlit Community Cloud, Hugging Face Spaces, Heroku

##### Relationships & Data Flow
- User clicks or selects module → HTTP request to Streamlit backend →
Streamlit routes to the appropriate `_pages/*.py` →
Page code calls into `functions/` to fetch, process, and model data →
Data is loaded from `data/` or precomputed artifacts →
Results (charts, maps) are rendered via Streamlit widgets and plotly/matplotlib →
Browser displays visualizations.
- Offline: `scripts/download_distritos.py` populates raw data, then `generate_geojson.py` transforms to GeoJSON for `data/`.

##### Architectural Patterns & Principles
- Modular multipage design: each `_pages` file is an isolated view/controller
- Business logic extraction: `functions/` enforces single-responsibility and reusability
- Clear separation of concerns: ETL scripts outside the request path
- Leverage containerization (`.devcontainer`) for dev-prod parity

- Labels: Component name, file path or module name

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Deployment and Infrastructure Layer
    subgraph "Deployment/Infra"
        direction TB
        DC[".devcontainer"]:::infra
        REQ["requirements.txt"]:::infra
        Cloud["Cloud Deployment"]:::infra
    end

    %% ETL Pipeline (Offline)
    subgraph "ETL Pipeline (Offline)"
        direction TB
        Scripts["download_distritos.py"]:::infra
        Gen["generate_geojson.py"]:::data
        Scripts -.->|"runs ETL"| Gen
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        RawSens["sensores.csv"]:::data
        RawGeo["distritos_madrid.geojson"]:::data
        Assets["assets/"]:::data
    end

    %% Application Logic Layer
    subgraph "Logic Layer"
        direction TB
        ChronosLogic["ChronosLogic.py"]:::logic
        PrecogLogic["precog.py"]:::logic
        Protocol["protocolos.py"]:::logic
        Utils["utils.py"]:::logic
    end

    %% UI Layer
    subgraph "UI Layer"
        direction TB
        Browser["Browser"]:::ui
        Streamlit["Streamlit Server"]:::ui
        App["app.py"]:::ui
        Chatbot["Chatbot Page"]:::ui
        Chronos["Chronos Page"]:::ui
        KLang["K-Lang Page"]:::ui
        Precog["Precog Page"]:::ui
    end

    %% Runtime Data Flow
    Browser <--> Streamlit
    Streamlit --> App
    App --> Chatbot
    App --> Chronos
    App --> KLang
    App --> Precog

    Chatbot --> Utils
    Chronos --> ChronosLogic
    KLang --> Utils
    Precog --> PrecogLogic

    ChronosLogic --> Protocol
    ChronosLogic --> Utils
    PrecogLogic --> Utils

    ChronosLogic --> RawSens
    ChronosLogic --> RawGeo
    PrecogLogic --> RawSens

    Utils --> Assets
    Protocol --> Assets

    %% Offline Data Generation
    Gen --> RawGeo
    Scripts -.-> RawSens

    %% Click Events
    click App "https://github.com/jhackisneros/dashboard_de_mando/blob/main/app.py"
    click Chatbot "https://github.com/jhackisneros/dashboard_de_mando/blob/main/_pages/chatbot.py"
    click Chronos "https://github.com/jhackisneros/dashboard_de_mando/blob/main/_pages/chronos.py"
    click KLang "https://github.com/jhackisneros/dashboard_de_mando/blob/main/_pages/klang.py"
    click Precog "https://github.com/jhackisneros/dashboard_de_mando/blob/main/_pages/precog.py"
    click ChronosLogic "https://github.com/jhackisneros/dashboard_de_mando/blob/main/functions/ChronosLogic.py"
    click PrecogLogic "https://github.com/jhackisneros/dashboard_de_mando/blob/main/functions/precog.py"
    click Protocol "https://github.com/jhackisneros/dashboard_de_mando/blob/main/functions/protocolos.py"
    click Utils "https://github.com/jhackisneros/dashboard_de_mando/blob/main/functions/utils.py"
    click RawSens "https://github.com/jhackisneros/dashboard_de_mando/blob/main/data/sensores.csv"
    click RawGeo "https://github.com/jhackisneros/dashboard_de_mando/blob/main/data/distritos_madrid.geojson"
    click Gen "https://github.com/jhackisneros/dashboard_de_mando/blob/main/generate_geojson.py"
    click Assets "https://github.com/jhackisneros/dashboard_de_mando/tree/main/assets/"
    click Scripts "https://github.com/jhackisneros/dashboard_de_mando/blob/main/scripts/download_distritos.py"
    click DC "https://github.com/jhackisneros/dashboard_de_mando/blob/main/.devcontainer/devcontainer.json"
    click REQ "https://github.com/jhackisneros/dashboard_de_mando/blob/main/requirements.txt"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#333,stroke-width:1px
    classDef logic fill:#ABEBC6,stroke:#333,stroke-width:1px
    classDef data fill:#F9E79F,stroke:#333,stroke-width:1px
    classDef infra fill:#D5DBDB,stroke:#333,stroke-width:1px
```
