# dhiraj455/airesearch_agent architecture

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

- Interactive diagram: https://gitdiagram.com/dhiraj455/airesearch_agent
- Repository: https://github.com/dhiraj455/airesearch_agent

## Overview

AI Research Agent accepts a research question through a chat interface, runs a staged web-research workflow, and returns a cited Markdown report; chats also support report-grounded follow-ups and PDF downloads. The backend coordinates LangGraph stages, Gemini calls, search and document retrieval, while Redis caches run and chat state. The frontend provides chat, report, and research-progress views. Workflow edges are grounded in the shown graph and node code; frontend-to-backend communication is documented in the README. Other capabilities are represented where documented, without inferring unsampled implementation details.

Main entry points: [`src/agent/graph.py`](https://github.com/dhiraj455/airesearch_agent/blob/master/src/agent/graph.py) (Research graph), [`frontend/components/ChatView.tsx`](https://github.com/dhiraj455/airesearch_agent/blob/master/frontend/components/ChatView.tsx) (Chat view), [`src/app.py`](https://github.com/dhiraj455/airesearch_agent/blob/master/src/app.py) (HTTP API), [`src/agent/utils.py`](https://github.com/dhiraj455/airesearch_agent/blob/master/src/agent/utils.py) (Gemini model access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Chat interface"]
  node_page["App page<br/>[page.tsx]"]
  node_chatview["Chat view<br/>[ChatView.tsx]"]
  node_chatinput["Chat input<br/>[ChatInput.tsx]"]
  node_message["Message display<br/>[MessageBubble.tsx]"]
  node_researchoverlay["Research progress"]
  node_sidebar["Chat sidebar<br/>[Sidebar.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["API and chat"]
  node_fastapi["HTTP API<br/>[app.py]"]
  node_chat_service["Follow-up answers<br/>[chat_service.py]"]
end

subgraph group_research["Research workflow"]
  node_workflow["Research graph<br/>[graph.py]"]
  node_planning["Research planning<br/>[nodes.py]"]
  node_search["Web search<br/>[search.py]"]
  node_fetch["Web fetching<br/>[fetch.py]"]
  node_pdf_fetch["PDF extraction<br/>[pdf.py]"]
  node_evidence["Evidence and coverage<br/>[nodes.py]"]
  node_report["Report and verification<br/>[nodes.py]"]
  node_prompts["Research prompts<br/>[prompt.py]"]
  node_llm["Gemini model access<br/>[utils.py]"]
end

subgraph group_data["State and evidence"]
  node_runstate["Run and chat models<br/>[schemes.py]"]
  node_redis[("Redis cache")]
  node_config["Runtime settings<br/>[config.py]"]
end

node_user(("Research user"))

node_user -->|"uses"| node_page
node_page -.->|"renders"| node_chatview
node_chatview -->|"renders"| node_chatinput
node_chatview -->|"renders"| node_message
node_chatview -.->|"requests"| node_api_client
node_chatview -.->|"shows progress"| node_researchoverlay
node_page -.->|"shows chats"| node_sidebar
node_api_client -->|"calls API"| node_fastapi
node_fastapi -->|"invokes research"| node_workflow
node_fastapi -->|"creates state"| node_runstate
node_fastapi -->|"reads and writes"| node_redis
node_fastapi -->|"answers follow-up"| node_chat_service
node_chat_service -->|"loads run"| node_redis
node_workflow -->|"dispatches stages"| node_planning
node_workflow -->|"dispatches search"| node_search
node_workflow -->|"dispatches fetch"| node_fetch
node_workflow -->|"dispatches PDF fetch"| node_pdf_fetch
node_workflow -->|"dispatches extraction"| node_evidence
node_workflow -->|"dispatches writing"| node_report
node_planning -->|"uses prompts"| node_prompts
node_planning -->|"requests plan"| node_llm
node_evidence -->|"extracts evidence"| node_llm
node_report -->|"writes and verifies"| node_llm
node_report -->|"uses prompts"| node_prompts
node_chat_service -->|"generates answer"| node_llm
node_llm -->|"reads settings"| node_config
node_search -.->|"reads limits"| node_config
node_fetch -->|"reads timeout"| node_config

click node_page "https://github.com/dhiraj455/airesearch_agent/blob/master/frontend/app/page.tsx"
click node_chatview "https://github.com/dhiraj455/airesearch_agent/blob/master/frontend/components/ChatView.tsx"
click node_chatinput "https://github.com/dhiraj455/airesearch_agent/blob/master/frontend/components/ChatInput.tsx"
click node_message "https://github.com/dhiraj455/airesearch_agent/blob/master/frontend/components/MessageBubble.tsx"
click node_researchoverlay "https://github.com/dhiraj455/airesearch_agent/blob/master/frontend/components/ResearchOverlay.tsx"
click node_sidebar "https://github.com/dhiraj455/airesearch_agent/blob/master/frontend/components/Sidebar.tsx"
click node_api_client "https://github.com/dhiraj455/airesearch_agent/blob/master/frontend/lib/api.ts"
click node_fastapi "https://github.com/dhiraj455/airesearch_agent/blob/master/src/app.py"
click node_chat_service "https://github.com/dhiraj455/airesearch_agent/blob/master/src/chat_service.py"
click node_runstate "https://github.com/dhiraj455/airesearch_agent/blob/master/src/schemes.py"
click node_workflow "https://github.com/dhiraj455/airesearch_agent/blob/master/src/agent/graph.py"
click node_planning "https://github.com/dhiraj455/airesearch_agent/blob/master/src/agent/nodes.py"
click node_search "https://github.com/dhiraj455/airesearch_agent/blob/master/src/tools/search.py"
click node_fetch "https://github.com/dhiraj455/airesearch_agent/blob/master/src/tools/fetch.py"
click node_pdf_fetch "https://github.com/dhiraj455/airesearch_agent/blob/master/src/tools/pdf.py"
click node_evidence "https://github.com/dhiraj455/airesearch_agent/blob/master/src/agent/nodes.py"
click node_report "https://github.com/dhiraj455/airesearch_agent/blob/master/src/agent/nodes.py"
click node_prompts "https://github.com/dhiraj455/airesearch_agent/blob/master/src/agent/prompt.py"
click node_llm "https://github.com/dhiraj455/airesearch_agent/blob/master/src/agent/utils.py"
click node_config "https://github.com/dhiraj455/airesearch_agent/blob/master/src/config.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_page,node_chatview,node_chatinput,node_message,node_researchoverlay,node_sidebar,node_api_client,node_user toneBlue
class node_fastapi,node_chat_service toneAmber
class node_workflow,node_planning,node_search,node_fetch,node_pdf_fetch,node_evidence,node_report,node_prompts,node_llm toneMint
class node_runstate,node_redis,node_config toneRose
```

## Components

### Chat interface

- [App page](https://github.com/dhiraj455/airesearch_agent/blob/master/frontend/app/page.tsx): `frontend/app/page.tsx`
- [Chat view](https://github.com/dhiraj455/airesearch_agent/blob/master/frontend/components/ChatView.tsx): `frontend/components/ChatView.tsx`
- [Chat input](https://github.com/dhiraj455/airesearch_agent/blob/master/frontend/components/ChatInput.tsx): `frontend/components/ChatInput.tsx`
- [Message display](https://github.com/dhiraj455/airesearch_agent/blob/master/frontend/components/MessageBubble.tsx): `frontend/components/MessageBubble.tsx`
- [Research progress](https://github.com/dhiraj455/airesearch_agent/blob/master/frontend/components/ResearchOverlay.tsx): `frontend/components/ResearchOverlay.tsx`
- [Chat sidebar](https://github.com/dhiraj455/airesearch_agent/blob/master/frontend/components/Sidebar.tsx): `frontend/components/Sidebar.tsx`
- [API client](https://github.com/dhiraj455/airesearch_agent/blob/master/frontend/lib/api.ts): `frontend/lib/api.ts`

### API and chat

- [HTTP API](https://github.com/dhiraj455/airesearch_agent/blob/master/src/app.py): `src/app.py`
- [Follow-up answers](https://github.com/dhiraj455/airesearch_agent/blob/master/src/chat_service.py): `src/chat_service.py`

### Research workflow

- [Research graph](https://github.com/dhiraj455/airesearch_agent/blob/master/src/agent/graph.py): `src/agent/graph.py`
- [Research planning](https://github.com/dhiraj455/airesearch_agent/blob/master/src/agent/nodes.py): `src/agent/nodes.py`
- [Web search](https://github.com/dhiraj455/airesearch_agent/blob/master/src/tools/search.py): `src/tools/search.py`
- [Web fetching](https://github.com/dhiraj455/airesearch_agent/blob/master/src/tools/fetch.py): `src/tools/fetch.py`
- [PDF extraction](https://github.com/dhiraj455/airesearch_agent/blob/master/src/tools/pdf.py): `src/tools/pdf.py`
- [Evidence and coverage](https://github.com/dhiraj455/airesearch_agent/blob/master/src/agent/nodes.py): `src/agent/nodes.py`
- [Report and verification](https://github.com/dhiraj455/airesearch_agent/blob/master/src/agent/nodes.py): `src/agent/nodes.py`
- [Research prompts](https://github.com/dhiraj455/airesearch_agent/blob/master/src/agent/prompt.py): `src/agent/prompt.py`
- [Gemini model access](https://github.com/dhiraj455/airesearch_agent/blob/master/src/agent/utils.py): `src/agent/utils.py`

### State and evidence

- [Run and chat models](https://github.com/dhiraj455/airesearch_agent/blob/master/src/schemes.py): `src/schemes.py`
- **Redis cache**
- [Runtime settings](https://github.com/dhiraj455/airesearch_agent/blob/master/src/config.py): `src/config.py`

### Other components

- **Research user**

## Connections

- Research user → App page: uses (evidence: `README.md`)
- App page → Chat view: renders
- Chat view → Chat input: renders (evidence: `frontend/components/ChatView.tsx`)
- Chat view → Message display: renders (evidence: `frontend/components/ChatView.tsx`)
- Chat view → API client: requests
- Chat view → Research progress: shows progress
- App page → Chat sidebar: shows chats
- API client → HTTP API: calls API (evidence: `README.md`)
- HTTP API → Research graph: invokes research (evidence: `src/app.py`)
- HTTP API → Run and chat models: creates state (evidence: `src/app.py`)
- HTTP API → Redis cache: reads and writes (evidence: `src/app.py`)
- HTTP API → Follow-up answers: answers follow-up (evidence: `src/app.py`)
- Follow-up answers → Redis cache: loads run (evidence: `src/chat_service.py`)
- Research graph → Research planning: dispatches stages (evidence: `src/agent/graph.py`)
- Research graph → Web search: dispatches search (evidence: `src/agent/graph.py`)
- Research graph → Web fetching: dispatches fetch (evidence: `src/agent/graph.py`)
- Research graph → PDF extraction: dispatches PDF fetch (evidence: `src/agent/graph.py`)
- Research graph → Evidence and coverage: dispatches extraction (evidence: `src/agent/graph.py`)
- Research graph → Report and verification: dispatches writing (evidence: `src/agent/graph.py`)
- Research planning → Research prompts: uses prompts (evidence: `src/agent/nodes.py`)
- Research planning → Gemini model access: requests plan (evidence: `src/agent/nodes.py`)
- Evidence and coverage → Gemini model access: extracts evidence (evidence: `src/agent/nodes.py`)
- Report and verification → Gemini model access: writes and verifies (evidence: `src/agent/nodes.py`)
- Report and verification → Research prompts: uses prompts (evidence: `src/agent/nodes.py`)
- Follow-up answers → Gemini model access: generates answer (evidence: `src/chat_service.py`)
- Gemini model access → Runtime settings: reads settings (evidence: `src/agent/utils.py`)
- Web search → Runtime settings: reads limits
- Web fetching → Runtime settings: reads timeout (evidence: `src/tools/fetch.py`)
