# danielcba/mini_dashboard architecture

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

- Interactive diagram: https://gitdiagram.com/danielcba/mini_dashboard
- Repository: https://github.com/danielcba/mini_dashboard

## Overview

##### Project Type and Purpose
- This is a single-page interactive web dashboard built with Streamlit (a Python framework that combines frontend UI and backend logic in one application).
- It fetches financial data (prices, dividends, metrics) for stock tickers (local and international), renders interactive Plotly charts, and allows CSV export.

##### File Structure Analysis
- Top-level files:
- mini_dashboard.py (core Streamlit app)
- requirements.txt (dependencies: streamlit, yfinance, plotly, pandas)
- .devcontainer (optional VSCode/container setup)
- README.md / README-EN.md & LICENSE
- No separate “frontend” or “backend” folders—Streamlit unifies both.
- No database directory—data comes from external API (yfinance).

a. Streamlit App Server
- Hosts mini_dashboard.py
- Exposes a web UI (HTTP:8501) to the user’s browser
b. Client Browser
- Renders the UI (charts, selectors, buttons) served by Streamlit
c. External Data Provider
- yfinance module issues HTTP requests to Yahoo Finance API
- Returns historical price and dividend data
d. Data Processing Layer
- pandas computes metrics (P/E, ROE, Beta)
- plotly generates interactive chart objects
e. Export Service
- CSV creation via pandas.to_csv
- Delivers downloadable file to the client
f. (Optional) Dev Container / Local Env
- .devcontainer/devcontainer.json for reproducible dev environment

##### Relationships & Data Flows
1. Client → Streamlit Server: UI interactions (ticker selection, export clicks)
2. Streamlit → yfinance: Data fetch requests → Yahoo Finance API → Streamlit
3. Streamlit: pandas transforms data, plotly builds charts
4. Streamlit → Browser: Renders updated charts and metrics
5. (On Export) Streamlit → Browser: CSV file download

##### Architectural Patterns & Design Principles
- Single-page application paradigm (no page reloads; reactive callbacks)
- Separation of concerns (within one file):
- Presentation (Streamlit UI components)
- Business Logic (data fetch + metric calculations)
- Data Layer (external API)
- Use of caching (Streamlit.cache, if implemented) to avoid refetching

##### Final Advice
- Be exhaustive: break the mini_dashboard.py into sub‐blocks (UI, fetch, transform, render, export).
- External dependencies (yfinance, pandas, plotly).
- Keep labels concise but informative (e.g., “Fetch via yfinance”, “Compute metrics with pandas”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Client["User Browser"]:::browser

    %% Streamlit Application Components
    subgraph "Streamlit Application"
        direction TB
        Server["Streamlit Server"]:::internal
        Fetch["Fetch Data via yfinance"]:::internal
        Process["Process Data (pandas & plotly)"]:::internal
        Export["Generate CSV (pandas.to_csv)"]:::internal
    end

    %% External Service
    Yahoo[(Yahoo Finance API)]:::external

    %% Development Environment
    DevEnv["Dev Container"]:::dev

    %% Artifacts
    Req["Dependency Manifest"]:::artifact
    Docs["Docs & License"]:::artifact

    %% Data Flows
    Client -->|UI actions| Server
    Server -->|calls Fetch| Fetch
    Fetch -->|HTTP request| Yahoo
    Yahoo -->|data response| Fetch
    Fetch -->|raw data| Process
    Process -->|charts & metrics| Server
    Server -->|renders UI| Client
    Server -->|triggers export| Export
    Export -->|download CSV| Client

    %% Environment & Artifacts Links
    DevEnv --- Server
    Req --- Server
    Docs --- Server

    %% Click Events
    click Server "https://github.com/danielcba/mini_dashboard/blob/main/mini_dashboard.py"
    click Fetch "https://github.com/danielcba/mini_dashboard/blob/main/mini_dashboard.py"
    click Process "https://github.com/danielcba/mini_dashboard/blob/main/mini_dashboard.py"
    click Export "https://github.com/danielcba/mini_dashboard/blob/main/mini_dashboard.py"
    click DevEnv "https://github.com/danielcba/mini_dashboard/blob/main/.devcontainer/devcontainer.json"
    click Req "https://github.com/danielcba/mini_dashboard/blob/main/requirements.txt"
    click Docs "https://github.com/danielcba/mini_dashboard/blob/main/README.md"

    %% Styles
    classDef internal fill:#D0E1FF,stroke:#333,stroke-width:1px
    classDef external fill:#CCFFE5,stroke:#333,stroke-width:1px
    classDef browser fill:#FFD9B3,stroke:#333,stroke-width:1px
    classDef dev fill:#E0E0E0,stroke:#333,stroke-width:1px
    classDef artifact fill:#F2F2F2,stroke:#333,stroke-width:1px
```
