# suyashagnihotri/share-market-price-prediction architecture

> Architecture diagram of the GitHub repository suyashagnihotri/share-market-price-prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/suyashagnihotri/share-market-price-prediction
- Repository: https://github.com/suyashagnihotri/share-market-price-prediction

## Overview

##### Project type and purpose
- This is an ML-based, single-page web application whose goal is to train an LSTM on historical stock data (in a Jupyter notebook) and then serve real-time predictions and visualizations via a Streamlit app.

##### File structure
- .devcontainer/ → development container config for reproducible environment (VSCode dev‐container)
- LSTM.ipynb → training pipeline (data ingestion, feature engineering, model fitting)
- STOCK.keras → persisted Keras LSTM model file (inference artifact)
- lstm_real.py → Streamlit application for model loading, data fetching, prediction, and UI
- requirements.txt → Python dependencies (Keras/TensorFlow, Streamlit, pandas, yfinance/TA-libs, etc.)

##### README for additional insights
- Confirms two main workflows: “train & save LSTM” vs. “load & infer in Streamlit.”
- Mentions OHLCV data retrieval, technical indicator computation, real-time plotting.

##### Main components & interactions
a. Model Training Pipeline (Offline)
- Data Loader: imports historical OHLCV from CSV or API
- Preprocessor: scales and window-frames time series
- LSTM Trainer (Keras): defines, fits model
- Artifact Store: writes out STOCK.keras to disk

b. Model Serving / Inference (Online)
- Streamlit App (lstm_real.py): exposes web UI
- Data Fetcher: calls external API (e.g., yfinance) for recent OHLCV
- Feature Processor: computes indicators and windows matching training
- Model Loader: loads STOCK.keras
- Inference Engine: runs model.predict(…)
- Visualization Module: plots OHLCV + indicators + forecast
- Browser UI: end user sees interactive charts

c. Supporting Infrastructure
- Dev Container: Docker/VSCode for consistent dev environment
- Version Control: .gitignore + Git repo

##### Architectural patterns & design principles
- Separation of concerns: Training vs. Serving are entirely decoupled
- Pipeline pattern: sequential data flow in both train and serve paths
- Artifact management: single model file (STOCK.keras) as contract between train/serve
- External integration: data fetched at runtime from public API

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Operations
    subgraph "Operations"
        DC["Dev Container\n(.devcontainer)"]:::ops
        VC["Version Control\n(.gitignore)"]:::ops
    end

    %% Offline Training Pipeline
    subgraph "Offline Training Pipeline"
        DL["Data Loader\n(OHLCV CSV/API)"]:::compute
        PR["Preprocessor\n(scaling & windowing)"]:::compute
        TR["LSTM Trainer\n(Keras training)"]:::compute
        MD["Model Artifact\nSTOCK.keras"]:::storage
    end

    %% Online Serving Pipeline
    subgraph "Online Serving / Inference"
        SL["Streamlit App\n(lstm_real.py)"]:::framework
        DF["Data Fetcher\n(yfinance/API)"]:::external
        FP["Feature Processor\n(indicators & windows)"]:::compute
        ML["Model Loader\n(loads STOCK.keras)"]:::compute
        IE["Inference Engine\n(model.predict)"]:::compute
        VZ["Visualization Module\n(plots & charts)"]:::compute
        BR["Browser UI\n(end user)"]:::external
    end

    %% Documentation & Dependencies
    RD["Project Docs\nREADME.md"]:::framework
    RP["Dependencies\nrequirements.txt"]:::framework

    %% Flow Connections
    DL -->|"raw OHLCV data"| PR
    PR -->|"processed windows"| TR
    TR -->|"trained model"| MD
    MD -->|"model file"| ML
    DF -->|"recent OHLCV JSON"| FP
    FP -->|"features & windows"| IE
    ML -->|"loaded model"| IE
    IE -->|"predicted prices"| VZ
    VZ -->|"charts & UI"| BR

    %% Supporting links
    DL --> RP
    SL --> RP
    SL --> RD

    %% Click Events
    click DC "https://github.com/suyashagnihotri/share-market-price-prediction/blob/main/.devcontainer/devcontainer.json"
    click VC "https://github.com/suyashagnihotri/share-market-price-prediction/blob/main/.gitignore"
    click DL "https://github.com/suyashagnihotri/share-market-price-prediction/blob/main/LSTM.ipynb"
    click PR "https://github.com/suyashagnihotri/share-market-price-prediction/blob/main/LSTM.ipynb"
    click TR "https://github.com/suyashagnihotri/share-market-price-prediction/blob/main/LSTM.ipynb"
    click MD "https://github.com/suyashagnihotri/share-market-price-prediction/blob/main/STOCK.keras"
    click SL "https://github.com/suyashagnihotri/share-market-price-prediction/blob/main/lstm_real.py"
    click DF "https://github.com/suyashagnihotri/share-market-price-prediction/blob/main/lstm_real.py"
    click FP "https://github.com/suyashagnihotri/share-market-price-prediction/blob/main/lstm_real.py"
    click ML "https://github.com/suyashagnihotri/share-market-price-prediction/blob/main/lstm_real.py"
    click IE "https://github.com/suyashagnihotri/share-market-price-prediction/blob/main/lstm_real.py"
    click VZ "https://github.com/suyashagnihotri/share-market-price-prediction/blob/main/lstm_real.py"
    click RD "https://github.com/suyashagnihotri/share-market-price-prediction/blob/main/README.md"
    click RP "https://github.com/suyashagnihotri/share-market-price-prediction/blob/main/requirements.txt"

    %% Styles
    classDef compute fill:#ADD8E6,stroke:#000000
    classDef storage fill:#90EE90,stroke:#000000
    classDef external fill:#FFA500,stroke:#000000
    classDef framework fill:#D3D3D3,stroke:#000000
    classDef ops fill:#E8E8E8,stroke:#000000,stroke-dasharray: 5 5
```
