# nbhatia1710/research-pilot architecture

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

- Interactive diagram: https://gitdiagram.com/nbhatia1710/research-pilot
- Repository: https://github.com/nbhatia1710/research-pilot

## Overview

AI Research Assistant is a document-grounded chat product. Users upload supported files, which the API parses and indexes, then ask questions across selected documents; the multi-agent path retrieves evidence, summarizes it, critiques gaps, and returns an answer with conversation context. The frontend also exposes session history and a simple-RAG mode. The graph follows README-documented capabilities and indexed source references; several route and UI implementations were only partially excerpted, so those links rely on README evidence.

Main entry points: [`backend/main.py`](https://github.com/nbhatia1710/research-pilot/blob/main/backend/main.py) (HTTP API), [`backend/agents/langgraph_nodes.py`](https://github.com/nbhatia1710/research-pilot/blob/main/backend/agents/langgraph_nodes.py) (Workflow nodes), [`backend/agents/research_agent.py`](https://github.com/nbhatia1710/research-pilot/blob/main/backend/agents/research_agent.py) (Research retrieval), [`frontend/components/ChatBox.tsx`](https://github.com/nbhatia1710/research-pilot/blob/main/frontend/components/ChatBox.tsx) (Chat and upload)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Chat interface"]
  node_chat["Chat and upload<br/>[ChatBox.tsx]"]
  node_history["Session history<br/>[history.tsx]"]
end

subgraph group_api["API and ingestion"]
  node_api_server["HTTP API<br/>[main.py]"]
  node_parser["Parse and chunk<br/>[document_parser.py]"]
end

subgraph group_retrieval["Document retrieval"]
  node_embeddings["Embeddings and LLM<br/>[embeddings.py]"]
  node_single_store[("Shared FAISS index<br/>[faiss_store.py]")]
  node_multi_store[("Per-document FAISS<br/>[multi_doc_store.py]")]
end

subgraph group_agents["Answer workflow"]
  node_research["Research retrieval<br/>[research_agent.py]"]
  node_orchestrator["Workflow entry<br/>[orchestrator.py]"]
  node_workflow["LangGraph routing"]
  node_nodes["Workflow nodes<br/>[langgraph_nodes.py]"]
  node_state["Agent state<br/>[agent_state.py]"]
  node_summarizer["Summarizer"]
  node_critic["Critic<br/>[critic_agent.py]"]
  node_editor["Editor<br/>[editor_agent.py]"]
end

subgraph group_memory["Session memory"]
  node_memory[("Conversation memory<br/>[postgres_memory.py]")]
  node_sqlite_memory[("SQLite session memory<br/>[sqlite_memory.py]")]
end

node_user(("User"))
node_ollama{{"Ollama service"}}

node_user -->|"asks and uploads"| node_chat
node_chat -->|"calls API"| node_api_server
node_api_server -->|"parses uploads"| node_parser
node_api_server -->|"indexes documents"| node_multi_store
node_api_server -->|"serves simple RAG"| node_single_store
node_api_server -->|"starts workflow"| node_orchestrator
node_orchestrator -->|"runs graph"| node_workflow
node_workflow -->|"routes nodes"| node_nodes
node_nodes -->|"updates state"| node_state
node_nodes -->|"invokes retrieval"| node_research
node_nodes -->|"invokes summary"| node_summarizer
node_nodes -->|"invokes critique"| node_critic
node_nodes -->|"invokes editing"| node_editor
node_research -->|"searches index"| node_single_store
node_research -->|"searches documents"| node_multi_store
node_research -->|"embeds query"| node_embeddings
node_summarizer -->|"generates summary"| node_ollama
node_critic -->|"evaluates answer"| node_ollama
node_editor -->|"polishes answer"| node_ollama
node_api_server -->|"stores sessions"| node_memory
node_history -->|"browses sessions"| node_api_server
node_api_server -.->|"supports session history"| node_sqlite_memory

click node_chat "https://github.com/nbhatia1710/research-pilot/blob/main/frontend/components/ChatBox.tsx"
click node_history "https://github.com/nbhatia1710/research-pilot/blob/main/frontend/pages/history.tsx"
click node_api_server "https://github.com/nbhatia1710/research-pilot/blob/main/backend/main.py"
click node_parser "https://github.com/nbhatia1710/research-pilot/blob/main/backend/utils/document_parser.py"
click node_embeddings "https://github.com/nbhatia1710/research-pilot/blob/main/backend/utils/embeddings.py"
click node_single_store "https://github.com/nbhatia1710/research-pilot/blob/main/backend/db/faiss_store.py"
click node_multi_store "https://github.com/nbhatia1710/research-pilot/blob/main/backend/db/multi_doc_store.py"
click node_research "https://github.com/nbhatia1710/research-pilot/blob/main/backend/agents/research_agent.py"
click node_orchestrator "https://github.com/nbhatia1710/research-pilot/blob/main/backend/agents/orchestrator.py"
click node_workflow "https://github.com/nbhatia1710/research-pilot/blob/main/backend/agents/langgraph_workflow.py"
click node_nodes "https://github.com/nbhatia1710/research-pilot/blob/main/backend/agents/langgraph_nodes.py"
click node_state "https://github.com/nbhatia1710/research-pilot/blob/main/backend/agents/agent_state.py"
click node_summarizer "https://github.com/nbhatia1710/research-pilot/blob/main/backend/agents/summarizer_agent.py"
click node_critic "https://github.com/nbhatia1710/research-pilot/blob/main/backend/agents/critic_agent.py"
click node_editor "https://github.com/nbhatia1710/research-pilot/blob/main/backend/agents/editor_agent.py"
click node_memory "https://github.com/nbhatia1710/research-pilot/blob/main/backend/db/postgres_memory.py"
click node_sqlite_memory "https://github.com/nbhatia1710/research-pilot/blob/main/backend/db/sqlite_memory.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_chat,node_history,node_user toneBlue
class node_api_server,node_parser toneAmber
class node_embeddings,node_single_store,node_multi_store toneMint
class node_research,node_orchestrator,node_workflow,node_nodes,node_state,node_summarizer,node_critic,node_editor toneRose
class node_memory,node_sqlite_memory,node_ollama toneIndigo
```

## Components

### Chat interface

- [Chat and upload](https://github.com/nbhatia1710/research-pilot/blob/main/frontend/components/ChatBox.tsx): `frontend/components/ChatBox.tsx`
- [Session history](https://github.com/nbhatia1710/research-pilot/blob/main/frontend/pages/history.tsx): `frontend/pages/history.tsx`

### API and ingestion

- [HTTP API](https://github.com/nbhatia1710/research-pilot/blob/main/backend/main.py): `backend/main.py`
- [Parse and chunk](https://github.com/nbhatia1710/research-pilot/blob/main/backend/utils/document_parser.py): `backend/utils/document_parser.py`

### Document retrieval

- [Embeddings and LLM](https://github.com/nbhatia1710/research-pilot/blob/main/backend/utils/embeddings.py): `backend/utils/embeddings.py`
- [Shared FAISS index](https://github.com/nbhatia1710/research-pilot/blob/main/backend/db/faiss_store.py): `backend/db/faiss_store.py`
- [Per-document FAISS](https://github.com/nbhatia1710/research-pilot/blob/main/backend/db/multi_doc_store.py): `backend/db/multi_doc_store.py`

### Answer workflow

- [Research retrieval](https://github.com/nbhatia1710/research-pilot/blob/main/backend/agents/research_agent.py): `backend/agents/research_agent.py`
- [Workflow entry](https://github.com/nbhatia1710/research-pilot/blob/main/backend/agents/orchestrator.py): `backend/agents/orchestrator.py`
- [LangGraph routing](https://github.com/nbhatia1710/research-pilot/blob/main/backend/agents/langgraph_workflow.py): `backend/agents/langgraph_workflow.py`
- [Workflow nodes](https://github.com/nbhatia1710/research-pilot/blob/main/backend/agents/langgraph_nodes.py): `backend/agents/langgraph_nodes.py`
- [Agent state](https://github.com/nbhatia1710/research-pilot/blob/main/backend/agents/agent_state.py): `backend/agents/agent_state.py`
- [Summarizer](https://github.com/nbhatia1710/research-pilot/blob/main/backend/agents/summarizer_agent.py): `backend/agents/summarizer_agent.py`
- [Critic](https://github.com/nbhatia1710/research-pilot/blob/main/backend/agents/critic_agent.py): `backend/agents/critic_agent.py`
- [Editor](https://github.com/nbhatia1710/research-pilot/blob/main/backend/agents/editor_agent.py): `backend/agents/editor_agent.py`

### Session memory

- [Conversation memory](https://github.com/nbhatia1710/research-pilot/blob/main/backend/db/postgres_memory.py): `backend/db/postgres_memory.py`
- [SQLite session memory](https://github.com/nbhatia1710/research-pilot/blob/main/backend/db/sqlite_memory.py): `backend/db/sqlite_memory.py`

### Other components

- **User**
- **Ollama service**

## Connections

- User → Chat and upload: asks and uploads (evidence: `README.md`)
- Chat and upload → HTTP API: calls API (evidence: `README.md`)
- HTTP API → Parse and chunk: parses uploads (evidence: `README.md`)
- HTTP API → Per-document FAISS: indexes documents (evidence: `README.md`)
- HTTP API → Shared FAISS index: serves simple RAG (evidence: `backend/main.py`)
- HTTP API → Workflow entry: starts workflow (evidence: `backend/main.py`)
- Workflow entry → LangGraph routing: runs graph (evidence: `backend/agents/orchestrator.py`)
- LangGraph routing → Workflow nodes: routes nodes (evidence: `backend/agents/langgraph_workflow.py`)
- Workflow nodes → Agent state: updates state (evidence: `backend/agents/langgraph_nodes.py`)
- Workflow nodes → Research retrieval: invokes retrieval (evidence: `backend/agents/langgraph_nodes.py`)
- Workflow nodes → Summarizer: invokes summary (evidence: `backend/agents/langgraph_nodes.py`)
- Workflow nodes → Critic: invokes critique (evidence: `backend/agents/langgraph_nodes.py`)
- Workflow nodes → Editor: invokes editing (evidence: `backend/agents/langgraph_nodes.py`)
- Research retrieval → Shared FAISS index: searches index (evidence: `backend/agents/research_agent.py`)
- Research retrieval → Per-document FAISS: searches documents (evidence: `backend/agents/research_agent.py`)
- Research retrieval → Embeddings and LLM: embeds query (evidence: `backend/agents/research_agent.py`)
- Summarizer → Ollama service: generates summary
- Critic → Ollama service: evaluates answer
- Editor → Ollama service: polishes answer
- HTTP API → Conversation memory: stores sessions (evidence: `backend/main.py`)
- Session history → HTTP API: browses sessions (evidence: `README.md`)
- HTTP API → SQLite session memory: supports session history (evidence: `README.md`)
