# aaguiar10/gflows architecture

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

- Interactive diagram: https://gitdiagram.com/aaguiar10/gflows
- Repository: https://github.com/aaguiar10/gflows

## Overview

##### Main Components

a) Data Layer:
- External Data Source (CBOE API/Yahoo Finance)
- Data Storage System (JSON and CSV files in data/ directory)
- Both data formats supported (JSON and CSV directories)

b) Application Core:
- Background Scheduler System
- Data Processing Modules
- Web Server (Dash/Flask)

c) Frontend Layer:
- Dash UI Components
- CSS Styling
- JavaScript Theme Handler

##### Data Flow
- External API → Data Downloader (ticker_dwn.py) → Storage (data/)
- Storage → Data Processing (calc.py, stats.py) → UI Layout (layout.py)

##### Control Flow
- Background Scheduler → Data Downloader
- User Interactions → Layout Module → Calculation Module

##### Specific Implementation Details

- Blue Rectangles: Core Application Components
- Yellow Diamonds: External Services
- Orange Rectangles: Processing Modules
- Purple Rectangles: UI Components

##### Key Elements to Highlight

a) Scheduler System:
- 15-minute update cycle (9:00 AM - 4:30 PM ET)
- Retry mechanism (5-second intervals)

b) Data Processing Pipeline:
- Options data ingestion
- Greeks calculations (Delta, Gamma, Vanna, Charm)
- IV averaging

c) Configuration System:
- Environment variables
- Application settings

##### Architectural Patterns to Emphasize

- Modular Design (separate modules for different functionalities)
- Event-Driven Architecture (scheduler-based updates)
- MVC-like Pattern (separation of layout, calculation, and data)

##### Technical Details

Languages/Frameworks:
- Python 3.9+
- Dash/Flask
- Background Scheduler
- CBOE/Custom API Integration

**[User Interface Layer]**
- ↑↓
**[Application Layer]**
- ↑↓
**[Data Processing Layer]**
- ↑↓
**[Data Storage Layer]**
- ↑↓
**[External Services Layer]**

- Component types
- Update frequencies
- Time zone specifications

Additional Considerations:
##### Monitoring points for the scheduler

Remember to add notes about:
- Timezone handling (America/New_York)
- Market hours constraints
- Data format flexibility (JSON/CSV)
- Configuration options via .env file

This will provide a complete picture of how G|Flows operates while maintaining clarity and usefulness for development and maintenance purposes.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef external fill:#FFD700,stroke:#000
    classDef storage fill:#90EE90,stroke:#000
    classDef core fill:#87CEEB,stroke:#000
    classDef processing fill:#FFA500,stroke:#000
    classDef ui fill:#DDA0DD,stroke:#000
    classDef config fill:#D3D3D3,stroke:#000

    %% External Services Layer
    subgraph ExternalLayer["External Services Layer"]
        CBOE["CBOE API"]:::external
        YF["Yahoo Finance"]:::external
    end

    %% Data Storage Layer
    subgraph StorageLayer["Data Storage Layer"]
        DataStore{"Data Storage"}
        subgraph JSON["JSON Storage"]
            SPX_JSON["SPX Data"]:::storage
            NDX_JSON["NDX Data"]:::storage
            RUT_JSON["RUT Data"]:::storage
        end
        subgraph CSV["CSV Storage"]
            SPX_CSV["SPX Data"]:::storage
            NDX_CSV["NDX Data"]:::storage
            RUT_CSV["RUT Data"]:::storage
        end
    end

    %% Data Processing Layer
    subgraph ProcessingLayer["Data Processing Layer"]
        DataDownloader["Data Downloader"]:::processing
        GreeksCalc["Greeks Calculator"]:::processing
        StatsAnalysis["Statistical Analysis"]:::processing
    end

    %% Application Layer
    subgraph AppLayer["Application Layer"]
        WebServer["Web Server<br/>(Dash/Flask)"]:::core
        Scheduler["Background<br/>Scheduler"]:::core
        Config["Configuration<br/>.env"]:::config
    end

    %% UI Layer
    subgraph UILayer["UI Layer"]
        Layout["UI Layout"]:::ui
        Style["CSS Styling"]:::ui
        Theme["Theme Handler"]:::ui
    end

    %% Relationships
    CBOE & YF --> DataDownloader
    DataDownloader --> DataStore
    DataStore --> GreeksCalc & StatsAnalysis
    GreeksCalc & StatsAnalysis --> Layout
    Scheduler --> DataDownloader
    WebServer --> Layout
    Config --> WebServer
    Style & Theme --> Layout

    %% Click Events
    click WebServer "https://github.com/aaguiar10/gflows/blob/main/app.py"
    click DataDownloader "https://github.com/aaguiar10/gflows/blob/main/modules/ticker_dwn.py"
    click GreeksCalc "https://github.com/aaguiar10/gflows/blob/main/modules/calc.py"
    click StatsAnalysis "https://github.com/aaguiar10/gflows/blob/main/modules/stats.py"
    click Layout "https://github.com/aaguiar10/gflows/blob/main/modules/layout.py"
    click Style "https://github.com/aaguiar10/gflows/blob/main/assets/style.css"
    click Theme "https://github.com/aaguiar10/gflows/blob/main/assets/theme.js"
    click JSON "https://github.com/aaguiar10/gflows/tree/main/data/json"
    click CSV "https://github.com/aaguiar10/gflows/tree/main/data/csv"
    click SPX_JSON "https://github.com/aaguiar10/gflows/blob/main/data/json/spx_quotedata.json"
    click NDX_JSON "https://github.com/aaguiar10/gflows/blob/main/data/json/ndx_quotedata.json"
    click RUT_JSON "https://github.com/aaguiar10/gflows/blob/main/data/json/rut_quotedata.json"
    click SPX_CSV "https://github.com/aaguiar10/gflows/blob/main/data/csv/spx_quotedata.csv"
    click NDX_CSV "https://github.com/aaguiar10/gflows/blob/main/data/csv/ndx_quotedata.csv"
    click RUT_CSV "https://github.com/aaguiar10/gflows/blob/main/data/csv/rut_quotedata.csv"

    %% Legend
    subgraph Legend["Legend"]
        L1["External Services"]:::external
        L2["Storage Components"]:::storage
        L3["Core Components"]:::core
        L4["Processing Modules"]:::processing
        L5["UI Components"]:::ui
        L6["Configuration"]:::config
    end
```
