# bennythadikaran/eod2 architecture

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

- Interactive diagram: https://gitdiagram.com/bennythadikaran/eod2
- Repository: https://github.com/bennythadikaran/eod2

## Overview

##### Main Components
- Data Ingestion & Update Engine: This is primarily handled by the script in dget.py, which periodically fetches NSE stock data, performs historical adjustments, and updates CSV files.
- Data Storage Layer: The CSV files stored in directories like src/eod2_data (including the “daily” subfolder mentioned in the README) and src/data (with sectors.csv) represent the persistent storage of processed stock and index information.
- Core Definitions & Utilities: The src/defs directory (with Config.py, Plotter.py, Plugin.py, defs.py, diagnostic.py, and utils.py) encapsulates the core configurations, utility functions, plotting functionality, and plugin mechanisms. These modules form the backbone of the project logic.
- Plugin System: Under src/plugin (e.g., rsi.py), specialized analysis components extend capabilities (like technical indicators). This demonstrates a level of modular design, where additional analysis can be integrated via plugins.
- Visualization/Plotting: Managed by plot.py (and supported by Plotter.py in src/defs), this component allows analysis through charts. It includes interactive tools (support, resistance, trend, and trading lines) as showcased in the README images.
- Testing & Validation: The tests directory with a variety of test scripts ensures that the core functionalities (data loading, module handling, utility functions) have automated checks in place.
- Setup & Configuration: Files like setup_data.py and requirements.txt are used to initialize data and manage dependencies.

##### Relationships and Data Flow
- User Interaction / Cron Jobs: Initiates the execution of the main scripts (dget.py for data updates and plot.py for visualization).
- Data Retrieval: dget.py interacts with NSE endpoints (external service) to download daily data.
- Data Adjustment and Storage: The fetched data is processed using logic defined in the defs modules and then stored as CSV files (organized under src/eod2_data and src/data).
- Configuration & Plugin Integration: The core configuration module (Config.py) controls parameters, while the Plugin.py and additional modules under src/plugin (like rsi.py) provide additional technical analysis capabilities.
- Visualization: When plot.py is executed, it references the processed CSV data and uses Plotter.py to generate visual charts, optionally leveraging plugins for technical indicators.

##### Architectural Patterns and Principles
- Modularity and Separation of Concerns: Distinct directories and modules separate data ingestion, processing, configuration, plug-in management, and visualization.
- Extensibility: The plugin structure allows easy addition of more analysis tools without modifying the core system.
- Data Flow Independence: Data is stored persistently in CSVs, which provides a clear demarcation between data ingestion and visualization layers.
- Testing and Robustness: The testing folder ensures that each layer can be validated independently, promoting reliability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and Trigger
    subgraph "User/Trigger"
        U["User / Cron Job"]:::user
    end

    %% Ingestion Layer
    subgraph "Ingestion Layer"
        DGET["Data Ingestion (dget.py)"]:::ingestion
    end

    %% External Data Source
    subgraph "External Service"
        NSE["NSE Data Source"]:::external
    end

    %% Core Processing & Utilities
    subgraph "Core Processing"
        CORE["Core Definitions & Utilities (src/defs)"]:::core
        DIAG["Diagnostics (diagnostic.py)"]:::core
    end

    %% Plugin System
    subgraph "Plugin System"
        PLUGIN["Technical Analysis Plugin (rsi.py)"]:::plugin
    end

    %% Data Storage Layer
    subgraph "Data Storage Layer"
        CSV["CSV Files (src/eod2_data)"]:::storage
        SECTORS["Sectors Data (src/data/sectors.csv)"]:::storage
    end

    %% Visualization Layer
    subgraph "Visualization Layer"
        PLOT["Visualization (plot.py)"]:::viz
        CHART["Charting (Plotter.py)"]:::viz
    end

    %% Setup & Configuration
    subgraph "Setup & Configuration"
        SETUP["Setup (setup_data.py)"]:::setup
        REQT["Dependencies (requirements.txt)"]:::setup
    end

    %% Testing Suite
    subgraph "Testing Suite"
        TEST["Tests (tests folder)"]:::testing
    end

    %% Data Flow
    U -->|"triggers"| DGET
    DGET -->|"calls"| NSE
    DGET -->|"processes data"| CORE
    CORE -->|"stores daily CSV"| CSV
    CORE -->|"stores sectors data"| SECTORS
    CORE -->|"handles errors"| DIAG
    CORE -->|"integrates plugin"| PLUGIN
    PLUGIN -->|"extends analysis"| CORE
    U -->|"can trigger"| PLOT
    PLOT -->|"reads data from"| CSV
    PLOT -->|"reads data from"| SECTORS
    PLOT -->|"utilizes plotting"| CHART
    PLOT -->|"uses core plotting tools"| CORE
    SETUP -->|"configures"| CORE
    TEST -->|"verifies functionality of"| DGET
    TEST -->|"verifies functionality of"| CORE
    TEST -->|"verifies functionality of"| PLUGIN
    TEST -->|"verifies functionality of"| PLOT

    %% Click Events
    click DGET "https://github.com/bennythadikaran/eod2/blob/main/src/dget.py"
    click CSV "https://github.com/bennythadikaran/eod2/tree/main/src/eod2_data"
    click SECTORS "https://github.com/bennythadikaran/eod2/blob/main/src/data/sectors.csv"
    click CORE "https://github.com/bennythadikaran/eod2/tree/main/src/defs"
    click PLUGIN "https://github.com/bennythadikaran/eod2/blob/main/src/plugin/rsi.py"
    click PLOT "https://github.com/bennythadikaran/eod2/blob/main/src/plot.py"
    click CHART "https://github.com/bennythadikaran/eod2/blob/main/src/defs/Plotter.py"
    click TEST "https://github.com/bennythadikaran/eod2/tree/main/tests"
    click SETUP "https://github.com/bennythadikaran/eod2/blob/main/setup_data.py"
    click REQT "https://github.com/bennythadikaran/eod2/blob/main/requirements.txt"

    %% Styles
    classDef ingestion fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef external fill:#F0E68C,stroke:#000,stroke-width:2px;
    classDef core fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef plugin fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef storage fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef viz fill:#E6E6FA,stroke:#000,stroke-width:2px;
    classDef setup fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef testing fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef user fill:#FFA07A,stroke:#000,stroke-width:2px;
```
