# yashchavan05/investiq architecture

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

- Interactive diagram: https://gitdiagram.com/yashchavan05/investiq
- Repository: https://github.com/yashchavan05/investiq

## Overview

InvestIQ turns a user's tickers, budget, and risk limit into a persisted portfolio analysis. The main path runs from the allocator UI through the REST API and LangGraph orchestrator, which coordinates risk, forecasting, market knowledge, fundamentals, ESG, historical learning, optimization, budgeting, XAI, LLM narration, and persistence. Separate product branches support market data, news, single-agent runs, chat, dashboards, and analysis history. The orchestrator's calls are evidenced by the source index and excerpts; additional stage ordering and some UI-to-endpoint links are documented in the README or remain unverified.

Main entry points: [`backend/agents/investiq_agent.py`](https://github.com/yashchavan05/investiq/blob/main/backend/agents/investiq_agent.py) (Analysis orchestrator), [`backend/main.py`](https://github.com/yashchavan05/investiq/blob/main/backend/main.py) (REST API), [`frontend/src/services/api.js`](https://github.com/yashchavan05/investiq/blob/main/frontend/src/services/api.js) (API client), [`backend/agents/tools/memory_tool.py`](https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/memory_tool.py) (Run persistence)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Investor interface"]
  node_allocator_ui["Portfolio allocator<br/>[AIAllocator.jsx]"]
  node_agent_lab["Agent lab<br/>[Agents.jsx]"]
  node_assistant_ui["AI assistant<br/>[AIAssistant.jsx]"]
  node_markets_ui["Markets terminal<br/>[Markets.jsx]"]
  node_history_ui["History explorer<br/>[History.jsx]"]
  node_dashboard_ui["Dashboard<br/>[Dashboard.jsx]"]
end

subgraph group_api["API and market access"]
  node_api_client["API client<br/>[api.js]"]
  node_backend_api["REST API<br/>[main.py]"]
  node_market_data["Market data endpoints<br/>[main.py]"]
  node_news_api["News endpoint<br/>[main.py]"]
  node_history_endpoint["History endpoint<br/>[main.py]"]
  node_chat_endpoint["Chat endpoint<br/>[main.py]"]
end

subgraph group_analysis["Portfolio intelligence"]
  node_orchestrator["Analysis orchestrator<br/>[investiq_agent.py]"]
  node_risk["Risk analysis<br/>[risk_tool.py]"]
  node_forecast["Market forecasting<br/>[forecast_tool.py]"]
  node_news["Market news sentiment<br/>[news_tool.py]"]
  node_fundamentals["Finance audit<br/>[finance_tool.py]"]
  node_esg["ESG assessment"]
  node_optimizer["Portfolio optimizer"]
  node_budget["Capital allocation<br/>[budget_tool.py]"]
  node_xai["ROI attribution<br/>[xai_tool.py]"]
end

subgraph group_memory["Learning and persistence"]
  node_learning["Historical learning<br/>[learning_tool.py]"]
  node_persistence["Run persistence<br/>[memory_tool.py]"]
  node_mongo[("MongoDB<br/>[db_config.py]")]
end

node_investor(("Investor"))
node_market_service["Market data service"]
node_news_service["News service"]
node_llm["Groq Llama model"]

node_investor -.->|"sets inputs"| node_allocator_ui
node_allocator_ui -->|"submits analysis"| node_api_client
node_api_client -->|"posts analysis"| node_backend_api
node_backend_api -->|"runs workflow"| node_orchestrator
node_orchestrator -->|"calculates risk"| node_risk
node_orchestrator -->|"forecasts returns"| node_forecast
node_orchestrator -->|"gets sentiment"| node_news
node_orchestrator -->|"audits finances"| node_fundamentals
node_orchestrator -->|"assesses ESG"| node_esg
node_orchestrator -->|"loads adjustment"| node_learning
node_orchestrator -->|"optimizes weights"| node_optimizer
node_orchestrator -->|"allocates capital"| node_budget
node_orchestrator -->|"explains allocation"| node_xai
node_orchestrator -->|"saves run"| node_persistence
node_orchestrator -.->|"generates narration"| node_llm
node_learning -->|"reads prior runs"| node_persistence
node_persistence -->|"reads and writes"| node_mongo
node_backend_api -->|"serves quotes"| node_market_data
node_market_data -->|"fetches prices"| node_market_service
node_backend_api -->|"serves headlines"| node_news_api
node_news_api -->|"fetches articles"| node_news_service
node_backend_api -->|"serves history"| node_history_endpoint
node_history_endpoint -->|"queries records"| node_mongo
node_backend_api -->|"serves chat"| node_chat_endpoint
node_chat_endpoint -->|"runs casual chat"| node_orchestrator
node_chat_endpoint -.->|"requests response"| node_llm
node_agent_lab -.->|"runs agent"| node_backend_api
node_assistant_ui -.->|"requests chat"| node_api_client
node_markets_ui -.->|"requests market data"| node_api_client
node_history_ui -.->|"requests history"| node_api_client
node_dashboard_ui -.->|"requests metrics"| node_api_client

click node_allocator_ui "https://github.com/yashchavan05/investiq/blob/main/frontend/src/pages/AIAllocator.jsx"
click node_agent_lab "https://github.com/yashchavan05/investiq/blob/main/frontend/src/pages/Agents.jsx"
click node_assistant_ui "https://github.com/yashchavan05/investiq/blob/main/frontend/src/pages/AIAssistant.jsx"
click node_markets_ui "https://github.com/yashchavan05/investiq/blob/main/frontend/src/pages/Markets.jsx"
click node_history_ui "https://github.com/yashchavan05/investiq/blob/main/frontend/src/pages/History.jsx"
click node_dashboard_ui "https://github.com/yashchavan05/investiq/blob/main/frontend/src/pages/Dashboard.jsx"
click node_api_client "https://github.com/yashchavan05/investiq/blob/main/frontend/src/services/api.js"
click node_backend_api "https://github.com/yashchavan05/investiq/blob/main/backend/main.py"
click node_orchestrator "https://github.com/yashchavan05/investiq/blob/main/backend/agents/investiq_agent.py"
click node_risk "https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/risk_tool.py"
click node_forecast "https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/forecast_tool.py"
click node_news "https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/news_tool.py"
click node_fundamentals "https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/finance_tool.py"
click node_esg "https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/sustainability_tool.py"
click node_optimizer "https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/optimization_tool.py"
click node_budget "https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/budget_tool.py"
click node_xai "https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/xai_tool.py"
click node_learning "https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/learning_tool.py"
click node_persistence "https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/memory_tool.py"
click node_mongo "https://github.com/yashchavan05/investiq/blob/main/backend/agents/db_config.py"
click node_market_data "https://github.com/yashchavan05/investiq/blob/main/backend/main.py"
click node_news_api "https://github.com/yashchavan05/investiq/blob/main/backend/main.py"
click node_history_endpoint "https://github.com/yashchavan05/investiq/blob/main/backend/main.py"
click node_chat_endpoint "https://github.com/yashchavan05/investiq/blob/main/backend/main.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_allocator_ui,node_agent_lab,node_assistant_ui,node_markets_ui,node_history_ui,node_dashboard_ui toneBlue
class node_api_client,node_backend_api,node_market_data,node_news_api,node_history_endpoint,node_chat_endpoint toneAmber
class node_orchestrator,node_risk,node_forecast,node_news,node_fundamentals,node_esg,node_optimizer,node_budget,node_xai toneMint
class node_learning,node_persistence,node_mongo toneRose
class node_investor,node_market_service,node_news_service,node_llm toneIndigo
```

## Components

### Investor interface

- [Portfolio allocator](https://github.com/yashchavan05/investiq/blob/main/frontend/src/pages/AIAllocator.jsx): `frontend/src/pages/AIAllocator.jsx`
- [Agent lab](https://github.com/yashchavan05/investiq/blob/main/frontend/src/pages/Agents.jsx): `frontend/src/pages/Agents.jsx`
- [AI assistant](https://github.com/yashchavan05/investiq/blob/main/frontend/src/pages/AIAssistant.jsx): `frontend/src/pages/AIAssistant.jsx`
- [Markets terminal](https://github.com/yashchavan05/investiq/blob/main/frontend/src/pages/Markets.jsx): `frontend/src/pages/Markets.jsx`
- [History explorer](https://github.com/yashchavan05/investiq/blob/main/frontend/src/pages/History.jsx): `frontend/src/pages/History.jsx`
- [Dashboard](https://github.com/yashchavan05/investiq/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`

### API and market access

- [API client](https://github.com/yashchavan05/investiq/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [REST API](https://github.com/yashchavan05/investiq/blob/main/backend/main.py): `backend/main.py`
- [Market data endpoints](https://github.com/yashchavan05/investiq/blob/main/backend/main.py): `backend/main.py`
- [News endpoint](https://github.com/yashchavan05/investiq/blob/main/backend/main.py): `backend/main.py`
- [History endpoint](https://github.com/yashchavan05/investiq/blob/main/backend/main.py): `backend/main.py`
- [Chat endpoint](https://github.com/yashchavan05/investiq/blob/main/backend/main.py): `backend/main.py`

### Portfolio intelligence

- [Analysis orchestrator](https://github.com/yashchavan05/investiq/blob/main/backend/agents/investiq_agent.py): `backend/agents/investiq_agent.py`
- [Risk analysis](https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/risk_tool.py): `backend/agents/tools/risk_tool.py`
- [Market forecasting](https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/forecast_tool.py): `backend/agents/tools/forecast_tool.py`
- [Market news sentiment](https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/news_tool.py): `backend/agents/tools/news_tool.py`
- [Finance audit](https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/finance_tool.py): `backend/agents/tools/finance_tool.py`
- [ESG assessment](https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/sustainability_tool.py): `backend/agents/tools/sustainability_tool.py`
- [Portfolio optimizer](https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/optimization_tool.py): `backend/agents/tools/optimization_tool.py`
- [Capital allocation](https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/budget_tool.py): `backend/agents/tools/budget_tool.py`
- [ROI attribution](https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/xai_tool.py): `backend/agents/tools/xai_tool.py`

### Learning and persistence

- [Historical learning](https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/learning_tool.py): `backend/agents/tools/learning_tool.py`
- [Run persistence](https://github.com/yashchavan05/investiq/blob/main/backend/agents/tools/memory_tool.py): `backend/agents/tools/memory_tool.py`
- [MongoDB](https://github.com/yashchavan05/investiq/blob/main/backend/agents/db_config.py): `backend/agents/db_config.py`

### Other components

- **Investor**
- **Market data service**
- **News service**
- **Groq Llama model**

## Connections

- Investor → Portfolio allocator: sets inputs
- Portfolio allocator → API client: submits analysis (evidence: `frontend/src/pages/AIAllocator.jsx`)
- API client → REST API: posts analysis (evidence: `frontend/src/services/api.js`)
- REST API → Analysis orchestrator: runs workflow (evidence: `backend/main.py`)
- Analysis orchestrator → Risk analysis: calculates risk (evidence: `backend/agents/investiq_agent.py`)
- Analysis orchestrator → Market forecasting: forecasts returns (evidence: `backend/agents/investiq_agent.py`)
- Analysis orchestrator → Market news sentiment: gets sentiment (evidence: `backend/agents/investiq_agent.py`)
- Analysis orchestrator → Finance audit: audits finances (evidence: `backend/agents/investiq_agent.py`)
- Analysis orchestrator → ESG assessment: assesses ESG (evidence: `backend/agents/investiq_agent.py`)
- Analysis orchestrator → Historical learning: loads adjustment (evidence: `backend/agents/investiq_agent.py`)
- Analysis orchestrator → Portfolio optimizer: optimizes weights (evidence: `backend/agents/investiq_agent.py`)
- Analysis orchestrator → Capital allocation: allocates capital (evidence: `backend/agents/investiq_agent.py`)
- Analysis orchestrator → ROI attribution: explains allocation (evidence: `backend/agents/investiq_agent.py`)
- Analysis orchestrator → Run persistence: saves run (evidence: `backend/agents/investiq_agent.py`)
- Analysis orchestrator → Groq Llama model: generates narration
- Historical learning → Run persistence: reads prior runs (evidence: `backend/agents/tools/learning_tool.py`)
- Run persistence → MongoDB: reads and writes (evidence: `backend/agents/tools/memory_tool.py`)
- REST API → Market data endpoints: serves quotes (evidence: `backend/main.py`)
- Market data endpoints → Market data service: fetches prices (evidence: `backend/main.py`)
- REST API → News endpoint: serves headlines (evidence: `backend/main.py`)
- News endpoint → News service: fetches articles (evidence: `backend/main.py`)
- REST API → History endpoint: serves history (evidence: `backend/main.py`)
- History endpoint → MongoDB: queries records (evidence: `backend/main.py`)
- REST API → Chat endpoint: serves chat (evidence: `backend/main.py`)
- Chat endpoint → Analysis orchestrator: runs casual chat (evidence: `backend/main.py`)
- Chat endpoint → Groq Llama model: requests response
- Agent lab → REST API: runs agent
- AI assistant → API client: requests chat
- Markets terminal → API client: requests market data (evidence: `frontend/src/pages/Markets.jsx`)
- History explorer → API client: requests history (evidence: `frontend/src/pages/History.jsx`)
- Dashboard → API client: requests metrics (evidence: `frontend/src/pages/Dashboard.jsx`)
