# dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis architecture

> Architecture diagram of the GitHub repository dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis
- Repository: https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis

## Overview

This stock-forecasting application collects historical prices and news, trains an LSTM, evaluates validation predictions, adjusts forecasts using sentiment, and presents results through either a command-line workflow or browser dashboard. The graph preserves the separate data, sentiment, modeling, evaluation, and presentation stages. The main, API, and Streamlit workflows are evidenced by excerpts; README documents capabilities such as technical indicators and both interfaces. The static frontend calls the API directly. Other source paths are included only where supported by the tree; unsampled implementation details and relationships are not inferred.

Main entry points: [`main.py`](https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/main.py) (CLI workflow), [`frontend_app.py`](https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/frontend_app.py) (Streamlit dashboard), [`api.py`](https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/api.py) (Prediction API), [`data_fetcher.py`](https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/data_fetcher.py) (Price collection and indicators)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_cli["CLI workflow<br/>[main.py]"]
  node_dashboard["Streamlit dashboard<br/>[frontend_app.py]"]
  node_web["Browser dashboard<br/>[script.js]"]
  node_api["Prediction API<br/>[api.py]"]
end

subgraph group_market["Market data"]
  node_prices["Price collection and indicators<br/>[data_fetcher.py]"]
  node_yahoo["Yahoo Finance"]
end

subgraph group_sentiment["News sentiment"]
  node_news["News retrieval and scoring<br/>[news_sentiment.py]"]
  node_newsapi["NewsAPI"]
end

subgraph group_prediction["Forecasting and evaluation"]
  node_lstm["LSTM preparation and forecasting<br/>[lstm_model.py]"]
  node_evaluation["Metrics and sentiment adjustment<br/>[trainer.py]"]
end

node_user(("Analyst"))

node_user -->|"runs"| node_cli
node_user -->|"configures"| node_dashboard
node_user -->|"submits"| node_web
node_cli -->|"fetches and features"| node_prices
node_cli -->|"gets sentiment"| node_news
node_cli -->|"trains and predicts"| node_lstm
node_cli -->|"evaluates and adjusts"| node_evaluation
node_dashboard -->|"loads features"| node_prices
node_dashboard -->|"loads sentiment"| node_news
node_dashboard -->|"trains and predicts"| node_lstm
node_dashboard -->|"evaluates and adjusts"| node_evaluation
node_web -->|"posts prediction request"| node_api
node_api -->|"fetches and features"| node_prices
node_api -->|"gets sentiment"| node_news
node_api -->|"trains and predicts"| node_lstm
node_api -->|"evaluates and adjusts"| node_evaluation
node_prices -->|"requests history"| node_yahoo
node_news -->|"requests articles"| node_newsapi

click node_cli "https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/main.py"
click node_dashboard "https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/frontend_app.py"
click node_web "https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/frontend/script.js"
click node_api "https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/api.py"
click node_prices "https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/data_fetcher.py"
click node_news "https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/news_sentiment.py"
click node_lstm "https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/lstm_model.py"
click node_evaluation "https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/trainer.py"

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_cli,node_dashboard,node_web,node_api toneBlue
class node_prices,node_yahoo toneAmber
class node_news,node_newsapi toneMint
class node_lstm,node_evaluation toneRose
class node_user toneIndigo
```

## Components

### User interfaces

- [CLI workflow](https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/main.py): `main.py`
- [Streamlit dashboard](https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/frontend_app.py): `frontend_app.py`
- [Browser dashboard](https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/frontend/script.js): `frontend/script.js`
- [Prediction API](https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/api.py): `api.py`

### Market data

- [Price collection and indicators](https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/data_fetcher.py): `data_fetcher.py`
- **Yahoo Finance**

### News sentiment

- [News retrieval and scoring](https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/news_sentiment.py): `news_sentiment.py`
- **NewsAPI**

### Forecasting and evaluation

- [LSTM preparation and forecasting](https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/lstm_model.py): `lstm_model.py`
- [Metrics and sentiment adjustment](https://github.com/dhivagaran2004/stock-market-prediton-using-lstm-and-news-sentiment-analysis/blob/main/trainer.py): `trainer.py`

### Other components

- **Analyst**

## Connections

- Analyst → CLI workflow: runs (evidence: `README.md`)
- Analyst → Streamlit dashboard: configures (evidence: `README.md`)
- Analyst → Browser dashboard: submits (evidence: `frontend/script.js`)
- CLI workflow → Price collection and indicators: fetches and features (evidence: `main.py`)
- CLI workflow → News retrieval and scoring: gets sentiment (evidence: `main.py`)
- CLI workflow → LSTM preparation and forecasting: trains and predicts (evidence: `main.py`)
- CLI workflow → Metrics and sentiment adjustment: evaluates and adjusts (evidence: `main.py`)
- Streamlit dashboard → Price collection and indicators: loads features (evidence: `frontend_app.py`)
- Streamlit dashboard → News retrieval and scoring: loads sentiment (evidence: `frontend_app.py`)
- Streamlit dashboard → LSTM preparation and forecasting: trains and predicts (evidence: `frontend_app.py`)
- Streamlit dashboard → Metrics and sentiment adjustment: evaluates and adjusts (evidence: `frontend_app.py`)
- Browser dashboard → Prediction API: posts prediction request (evidence: `frontend/script.js`)
- Prediction API → Price collection and indicators: fetches and features (evidence: `api.py`)
- Prediction API → News retrieval and scoring: gets sentiment (evidence: `api.py`)
- Prediction API → LSTM preparation and forecasting: trains and predicts (evidence: `api.py`)
- Prediction API → Metrics and sentiment adjustment: evaluates and adjusts (evidence: `api.py`)
- Price collection and indicators → Yahoo Finance: requests history (evidence: `data_fetcher.py`)
- News retrieval and scoring → NewsAPI: requests articles (evidence: `news_sentiment.py`)
