# hariharan024/ai-research-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/hariharan024/ai-research-assistant
- Repository: https://github.com/hariharan024/ai-research-assistant

## Overview

AI Research Assistant is a local PDF question-answering application. Users upload a PDF through the React UI; the API extracts pages, chunks text, and indexes it. Users then ask questions, which the RAG pipeline rewrites when conversation history exists, retrieves document chunks, and sends context to a local Ollama model. The API returns the answer and source metadata for display. The graph follows the sampled runtime; the README documents the broader capabilities, while unsampled implementation details are not inferred.

Main entry points: [`app/api.py`](https://github.com/hariharan024/ai-research-assistant/blob/main/app/api.py) (FastAPI endpoints), [`app/rag_pipeline.py`](https://github.com/hariharan024/ai-research-assistant/blob/main/app/rag_pipeline.py) (RAG pipeline), [`frontend/src/App.jsx`](https://github.com/hariharan024/ai-research-assistant/blob/main/frontend/src/App.jsx) (React interface), [`app/query_rewriter.py`](https://github.com/hariharan024/ai-research-assistant/blob/main/app/query_rewriter.py) (Query rewriting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_ui["React interface<br/>[App.jsx]"]
end

subgraph group_api["API and ingestion"]
  node_api["FastAPI endpoints<br/>[api.py]"]
  node_pdf["PDF extraction<br/>[pdf_loader.py]"]
  node_chunker["Text chunking<br/>[chunker.py]"]
end

subgraph group_rag["RAG and generation"]
  node_rag["RAG pipeline<br/>[rag_pipeline.py]"]
  node_rewriter["Query rewriting<br/>[query_rewriter.py]"]
  node_llm["Answer generation<br/>[local_llm.py]"]
end

subgraph group_storage["Document storage"]
  node_store[("Chroma vector store<br/>[vector_store.py]")]
end

node_user(("Researcher"))
node_ollama["Ollama model"]

node_user -->|"asks and uploads"| node_ui
node_ui -->|"sends requests"| node_api
node_api -->|"extracts pages"| node_pdf
node_api -->|"chunks pages"| node_chunker
node_api -->|"indexes chunks"| node_store
node_api -->|"dispatches questions"| node_rag
node_rag -->|"rewrites queries"| node_rewriter
node_rag -->|"retrieves chunks"| node_store
node_rag -->|"generates answer"| node_llm
node_rewriter -->|"calls model"| node_ollama
node_llm -->|"calls model"| node_ollama

click node_ui "https://github.com/hariharan024/ai-research-assistant/blob/main/frontend/src/App.jsx"
click node_api "https://github.com/hariharan024/ai-research-assistant/blob/main/app/api.py"
click node_pdf "https://github.com/hariharan024/ai-research-assistant/blob/main/app/pdf_loader.py"
click node_chunker "https://github.com/hariharan024/ai-research-assistant/blob/main/app/chunker.py"
click node_rag "https://github.com/hariharan024/ai-research-assistant/blob/main/app/rag_pipeline.py"
click node_rewriter "https://github.com/hariharan024/ai-research-assistant/blob/main/app/query_rewriter.py"
click node_llm "https://github.com/hariharan024/ai-research-assistant/blob/main/app/local_llm.py"
click node_store "https://github.com/hariharan024/ai-research-assistant/blob/main/app/vector_store.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_ui toneBlue
class node_api,node_pdf,node_chunker toneAmber
class node_rag,node_rewriter,node_llm toneMint
class node_store toneRose
class node_user,node_ollama toneIndigo
```

## Components

### Web client

- [React interface](https://github.com/hariharan024/ai-research-assistant/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`

### API and ingestion

- [FastAPI endpoints](https://github.com/hariharan024/ai-research-assistant/blob/main/app/api.py): `app/api.py`
- [PDF extraction](https://github.com/hariharan024/ai-research-assistant/blob/main/app/pdf_loader.py): `app/pdf_loader.py`
- [Text chunking](https://github.com/hariharan024/ai-research-assistant/blob/main/app/chunker.py): `app/chunker.py`

### RAG and generation

- [RAG pipeline](https://github.com/hariharan024/ai-research-assistant/blob/main/app/rag_pipeline.py): `app/rag_pipeline.py`
- [Query rewriting](https://github.com/hariharan024/ai-research-assistant/blob/main/app/query_rewriter.py): `app/query_rewriter.py`
- [Answer generation](https://github.com/hariharan024/ai-research-assistant/blob/main/app/local_llm.py): `app/local_llm.py`

### Document storage

- [Chroma vector store](https://github.com/hariharan024/ai-research-assistant/blob/main/app/vector_store.py): `app/vector_store.py`

### Other components

- **Researcher**
- **Ollama model**

## Connections

- Researcher → React interface: asks and uploads (evidence: `frontend/src/App.jsx`)
- React interface → FastAPI endpoints: sends requests (evidence: `frontend/src/App.jsx`)
- FastAPI endpoints → PDF extraction: extracts pages (evidence: `app/api.py`)
- FastAPI endpoints → Text chunking: chunks pages (evidence: `app/api.py`)
- FastAPI endpoints → Chroma vector store: indexes chunks (evidence: `app/api.py`)
- FastAPI endpoints → RAG pipeline: dispatches questions (evidence: `app/api.py`)
- RAG pipeline → Query rewriting: rewrites queries (evidence: `app/rag_pipeline.py`)
- RAG pipeline → Chroma vector store: retrieves chunks (evidence: `app/rag_pipeline.py`)
- RAG pipeline → Answer generation: generates answer (evidence: `app/rag_pipeline.py`)
- Query rewriting → Ollama model: calls model (evidence: `app/query_rewriter.py`)
- Answer generation → Ollama model: calls model (evidence: `app/local_llm.py`)
