# prazeina/research-buddy architecture

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

- Interactive diagram: https://gitdiagram.com/prazeina/research-buddy
- Repository: https://github.com/prazeina/research-buddy

## Overview

The Research Synthesizer is a paper-library RAG application with local CLI and Streamlit interfaces plus a hosted demo mode. Users add PDFs, which are extracted, page-bounded into chunks, and indexed; they then query all or selected papers and receive grounded answers with page citations. The web UI also supports follow-up chat and local conversation persistence. A separate evaluation harness scores answer quality and provides a faithfulness gate. Relationships are based on the README and shown excerpts/source-index references; unsampled internals are represented only where documented.

Main entry points: [`core.py`](https://github.com/prazeina/research-buddy/blob/main/core.py) (PDF ingestion), [`app.py`](https://github.com/prazeina/research-buddy/blob/main/app.py) (Streamlit UI), [`evals/ci_gate.py`](https://github.com/prazeina/research-buddy/blob/main/evals/ci_gate.py) (Faithfulness gate), [`backends.py`](https://github.com/prazeina/research-buddy/blob/main/backends.py) (Backend selection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_web["Streamlit UI<br/>[app.py]"]
  node_cli["CLI commands<br/>[rag.py]"]
  node_chat["Chat persistence<br/>[chat_store.py]"]
end

subgraph group_rag["RAG and paper library"]
  node_ingestion["PDF ingestion<br/>[core.py]"]
  node_pdf["PDF extraction and chunking<br/>[rag_utils.py]"]
  node_registry["Paper registry<br/>[rag_utils.py]"]
  node_retrieval["Chunk retrieval<br/>[core.py]"]
  node_answer["Grounded answer generation<br/>[core.py]"]
  node_vector[("Chroma vector store")]
  node_demo_seed["Demo library seeding<br/>[seed.py]"]
end

subgraph group_runtime["Runtime backends"]
  node_backend["Backend selection<br/>[backends.py]"]
  node_ollama{{"Ollama models"}}
  node_hosted{{"Hosted chat models"}}
end

subgraph group_evaluation["Answer evaluation"]
  node_eval_full["Quality evaluation<br/>[faithfullness.py]"]
  node_eval_gate["Faithfulness gate<br/>[ci_gate.py]"]
end

node_user(("Researcher"))
node_judge{{"Claude evaluator"}}

node_user -->|"asks through"| node_web
node_user -->|"runs commands"| node_cli
node_web -->|"adds papers"| node_ingestion
node_web -->|"submits questions"| node_answer
node_web -->|"loads and saves"| node_chat
node_cli -->|"adds papers"| node_ingestion
node_cli -->|"asks questions"| node_answer
node_ingestion -->|"extracts and chunks"| node_pdf
node_ingestion -->|"registers papers"| node_registry
node_ingestion -->|"indexes chunks"| node_vector
node_retrieval -->|"queries chunks"| node_vector
node_answer -->|"retrieves context"| node_retrieval
node_answer -->|"requests completion"| node_backend
node_backend -->|"uses locally"| node_ollama
node_backend -.->|"uses in demo"| node_hosted
node_web -->|"seeds demo library"| node_demo_seed
node_demo_seed -->|"ingests bundled PDFs"| node_ingestion
node_eval_full -->|"collects RAG answers"| node_answer
node_eval_full -->|"scores four metrics"| node_judge
node_eval_gate -->|"builds test cases"| node_answer
node_eval_gate -->|"seeds demo data"| node_demo_seed
node_eval_gate -->|"selects mode"| node_backend
node_eval_gate -->|"scores faithfulness"| node_judge

click node_web "https://github.com/prazeina/research-buddy/blob/main/app.py"
click node_cli "https://github.com/prazeina/research-buddy/blob/main/rag.py"
click node_chat "https://github.com/prazeina/research-buddy/blob/main/chat_store.py"
click node_ingestion "https://github.com/prazeina/research-buddy/blob/main/core.py"
click node_pdf "https://github.com/prazeina/research-buddy/blob/main/rag_utils.py"
click node_registry "https://github.com/prazeina/research-buddy/blob/main/rag_utils.py"
click node_retrieval "https://github.com/prazeina/research-buddy/blob/main/core.py"
click node_answer "https://github.com/prazeina/research-buddy/blob/main/core.py"
click node_backend "https://github.com/prazeina/research-buddy/blob/main/backends.py"
click node_demo_seed "https://github.com/prazeina/research-buddy/blob/main/seed.py"
click node_eval_full "https://github.com/prazeina/research-buddy/blob/main/evals/faithfullness.py"
click node_eval_gate "https://github.com/prazeina/research-buddy/blob/main/evals/ci_gate.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_web,node_cli,node_chat toneBlue
class node_ingestion,node_pdf,node_registry,node_retrieval,node_answer,node_vector,node_demo_seed toneAmber
class node_backend,node_ollama,node_hosted toneMint
class node_eval_full,node_eval_gate toneRose
class node_user,node_judge toneIndigo
```

## Components

### User interfaces

- [Streamlit UI](https://github.com/prazeina/research-buddy/blob/main/app.py): `app.py`
- [CLI commands](https://github.com/prazeina/research-buddy/blob/main/rag.py): `rag.py`
- [Chat persistence](https://github.com/prazeina/research-buddy/blob/main/chat_store.py): `chat_store.py`

### RAG and paper library

- [PDF ingestion](https://github.com/prazeina/research-buddy/blob/main/core.py): `core.py`
- [PDF extraction and chunking](https://github.com/prazeina/research-buddy/blob/main/rag_utils.py): `rag_utils.py`
- [Paper registry](https://github.com/prazeina/research-buddy/blob/main/rag_utils.py): `rag_utils.py`
- [Chunk retrieval](https://github.com/prazeina/research-buddy/blob/main/core.py): `core.py`
- [Grounded answer generation](https://github.com/prazeina/research-buddy/blob/main/core.py): `core.py`
- **Chroma vector store**
- [Demo library seeding](https://github.com/prazeina/research-buddy/blob/main/seed.py): `seed.py`

### Runtime backends

- [Backend selection](https://github.com/prazeina/research-buddy/blob/main/backends.py): `backends.py`
- **Ollama models**
- **Hosted chat models**

### Answer evaluation

- [Quality evaluation](https://github.com/prazeina/research-buddy/blob/main/evals/faithfullness.py): `evals/faithfullness.py`
- [Faithfulness gate](https://github.com/prazeina/research-buddy/blob/main/evals/ci_gate.py): `evals/ci_gate.py`

### Other components

- **Researcher**
- **Claude evaluator**

## Connections

- Researcher → Streamlit UI: asks through (evidence: `README.md`)
- Researcher → CLI commands: runs commands (evidence: `README.md`)
- Streamlit UI → PDF ingestion: adds papers (evidence: `app.py`)
- Streamlit UI → Grounded answer generation: submits questions (evidence: `app.py`)
- Streamlit UI → Chat persistence: loads and saves (evidence: `app.py`)
- CLI commands → PDF ingestion: adds papers (evidence: `rag.py`)
- CLI commands → Grounded answer generation: asks questions (evidence: `rag.py`)
- PDF ingestion → PDF extraction and chunking: extracts and chunks (evidence: `core.py`)
- PDF ingestion → Paper registry: registers papers (evidence: `core.py`)
- PDF ingestion → Chroma vector store: indexes chunks (evidence: `core.py`)
- Chunk retrieval → Chroma vector store: queries chunks (evidence: `core.py`)
- Grounded answer generation → Chunk retrieval: retrieves context (evidence: `core.py`)
- Grounded answer generation → Backend selection: requests completion (evidence: `core.py`)
- Backend selection → Ollama models: uses locally (evidence: `backends.py`)
- Backend selection → Hosted chat models: uses in demo (evidence: `backends.py`)
- Streamlit UI → Demo library seeding: seeds demo library (evidence: `app.py`)
- Demo library seeding → PDF ingestion: ingests bundled PDFs (evidence: `seed.py`)
- Quality evaluation → Grounded answer generation: collects RAG answers (evidence: `evals/faithfullness.py`)
- Quality evaluation → Claude evaluator: scores four metrics (evidence: `evals/faithfullness.py`)
- Faithfulness gate → Grounded answer generation: builds test cases (evidence: `evals/ci_gate.py`)
- Faithfulness gate → Demo library seeding: seeds demo data (evidence: `evals/ci_gate.py`)
- Faithfulness gate → Backend selection: selects mode (evidence: `evals/ci_gate.py`)
- Faithfulness gate → Claude evaluator: scores faithfulness (evidence: `evals/ci_gate.py`)
