# rajanguptashah/stock_price_forecasting architecture

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

- Interactive diagram: https://gitdiagram.com/rajanguptashah/stock_price_forecasting
- Repository: https://github.com/rajanguptashah/stock_price_forecasting

## Overview

##### Project type and purpose
- This is a data-driven, full-stack forecasting application written in Python.
- Purpose: ingest historical stock data (via Stooq API or offline CSV), engineer features (RSI, EMA, MACD), train a time-series forecasting model (Prophet), evaluate performance, and expose results through both a CLI and an interactive Dash web dashboard.

##### File structure
- Top level:
- Root CSV files (AAPL.csv, AMZN.csv, etc.) for offline mode
- stock_forecast.py – main CLI script that orchestrates data fetch, feature engineering, modeling, evaluation, and static plots
- (Implicit) app.py – Dash server for the interactive dashboard
- tempCodeRunnerFile.py – scratch or auxiliary code
- No separate “src/” or “frontend/” folders—this is a monolith that bundles data ingestion, ML pipeline, and dashboard.
- Configuration and dependency manifest implied via requirements.txt

##### README for additional insights
- Data acquisition: Stooq API with offline fallback to CSV.
- Technical indicators: RSI, EMA-9, EMA-21, MACD.
- Forecasting engine: Facebook Prophet.
- Visualization: Plotly (static) and Dash (interactive).
- Evaluation metrics: MAE, RMSE, MAPE.

##### Final advice
- Conditional logic for offline/online data fetching.
- Both CLI and web UIs so that stakeholders understand dual access modes.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Sources
    subgraph "Data Sources"
        Stooq["Stooq API"]:::external
        CSV["Local CSV Files"]:::external
    end

    %% Processing Pipeline
    DataIngestion["Data Ingestion & Offline-Mode Selector"]:::processing
    FeatureEng["Feature Engineering Module"]:::processing
    Forecast["Forecasting Engine (Prophet Model)"]:::processing
    Eval["Model Evaluation Module"]:::processing

    %% Visualization Layer
    subgraph "Visualization Layer"
        Static["Static Plotly Charts"]:::visualization
        DashUI["Dash Web Dashboard (Flask)"]:::visualization
    end

    %% User Interfaces
    CLI["Command-Line Interface"]:::ui
    WebUI["Web UI"]:::ui

    %% Scratch Code
    Scratch["Scratch/Auxiliary Code"]:::processing

    %% Connections
    Stooq -->|"raw OHLC data"| DataIngestion
    CSV -->|"raw OHLC data"| DataIngestion
    DataIngestion -->|"cleaned data"| FeatureEng
    FeatureEng -->|"engineered features"| Forecast
    Forecast -->|"forecast results"| Eval
    Forecast -->|"forecast results"| Static
    Forecast -->|"forecast results"| DashUI
    Eval -->|"error metrics"| Static
    Eval -->|"error metrics"| DashUI
    Static -->|"static plots"| CLI
    DashUI -->|"interactive dashboard"| WebUI
    CLI -->|"CLI output"| WebUI

    %% Click Events
    click CSV "https://github.com/rajanguptashah/stock_price_forecasting/tree/main//"
    click DataIngestion "https://github.com/rajanguptashah/stock_price_forecasting/blob/main/Stock_Price_Forecasting/stock_forecast.py"
    click FeatureEng "https://github.com/rajanguptashah/stock_price_forecasting/blob/main/Stock_Price_Forecasting/stock_forecast.py"
    click Forecast "https://github.com/rajanguptashah/stock_price_forecasting/blob/main/Stock_Price_Forecasting/stock_forecast.py"
    click Eval "https://github.com/rajanguptashah/stock_price_forecasting/blob/main/Stock_Price_Forecasting/stock_forecast.py"
    click Static "https://github.com/rajanguptashah/stock_price_forecasting/blob/main/Stock_Price_Forecasting/stock_forecast.py"
    click CLI "https://github.com/rajanguptashah/stock_price_forecasting/blob/main/Stock_Price_Forecasting/stock_forecast.py"
    click Scratch "https://github.com/rajanguptashah/stock_price_forecasting/blob/main/Stock_Price_Forecasting/tempCodeRunnerFile.py"

    %% Styles
    classDef external fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef processing fill:#90EE90,stroke:#333,stroke-width:1px
    classDef visualization fill:#FFA500,stroke:#333,stroke-width:1px
    classDef ui fill:#FFD700,stroke:#333,stroke-width:1px
```
