# shivanshu24-code/stocklite architecture

> Architecture diagram of the GitHub repository shivanshu24-code/stocklite, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shivanshu24-code/stocklite
- Repository: https://github.com/shivanshu24-code/stocklite

## Overview

StockLite combines a React stock-intelligence dashboard, a Node API, and a Python AI service. The main analysis path resolves a stock, obtains market data, computes a technical recommendation, gathers news context, and returns an AI explanation; the Opportunity Engine separately ranks candidates. Portfolio analysis and authentication are additional product branches. Some links are supported only by README descriptions or the SOURCE INDEX; unsampled internals are not inferred beyond those references.

Main entry points: [`AI service/app.py`](https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/app.py) (AI service API), [`Backend/Portfolio/Controller/PortfolioAnalysis.controller.js`](https://github.com/shivanshu24-code/stocklite/blob/main/Backend/Portfolio/Controller/PortfolioAnalysis.controller.js) (Portfolio analysis controller), [`Frontend/src/Pages/DashboardPage.jsx`](https://github.com/shivanshu24-code/stocklite/blob/main/Frontend/src/Pages/DashboardPage.jsx) (Dashboard), [`AI service/Rag_pipeline/Services/rag_service.py`](https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Rag_pipeline/Services/rag_service.py) (RAG retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_dashboard["Dashboard<br/>[DashboardPage.jsx]"]
  node_chat["AI chat<br/>[AiChatView.jsx]"]
  node_auth_ui["Login and signup<br/>[LoginPage.jsx]"]
end

subgraph group_backend["Backend API"]
  node_auth_api["User authentication<br/>[User.controller.js]"]
  node_user_store[("User records<br/>[User.model.js]")]
  node_opportunity_routes["Opportunity routes"]
  node_opportunity_controller["Opportunity controller"]
  node_opportunity_service["Opportunity ranking"]
end

subgraph group_ai["AI analysis"]
  node_ai_api["AI service API<br/>[app.py]"]
  node_stock_data["Stock data service<br/>[stock_service.py]"]
  node_top_stocks["Top stocks<br/>[top_stock.py]"]
  node_indicators["Technical indicators"]
  node_decision["Trade decision<br/>[decision_engine.py]"]
end

subgraph group_rag["News intelligence"]
  node_news_fetch["News fetching<br/>[news_service.py]"]
  node_chunking["News chunking<br/>[chunking.py]"]
  node_resolver["Company resolver"]
  node_rag_service["RAG retrieval<br/>[rag_service.py]"]
  node_embedding["Embeddings"]
  node_vector_db[("Chroma store<br/>[chroma_client.py]")]
  node_llm["Explanation generation<br/>[llm_service.py]"]
end

subgraph group_portfolio["Portfolio"]
  node_portfolio_routes["Portfolio routes"]
  node_portfolio_analysis["Portfolio analysis controller"]
  node_portfolio_model[("Portfolio records<br/>[Portfolio.js]")]
  node_snapshot["Portfolio snapshot"]
  node_portfolio_decision["Portfolio decisions<br/>[decision.engine.js]"]
end

node_investor(("Investor"))
node_market_api["Market and news providers"]

node_investor -->|"uses"| node_dashboard
node_investor -->|"signs in"| node_auth_ui
node_dashboard -.->|"opens"| node_chat
node_auth_ui -.->|"authenticates"| node_auth_api
node_auth_api -->|"reads and writes"| node_user_store
node_dashboard -.->|"requests opportunities"| node_opportunity_routes
node_opportunity_routes -->|"routes to"| node_opportunity_controller
node_opportunity_controller -->|"requests rankings"| node_opportunity_service
node_chat -->|"sends query"| node_ai_api
node_ai_api -->|"fetches data"| node_stock_data
node_ai_api -->|"requests candidates"| node_top_stocks
node_ai_api -->|"calculates signal"| node_decision
node_ai_api -->|"gets context"| node_rag_service
node_ai_api -->|"fetches news"| node_news_fetch
node_ai_api -->|"chunks news"| node_chunking
node_ai_api -->|"generates explanation"| node_llm
node_market_api -.->|"provides prices"| node_stock_data
node_market_api -->|"provides news"| node_news_fetch
node_news_fetch -->|"resolves company"| node_resolver
node_rag_service -->|"embeds text"| node_embedding
node_rag_service -->|"stores and retrieves"| node_vector_db
node_portfolio_routes -->|"routes to"| node_portfolio_analysis
node_portfolio_analysis -->|"loads portfolio"| node_portfolio_model
node_portfolio_analysis -->|"builds snapshot"| node_snapshot
node_portfolio_analysis -->|"analyzes holdings"| node_portfolio_decision

click node_dashboard "https://github.com/shivanshu24-code/stocklite/blob/main/Frontend/src/Pages/DashboardPage.jsx"
click node_chat "https://github.com/shivanshu24-code/stocklite/blob/main/Frontend/src/Components/Dashboard/AiChatView.jsx"
click node_auth_ui "https://github.com/shivanshu24-code/stocklite/blob/main/Frontend/src/Pages/LoginPage.jsx"
click node_auth_api "https://github.com/shivanshu24-code/stocklite/blob/main/Backend/User/User.controller.js"
click node_user_store "https://github.com/shivanshu24-code/stocklite/blob/main/Backend/User/User.model.js"
click node_opportunity_routes "https://github.com/shivanshu24-code/stocklite/blob/main/Backend/OpportunityEngine/Routes/opportunity.routes.js"
click node_opportunity_controller "https://github.com/shivanshu24-code/stocklite/blob/main/Backend/OpportunityEngine/Controllers/opportunity.controllers.js"
click node_opportunity_service "https://github.com/shivanshu24-code/stocklite/blob/main/Backend/OpportunityEngine/Services/opportunity.services.js"
click node_ai_api "https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/app.py"
click node_stock_data "https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Services/stock_service.py"
click node_top_stocks "https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Services/top_stock.py"
click node_indicators "https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Indicators/technical_indicators.py"
click node_decision "https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Models/decision_engine.py"
click node_news_fetch "https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Rag_pipeline/Services/news_service.py"
click node_chunking "https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Rag_pipeline/Utils/chunking.py"
click node_resolver "https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Rag_pipeline/Utils/company_resolver.py"
click node_rag_service "https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Rag_pipeline/Services/rag_service.py"
click node_embedding "https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Rag_pipeline/Services/embedding_service.py"
click node_vector_db "https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Rag_pipeline/Db/chroma_client.py"
click node_llm "https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Rag_pipeline/Services/llm_service.py"
click node_portfolio_routes "https://github.com/shivanshu24-code/stocklite/blob/main/Backend/Portfolio/Routes/Portfolio.routes.js"
click node_portfolio_analysis "https://github.com/shivanshu24-code/stocklite/blob/main/Backend/Portfolio/Controller/PortfolioAnalysis.controller.js"
click node_portfolio_model "https://github.com/shivanshu24-code/stocklite/blob/main/Backend/Portfolio/Models/Portfolio.js"
click node_snapshot "https://github.com/shivanshu24-code/stocklite/blob/main/Backend/Portfolio/Services/portfolioSnapshot.service.js"
click node_portfolio_decision "https://github.com/shivanshu24-code/stocklite/blob/main/Backend/Portfolio/DecisionEngine/decision.engine.js"

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_chat,node_auth_ui toneBlue
class node_auth_api,node_user_store,node_opportunity_routes,node_opportunity_controller,node_opportunity_service toneAmber
class node_ai_api,node_stock_data,node_top_stocks,node_indicators,node_decision toneMint
class node_news_fetch,node_chunking,node_resolver,node_rag_service,node_embedding,node_vector_db,node_llm toneRose
class node_portfolio_routes,node_portfolio_analysis,node_portfolio_model,node_snapshot,node_portfolio_decision,node_investor,node_market_api toneIndigo
```

## Components

### Client

- [Dashboard](https://github.com/shivanshu24-code/stocklite/blob/main/Frontend/src/Pages/DashboardPage.jsx): `Frontend/src/Pages/DashboardPage.jsx`
- [AI chat](https://github.com/shivanshu24-code/stocklite/blob/main/Frontend/src/Components/Dashboard/AiChatView.jsx): `Frontend/src/Components/Dashboard/AiChatView.jsx`
- [Login and signup](https://github.com/shivanshu24-code/stocklite/blob/main/Frontend/src/Pages/LoginPage.jsx): `Frontend/src/Pages/LoginPage.jsx`

### Backend API

- [User authentication](https://github.com/shivanshu24-code/stocklite/blob/main/Backend/User/User.controller.js): `Backend/User/User.controller.js`
- [User records](https://github.com/shivanshu24-code/stocklite/blob/main/Backend/User/User.model.js): `Backend/User/User.model.js`
- [Opportunity routes](https://github.com/shivanshu24-code/stocklite/blob/main/Backend/OpportunityEngine/Routes/opportunity.routes.js): `Backend/OpportunityEngine/Routes/opportunity.routes.js`
- [Opportunity controller](https://github.com/shivanshu24-code/stocklite/blob/main/Backend/OpportunityEngine/Controllers/opportunity.controllers.js): `Backend/OpportunityEngine/Controllers/opportunity.controllers.js`
- [Opportunity ranking](https://github.com/shivanshu24-code/stocklite/blob/main/Backend/OpportunityEngine/Services/opportunity.services.js): `Backend/OpportunityEngine/Services/opportunity.services.js`

### AI analysis

- [AI service API](https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/app.py): `AI service/app.py`
- [Stock data service](https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Services/stock_service.py): `AI service/Services/stock_service.py`
- [Top stocks](https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Services/top_stock.py): `AI service/Services/top_stock.py`
- [Technical indicators](https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Indicators/technical_indicators.py): `AI service/Indicators/technical_indicators.py`
- [Trade decision](https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Models/decision_engine.py): `AI service/Models/decision_engine.py`

### News intelligence

- [News fetching](https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Rag_pipeline/Services/news_service.py): `AI service/Rag_pipeline/Services/news_service.py`
- [News chunking](https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Rag_pipeline/Utils/chunking.py): `AI service/Rag_pipeline/Utils/chunking.py`
- [Company resolver](https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Rag_pipeline/Utils/company_resolver.py): `AI service/Rag_pipeline/Utils/company_resolver.py`
- [RAG retrieval](https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Rag_pipeline/Services/rag_service.py): `AI service/Rag_pipeline/Services/rag_service.py`
- [Embeddings](https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Rag_pipeline/Services/embedding_service.py): `AI service/Rag_pipeline/Services/embedding_service.py`
- [Chroma store](https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Rag_pipeline/Db/chroma_client.py): `AI service/Rag_pipeline/Db/chroma_client.py`
- [Explanation generation](https://github.com/shivanshu24-code/stocklite/blob/main/AI%20service/Rag_pipeline/Services/llm_service.py): `AI service/Rag_pipeline/Services/llm_service.py`

### Portfolio

- [Portfolio routes](https://github.com/shivanshu24-code/stocklite/blob/main/Backend/Portfolio/Routes/Portfolio.routes.js): `Backend/Portfolio/Routes/Portfolio.routes.js`
- [Portfolio analysis controller](https://github.com/shivanshu24-code/stocklite/blob/main/Backend/Portfolio/Controller/PortfolioAnalysis.controller.js): `Backend/Portfolio/Controller/PortfolioAnalysis.controller.js`
- [Portfolio records](https://github.com/shivanshu24-code/stocklite/blob/main/Backend/Portfolio/Models/Portfolio.js): `Backend/Portfolio/Models/Portfolio.js`
- [Portfolio snapshot](https://github.com/shivanshu24-code/stocklite/blob/main/Backend/Portfolio/Services/portfolioSnapshot.service.js): `Backend/Portfolio/Services/portfolioSnapshot.service.js`
- [Portfolio decisions](https://github.com/shivanshu24-code/stocklite/blob/main/Backend/Portfolio/DecisionEngine/decision.engine.js): `Backend/Portfolio/DecisionEngine/decision.engine.js`

### Other components

- **Investor**
- **Market and news providers**

## Connections

- Investor → Dashboard: uses (evidence: `README.md`)
- Investor → Login and signup: signs in (evidence: `README.md`)
- Dashboard → AI chat: opens
- Login and signup → User authentication: authenticates
- User authentication → User records: reads and writes (evidence: `Backend/User/User.controller.js`)
- Dashboard → Opportunity routes: requests opportunities
- Opportunity routes → Opportunity controller: routes to (evidence: `Backend/OpportunityEngine/Routes/opportunity.routes.js`)
- Opportunity controller → Opportunity ranking: requests rankings (evidence: `Backend/OpportunityEngine/Controllers/opportunity.controllers.js`)
- AI chat → AI service API: sends query (evidence: `README.md`)
- AI service API → Stock data service: fetches data (evidence: `AI service/app.py`)
- AI service API → Top stocks: requests candidates (evidence: `AI service/app.py`)
- AI service API → Trade decision: calculates signal (evidence: `AI service/app.py`)
- AI service API → RAG retrieval: gets context (evidence: `AI service/app.py`)
- AI service API → News fetching: fetches news (evidence: `AI service/app.py`)
- AI service API → News chunking: chunks news (evidence: `AI service/app.py`)
- AI service API → Explanation generation: generates explanation (evidence: `AI service/app.py`)
- Market and news providers → Stock data service: provides prices
- Market and news providers → News fetching: provides news (evidence: `README.md`)
- News fetching → Company resolver: resolves company (evidence: `AI service/Rag_pipeline/Services/news_service.py`)
- RAG retrieval → Embeddings: embeds text (evidence: `AI service/Rag_pipeline/Services/rag_service.py`)
- RAG retrieval → Chroma store: stores and retrieves (evidence: `AI service/Rag_pipeline/Services/rag_service.py`)
- Portfolio routes → Portfolio analysis controller: routes to (evidence: `Backend/Portfolio/Routes/Portfolio.routes.js`)
- Portfolio analysis controller → Portfolio records: loads portfolio (evidence: `Backend/Portfolio/Controller/PortfolioAnalysis.controller.js`)
- Portfolio analysis controller → Portfolio snapshot: builds snapshot (evidence: `Backend/Portfolio/Controller/PortfolioAnalysis.controller.js`)
- Portfolio analysis controller → Portfolio decisions: analyzes holdings (evidence: `Backend/Portfolio/Controller/PortfolioAnalysis.controller.js`)
