# abhishek-ms-01/stock_market_prediction-with-rag_lstm architecture

> Architecture diagram of the GitHub repository abhishek-ms-01/stock_market_prediction-with-rag_lstm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm
- Repository: https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm

## Overview

AlphaTrade is a stock-market intelligence product: users inspect market data and indicators, request forecasts and risk views, and can ask an AI assistant for explanations. The documented hybrid approach combines price-derived features with time-aware news retrieval and LSTM prediction; the repository also includes portfolio recommendations and live-news ingestion. The graph reflects explicit calls where sampled, while some documented or tree-visible subsystems have no confirmed wiring in the excerpts.

Main entry points: [`backend/app/api/routes.py`](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/app/api/routes.py) (Feature routes), [`backend/main.py`](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/main.py) (FastAPI app), [`backend/data_ingestion/live_news_fetcher.py`](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/data_ingestion/live_news_fetcher.py) (Live news ingestion), [`frontend/src/app/dashboard`](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/tree/main/frontend/src/app/dashboard) (Dashboard pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Investor dashboard"]
  node_dashboard["Dashboard pages"]
  node_charts["Charts<br/>[ChartPanel.tsx]"]
  node_data_hook["Stock data hook<br/>[useStockData.ts]"]
  node_api_client["API client<br/>[client.ts]"]
end

subgraph group_api["API and orchestration"]
  node_api_main["FastAPI app<br/>[main.py]"]
  node_api_routes["Feature routes<br/>[routes.py]"]
end

subgraph group_market["Market intelligence"]
  node_indicators["Technical indicators"]
  node_features["Feature engineering<br/>[create_features.py]"]
  node_risk["Risk analysis<br/>[risk_analyzer.py]"]
  node_regime["Market regime<br/>[regime_detector.py]"]
  node_portfolio["Portfolio advice"]
end

subgraph group_news["News and retrieval"]
  node_news_fetch["Live news ingestion"]
  node_event_nlp["Event and sentiment NLP"]
  node_rag["Time-aware retrieval<br/>[time_aware_rag.py]"]
  node_chat_rag["Chat retrieval<br/>[rag_engine.py]"]
  node_news_store[("News corpus")]
end

subgraph group_models["Forecasting"]
  node_predict["Forecast endpoint<br/>[main.py]"]
  node_trainer["Online trainer<br/>[online_trainer.py]"]
  node_neural["Neural models<br/>[neural_models.py]"]
  node_chatbot["Chat assistant<br/>[chatbot.py]"]
end

node_investor(("Investor"))
node_market_data(("Market data provider"))
node_news_sources(("News sources"))

node_investor -->|"uses"| node_dashboard
node_dashboard -->|"renders"| node_charts
node_data_hook -->|"fetches stock data"| node_api_main
node_api_client -->|"sends API requests"| node_api_routes
node_api_routes -->|"downloads prices"| node_market_data
node_api_main -->|"fetches quotes"| node_market_data
node_api_routes -->|"calculates indicators"| node_indicators
node_api_routes -->|"calculates risk"| node_risk
node_api_routes -->|"detects regime"| node_regime
node_api_routes -->|"ranks forecasts"| node_portfolio
node_api_routes -->|"requests response"| node_chatbot
node_news_fetch -->|"fetches articles"| node_news_sources
node_news_fetch -->|"produces corpus"| node_news_store
node_rag -->|"indexes corpus"| node_news_store
node_chat_rag -->|"reads corpus"| node_news_store
node_investor -->|"requests features"| node_api_client
node_api_main -->|"trains model"| node_trainer
node_trainer -->|"uses market data"| node_market_data
node_predict -->|"runs inference"| node_neural
node_api_main -->|"serves forecast"| node_predict
node_event_nlp -.->|"enriches retrieval"| node_rag

click node_dashboard "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/tree/main/frontend/src/app/dashboard"
click node_charts "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/frontend/src/components/charts/ChartPanel.tsx"
click node_data_hook "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/frontend/src/hooks/useStockData.ts"
click node_api_client "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/frontend/src/lib/api/client.ts"
click node_api_main "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/main.py"
click node_api_routes "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/app/api/routes.py"
click node_indicators "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/tree/main/backend/indicators"
click node_features "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/feature_engineering/create_features.py"
click node_risk "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/risk/risk_analyzer.py"
click node_regime "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/market_regime/regime_detector.py"
click node_portfolio "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/portfolio/portfolio_advisor.py"
click node_news_fetch "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/data_ingestion/live_news_fetcher.py"
click node_event_nlp "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/tree/main/backend/nlp"
click node_rag "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/rag/time_aware_rag.py"
click node_chat_rag "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/chatbot/rag_engine.py"
click node_predict "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/main.py"
click node_trainer "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/prediction/online_trainer.py"
click node_neural "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/models/neural_models.py"
click node_chatbot "https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/chatbot/chatbot.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_dashboard,node_charts,node_data_hook,node_api_client toneBlue
class node_api_main,node_api_routes toneAmber
class node_indicators,node_features,node_risk,node_regime,node_portfolio toneMint
class node_news_fetch,node_event_nlp,node_rag,node_chat_rag,node_news_store toneRose
class node_predict,node_trainer,node_neural,node_chatbot,node_investor,node_market_data,node_news_sources toneIndigo
```

## Components

### Investor dashboard

- [Dashboard pages](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/tree/main/frontend/src/app/dashboard): `frontend/src/app/dashboard`
- [Charts](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/frontend/src/components/charts/ChartPanel.tsx): `frontend/src/components/charts/ChartPanel.tsx`
- [Stock data hook](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/frontend/src/hooks/useStockData.ts): `frontend/src/hooks/useStockData.ts`
- [API client](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/frontend/src/lib/api/client.ts): `frontend/src/lib/api/client.ts`

### API and orchestration

- [FastAPI app](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/main.py): `backend/main.py`
- [Feature routes](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/app/api/routes.py): `backend/app/api/routes.py`

### Market intelligence

- [Technical indicators](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/tree/main/backend/indicators): `backend/indicators`
- [Feature engineering](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/feature_engineering/create_features.py): `backend/feature_engineering/create_features.py`
- [Risk analysis](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/risk/risk_analyzer.py): `backend/risk/risk_analyzer.py`
- [Market regime](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/market_regime/regime_detector.py): `backend/market_regime/regime_detector.py`
- [Portfolio advice](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/portfolio/portfolio_advisor.py): `backend/portfolio/portfolio_advisor.py`

### News and retrieval

- [Live news ingestion](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/data_ingestion/live_news_fetcher.py): `backend/data_ingestion/live_news_fetcher.py`
- [Event and sentiment NLP](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/tree/main/backend/nlp): `backend/nlp`
- [Time-aware retrieval](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/rag/time_aware_rag.py): `backend/rag/time_aware_rag.py`
- [Chat retrieval](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/chatbot/rag_engine.py): `backend/chatbot/rag_engine.py`
- **News corpus**

### Forecasting

- [Forecast endpoint](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/main.py): `backend/main.py`
- [Online trainer](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/prediction/online_trainer.py): `backend/prediction/online_trainer.py`
- [Neural models](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/models/neural_models.py): `backend/models/neural_models.py`
- [Chat assistant](https://github.com/abhishek-ms-01/stock_market_prediction-with-rag_lstm/blob/main/backend/chatbot/chatbot.py): `backend/chatbot/chatbot.py`

### Other components

- **Investor**
- **Market data provider**
- **News sources**

## Connections

- Investor → Dashboard pages: uses
- Dashboard pages → Charts: renders
- Stock data hook → FastAPI app: fetches stock data
- API client → Feature routes: sends API requests
- Feature routes → Market data provider: downloads prices
- FastAPI app → Market data provider: fetches quotes
- Feature routes → Technical indicators: calculates indicators
- Feature routes → Risk analysis: calculates risk
- Feature routes → Market regime: detects regime
- Feature routes → Portfolio advice: ranks forecasts
- Feature routes → Chat assistant: requests response
- Live news ingestion → News sources: fetches articles
- Live news ingestion → News corpus: produces corpus
- Time-aware retrieval → News corpus: indexes corpus
- Chat retrieval → News corpus: reads corpus
- Investor → API client: requests features
- FastAPI app → Online trainer: trains model
- Online trainer → Market data provider: uses market data
- Forecast endpoint → Neural models: runs inference
- FastAPI app → Forecast endpoint: serves forecast
- Event and sentiment NLP → Time-aware retrieval: enriches retrieval
