# jayantsinghkhanna/ai-finance-analyst architecture

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

- Interactive diagram: https://gitdiagram.com/jayantsinghkhanna/ai-finance-analyst
- Repository: https://github.com/jayantsinghkhanna/ai-finance-analyst

## Overview

Autonomous Finance Analyst turns a natural-language investment query into a dynamically selected set of market, fundamental, technical, news, and risk analyses, then produces a recommendation, written report, and PDF. The supervisor owns the reflection-and-skill loop; LangGraph routes the request through reporting and PDF generation. Shared FinanceState carries inputs and results. The README documents news APIs and the broader analysis capabilities; source excerpts and index references support the implementation links shown. Unsampled subsystem details and unverified external-service calls are not inferred.

Main entry points: [`graph/skill_executor.py`](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/graph/skill_executor.py) (Skill Executor), [`graph/workflow.py`](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/graph/workflow.py) (Graph Workflow), [`tools/yfinance_tool.py`](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/tools/yfinance_tool.py) (yFinance Access), [`agents/router_agent.py`](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/agents/router_agent.py) (Intent Router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Query and Routing"]
  node_cli["Query CLI<br/>[main.py]"]
  node_router["Intent Router<br/>[router_agent.py]"]
  node_router_prompt["Router Prompt<br/>[router_prompt.py]"]
  node_router_schema["Router Schema<br/>[router_schema.py]"]
end

subgraph group_workflow["Workflow and State"]
  node_workflow["Graph Workflow<br/>[workflow.py]"]
  node_supervisor["Finance Supervisor"]
  node_reflection["Reflection Agent"]
  node_reflection_prompt["Reflection Prompt"]
  node_reflection_schema["Reflection Schema"]
  node_executor["Skill Executor<br/>[skill_executor.py]"]
  node_state["FinanceState<br/>[finance_state.py]"]
  node_report_agent["Report Agent<br/>[report_agent.py]"]
  node_report_prompt["Report Prompt<br/>[report_prompt.py]"]
  node_pdf["PDF Generator"]
end

subgraph group_analysis["Analysis Capabilities"]
  node_price["Stock Price"]
  node_metrics["Market Metrics"]
  node_financial["Financial Health"]
  node_technical["Technical Analysis"]
  node_news_fetch["News Fetch"]
  node_sentiment["News Sentiment"]
  node_risk["Risk Analysis"]
  node_investment["Investment Summary"]
end

subgraph group_integrations["Models and Data"]
  node_yfinance_tool["yFinance Access<br/>[yfinance_tool.py]"]
  node_technical_tool["Technical Tool<br/>[technical_tool.py]"]
  node_news_tool["News Tool<br/>[news_tool.py]"]
  node_llm["Gemini LLM<br/>[llm.py]"]
end

node_user(("User"))
node_report_output["Investment Report"]
node_news_api["News APIs"]

node_user -->|"enters query"| node_cli
node_cli -->|"invokes graph"| node_workflow
node_workflow -->|"routes first"| node_router
node_router -->|"formats prompt"| node_router_prompt
node_router -->|"validates output"| node_router_schema
node_router -->|"requests parsing"| node_llm
node_workflow -->|"routes next"| node_supervisor
node_supervisor -->|"reflects"| node_reflection
node_reflection -->|"uses prompt"| node_reflection_prompt
node_reflection -->|"validates decision"| node_reflection_schema
node_reflection -->|"requests reasoning"| node_llm
node_supervisor -->|"executes selection"| node_executor
node_supervisor -->|"updates results"| node_state
node_workflow -->|"uses graph state"| node_state
node_workflow -->|"routes report"| node_report_agent
node_report_agent -->|"generates report"| node_llm
node_report_agent -->|"uses prompt"| node_report_prompt
node_workflow -->|"routes PDF"| node_pdf
node_pdf -->|"writes PDF"| node_report_output
node_executor -->|"dispatches"| node_price
node_executor -->|"dispatches"| node_metrics
node_executor -->|"dispatches"| node_financial
node_executor -->|"dispatches"| node_technical
node_executor -->|"dispatches"| node_news_fetch
node_executor -->|"dispatches"| node_sentiment
node_executor -->|"dispatches"| node_risk
node_executor -->|"dispatches"| node_investment
node_price -->|"reads prices"| node_yfinance_tool
node_metrics -->|"reads metrics"| node_yfinance_tool
node_financial -->|"reads fundamentals"| node_yfinance_tool
node_technical -->|"reads history"| node_yfinance_tool
node_technical -->|"uses calculations"| node_technical_tool
node_news_fetch -->|"fetches articles"| node_news_tool
node_news_tool -.->|"retrieves news"| node_news_api
node_sentiment -->|"classifies sentiment"| node_llm
node_risk -->|"reads risk data"| node_yfinance_tool

click node_cli "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/main.py"
click node_router "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/agents/router_agent.py"
click node_router_prompt "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/prompts/router_prompt.py"
click node_router_schema "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/schemas/router_schema.py"
click node_workflow "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/graph/workflow.py"
click node_supervisor "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/agents/finance_supervisor_agent.py"
click node_reflection "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/agents/reflection_agent.py"
click node_reflection_prompt "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/prompts/reflection_prompt.py"
click node_reflection_schema "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/schemas/reflection_schema.py"
click node_executor "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/graph/skill_executor.py"
click node_state "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/state/finance_state.py"
click node_report_agent "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/agents/report_agent.py"
click node_report_prompt "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/prompts/report_prompt.py"
click node_pdf "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/skills/pdf_report_skill.py"
click node_price "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/skills/stock_price_skill.py"
click node_metrics "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/skills/market_metrics_skill.py"
click node_financial "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/skills/financial_health_skill.py"
click node_technical "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/skills/technical_analysis_skill.py"
click node_news_fetch "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/skills/news_fetch_skill.py"
click node_sentiment "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/skills/news_sentiment_skill.py"
click node_risk "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/skills/risk_analysis_skill.py"
click node_investment "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/skills/investment_summary_skill.py"
click node_yfinance_tool "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/tools/yfinance_tool.py"
click node_technical_tool "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/tools/technical_tool.py"
click node_news_tool "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/tools/news_tool.py"
click node_llm "https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/llm.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_router,node_router_prompt,node_router_schema,node_user toneBlue
class node_workflow,node_supervisor,node_reflection,node_reflection_prompt,node_reflection_schema,node_executor,node_state,node_report_agent,node_report_prompt,node_pdf toneAmber
class node_price,node_metrics,node_financial,node_technical,node_news_fetch,node_sentiment,node_risk,node_investment,node_news_api toneMint
class node_yfinance_tool,node_technical_tool,node_news_tool,node_llm toneRose
class node_report_output toneIndigo
```

## Components

### Query and Routing

- [Query CLI](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/main.py): `main.py`
- [Intent Router](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/agents/router_agent.py): `agents/router_agent.py`
- [Router Prompt](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/prompts/router_prompt.py): `prompts/router_prompt.py`
- [Router Schema](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/schemas/router_schema.py): `schemas/router_schema.py`

### Workflow and State

- [Graph Workflow](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/graph/workflow.py): `graph/workflow.py`
- [Finance Supervisor](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/agents/finance_supervisor_agent.py): `agents/finance_supervisor_agent.py`
- [Reflection Agent](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/agents/reflection_agent.py): `agents/reflection_agent.py`
- [Reflection Prompt](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/prompts/reflection_prompt.py): `prompts/reflection_prompt.py`
- [Reflection Schema](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/schemas/reflection_schema.py): `schemas/reflection_schema.py`
- [Skill Executor](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/graph/skill_executor.py): `graph/skill_executor.py`
- [FinanceState](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/state/finance_state.py): `state/finance_state.py`
- [Report Agent](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/agents/report_agent.py): `agents/report_agent.py`
- [Report Prompt](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/prompts/report_prompt.py): `prompts/report_prompt.py`
- [PDF Generator](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/skills/pdf_report_skill.py): `skills/pdf_report_skill.py`

### Analysis Capabilities

- [Stock Price](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/skills/stock_price_skill.py): `skills/stock_price_skill.py`
- [Market Metrics](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/skills/market_metrics_skill.py): `skills/market_metrics_skill.py`
- [Financial Health](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/skills/financial_health_skill.py): `skills/financial_health_skill.py`
- [Technical Analysis](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/skills/technical_analysis_skill.py): `skills/technical_analysis_skill.py`
- [News Fetch](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/skills/news_fetch_skill.py): `skills/news_fetch_skill.py`
- [News Sentiment](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/skills/news_sentiment_skill.py): `skills/news_sentiment_skill.py`
- [Risk Analysis](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/skills/risk_analysis_skill.py): `skills/risk_analysis_skill.py`
- [Investment Summary](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/skills/investment_summary_skill.py): `skills/investment_summary_skill.py`

### Models and Data

- [yFinance Access](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/tools/yfinance_tool.py): `tools/yfinance_tool.py`
- [Technical Tool](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/tools/technical_tool.py): `tools/technical_tool.py`
- [News Tool](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/tools/news_tool.py): `tools/news_tool.py`
- [Gemini LLM](https://github.com/jayantsinghkhanna/ai-finance-analyst/blob/main/llm.py): `llm.py`

### Other components

- **User**
- **Investment Report**
- **News APIs**

## Connections

- User → Query CLI: enters query (evidence: `README.md`)
- Query CLI → Graph Workflow: invokes graph (evidence: `main.py`)
- Graph Workflow → Intent Router: routes first (evidence: `graph/workflow.py`)
- Intent Router → Router Prompt: formats prompt (evidence: `agents/router_agent.py`)
- Intent Router → Router Schema: validates output (evidence: `agents/router_agent.py`)
- Intent Router → Gemini LLM: requests parsing (evidence: `agents/router_agent.py`)
- Graph Workflow → Finance Supervisor: routes next (evidence: `graph/workflow.py`)
- Finance Supervisor → Reflection Agent: reflects (evidence: `agents/finance_supervisor_agent.py`)
- Reflection Agent → Reflection Prompt: uses prompt (evidence: `agents/reflection_agent.py`)
- Reflection Agent → Reflection Schema: validates decision (evidence: `agents/reflection_agent.py`)
- Reflection Agent → Gemini LLM: requests reasoning (evidence: `agents/reflection_agent.py`)
- Finance Supervisor → Skill Executor: executes selection (evidence: `agents/finance_supervisor_agent.py`)
- Finance Supervisor → FinanceState: updates results (evidence: `README.md`)
- Graph Workflow → FinanceState: uses graph state (evidence: `graph/workflow.py`)
- Graph Workflow → Report Agent: routes report (evidence: `graph/workflow.py`)
- Report Agent → Gemini LLM: generates report (evidence: `agents/report_agent.py`)
- Report Agent → Report Prompt: uses prompt (evidence: `README.md`)
- Graph Workflow → PDF Generator: routes PDF (evidence: `graph/workflow.py`)
- PDF Generator → Investment Report: writes PDF (evidence: `skills/pdf_report_skill.py`)
- Skill Executor → Stock Price: dispatches (evidence: `graph/skill_executor.py`)
- Skill Executor → Market Metrics: dispatches (evidence: `graph/skill_executor.py`)
- Skill Executor → Financial Health: dispatches (evidence: `graph/skill_executor.py`)
- Skill Executor → Technical Analysis: dispatches (evidence: `graph/skill_executor.py`)
- Skill Executor → News Fetch: dispatches (evidence: `graph/skill_executor.py`)
- Skill Executor → News Sentiment: dispatches (evidence: `graph/skill_executor.py`)
- Skill Executor → Risk Analysis: dispatches (evidence: `graph/skill_executor.py`)
- Skill Executor → Investment Summary: dispatches (evidence: `graph/skill_executor.py`)
- Stock Price → yFinance Access: reads prices (evidence: `skills/stock_price_skill.py`)
- Market Metrics → yFinance Access: reads metrics (evidence: `skills/market_metrics_skill.py`)
- Financial Health → yFinance Access: reads fundamentals (evidence: `skills/financial_health_skill.py`)
- Technical Analysis → yFinance Access: reads history (evidence: `skills/technical_analysis_skill.py`)
- Technical Analysis → Technical Tool: uses calculations (evidence: `skills/technical_analysis_skill.py`)
- News Fetch → News Tool: fetches articles (evidence: `skills/news_fetch_skill.py`)
- News Tool → News APIs: retrieves news (evidence: `README.md`)
- News Sentiment → Gemini LLM: classifies sentiment (evidence: `skills/news_sentiment_skill.py`)
- Risk Analysis → yFinance Access: reads risk data (evidence: `skills/risk_analysis_skill.py`)
