# alok-yadav25/stock-prediction-using-lstm architecture

> Architecture diagram of the GitHub repository alok-yadav25/stock-prediction-using-lstm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alok-yadav25/stock-prediction-using-lstm
- Repository: https://github.com/alok-yadav25/stock-prediction-using-lstm

## Overview

This is a Flask stock-analysis application: a user submits a ticker in the browser, the backend fetches historical Yahoo Finance data, runs an LSTM prediction, and returns metrics, charts, and tables for display. The README also identifies notebook-based model training and interactive charting as capabilities. The graph separates request handling, prediction, and presentation; unsampled template routing and model-artifact loading are shown only where documented or explicitly marked unverified.

Main entry points: [`app.py`](https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/app.py) (Flask analysis API), [`static/js/script.js`](https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/static/js/script.js) (Form and results), [`templates/index.html`](https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/templates/index.html) (Analysis interface), [`models/model.h5`](https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/models/model.h5) (LSTM model artifact)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_frontend["Analysis interface<br/>[index.html]"]
  node_browser_logic["Form and results<br/>[script.js]"]
end

subgraph group_backend["Analysis backend"]
  node_flask_api["Flask analysis API<br/>[app.py]"]
  node_market_data["Historical market data<br/>[app.py]"]
  node_prediction["LSTM prediction<br/>[app.py]"]
  node_analysis_outputs["Metrics and visualizations<br/>[app.py]"]
end

subgraph group_model["Model lifecycle"]
  node_trained_model[("LSTM model artifact<br/>[model.h5]")]
  node_scaler[("Price scaler<br/>[scaler.pkl]")]
  node_training["Notebook training<br/>[st.ipynb]"]
end

node_user(("Stock analyst"))
node_yahoo["Yahoo Finance"]

node_user -.->|"enters ticker"| node_frontend
node_frontend -.->|"loads interface"| node_browser_logic
node_browser_logic -->|"posts ticker"| node_flask_api
node_flask_api -->|"handles request"| node_market_data
node_market_data -->|"downloads prices"| node_yahoo
node_flask_api -->|"prepares sequences"| node_prediction
node_prediction -.->|"predicts with"| node_trained_model
node_prediction -.->|"scales prices"| node_scaler
node_flask_api -->|"builds response"| node_analysis_outputs
node_analysis_outputs -->|"returns results"| node_browser_logic
node_browser_logic -.->|"renders results"| node_frontend
node_training -.->|"trains model"| node_trained_model

click node_frontend "https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/templates/index.html"
click node_browser_logic "https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/static/js/script.js"
click node_flask_api "https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/app.py"
click node_market_data "https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/app.py"
click node_prediction "https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/app.py"
click node_analysis_outputs "https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/app.py"
click node_trained_model "https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/models/model.h5"
click node_scaler "https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/models/scaler.pkl"
click node_training "https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/notebooks/st.ipynb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend,node_browser_logic toneBlue
class node_flask_api,node_market_data,node_prediction,node_analysis_outputs toneAmber
class node_trained_model,node_scaler,node_training toneMint
class node_user,node_yahoo toneIndigo
```

## Components

### Web interface

- [Analysis interface](https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/templates/index.html): `templates/index.html`
- [Form and results](https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/static/js/script.js): `static/js/script.js`

### Analysis backend

- [Flask analysis API](https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/app.py): `app.py`
- [Historical market data](https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/app.py): `app.py`
- [LSTM prediction](https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/app.py): `app.py`
- [Metrics and visualizations](https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/app.py): `app.py`

### Model lifecycle

- [LSTM model artifact](https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/models/model.h5): `models/model.h5`
- [Price scaler](https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/models/scaler.pkl): `models/scaler.pkl`
- [Notebook training](https://github.com/alok-yadav25/stock-prediction-using-lstm/blob/main/notebooks/st.ipynb): `notebooks/st.ipynb`

### Other components

- **Stock analyst**
- **Yahoo Finance**

## Connections

- Stock analyst → Analysis interface: enters ticker (evidence: `README.md`)
- Analysis interface → Form and results: loads interface (evidence: `README.md`)
- Form and results → Flask analysis API: posts ticker (evidence: `static/js/script.js`)
- Flask analysis API → Historical market data: handles request (evidence: `app.py`)
- Historical market data → Yahoo Finance: downloads prices (evidence: `app.py`)
- Flask analysis API → LSTM prediction: prepares sequences (evidence: `app.py`)
- LSTM prediction → LSTM model artifact: predicts with
- LSTM prediction → Price scaler: scales prices
- Flask analysis API → Metrics and visualizations: builds response (evidence: `app.py`)
- Metrics and visualizations → Form and results: returns results (evidence: `static/js/script.js`)
- Form and results → Analysis interface: renders results (evidence: `README.md`)
- Notebook training → LSTM model artifact: trains model (evidence: `README.md`)
