# somyajangir/paperqa-tutor-page-wise-research-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/somyajangir/paperqa-tutor-page-wise-research-assistant
- Repository: https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant

## Overview

PaperQA Section Tutor is a Streamlit application for studying uploaded research-paper PDFs. The principal workflow runs from PDF upload and page navigation to page explanations, page-scoped questions, and quizzes with feedback; a separate document-wide RAG chat returns evidence with citations. A fine-tuned local Gemma summarizer and text-to-speech are additional learning capabilities. The graph preserves the README’s major features; some UI-to-agent wiring is only partially excerpted, so uncertain connections are omitted or marked unverified.

Main entry points: [`ui/app.py`](https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/ui/app.py) (Streamlit tutor), [`agent/indexer.py`](https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/indexer.py) (Document RAG index), [`agent/page_qa.py`](https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/page_qa.py) (Page-scoped Q&A), [`agent/ingestor.py`](https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/ingestor.py) (PDF page extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Tutor interface"]
  node_app["Streamlit tutor<br/>[app.py]"]
end

subgraph group_document["Paper processing"]
  node_ingestor["PDF page extraction<br/>[ingestor.py]"]
  node_pageplan["Page text"]
end

subgraph group_retrieval["Retrieval and QA"]
  node_indexer["Document RAG index<br/>[indexer.py]"]
  node_embeddings["Embedding model<br/>[embeddings.py]"]
  node_faiss[("FAISS search index")]
  node_pageqa["Page-scoped Q&amp;A<br/>[page_qa.py]"]
end

subgraph group_learning["Learning features"]
  node_explainer["Page explainer<br/>[explainer.py]"]
  node_quizgen["Quiz generation<br/>[qg_generator.py]"]
  node_evaluator["Quiz grading<br/>[evaluator.py]"]
  node_summarizer["Local summarizer<br/>[summarizer.py]"]
  node_audio["Speech playback<br/>[app.py]"]
end

subgraph group_support["Models and logging"]
  node_gemma[("Merged Gemma model")]
  node_logger["Interaction logging<br/>[logger.py]"]
end

node_learner(("Learner"))
node_pdf["Uploaded PDF"]
node_gemini{{"Gemini API"}}

node_learner -->|"uses"| node_app
node_pdf -->|"uploads"| node_app
node_app -.->|"ingests PDF"| node_ingestor
node_ingestor -->|"extracts pages"| node_pageplan
node_app -.->|"builds retrieval"| node_indexer
node_indexer -->|"encodes chunks"| node_embeddings
node_indexer -->|"stores vectors"| node_faiss
node_app -.->|"asks page questions"| node_pageqa
node_pageqa -->|"encodes chunks"| node_embeddings
node_pageqa -->|"synthesizes answers"| node_gemini
node_app -.->|"requests explanations"| node_explainer
node_explainer -->|"generates explanation"| node_gemini
node_app -.->|"generates quiz"| node_quizgen
node_quizgen -->|"generates questions"| node_gemini
node_app -.->|"submits answers"| node_evaluator
node_evaluator -->|"grades answers"| node_gemini
node_app -->|"requests summary"| node_summarizer
node_summarizer -->|"loads weights"| node_gemma
node_app -->|"plays speech"| node_audio
node_app -->|"logs interactions"| node_logger
node_app -->|"shows citations"| node_learner

click node_app "https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/ui/app.py"
click node_ingestor "https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/ingestor.py"
click node_indexer "https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/indexer.py"
click node_embeddings "https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/embeddings.py"
click node_pageqa "https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/page_qa.py"
click node_explainer "https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/explainer.py"
click node_quizgen "https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/qg_generator.py"
click node_evaluator "https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/evaluator.py"
click node_summarizer "https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/summarizer.py"
click node_audio "https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/ui/app.py"
click node_gemma "https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/tree/main/merged_full_model"
click node_logger "https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/logger.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_app toneBlue
class node_ingestor,node_pageplan toneAmber
class node_indexer,node_embeddings,node_faiss,node_pageqa,node_gemini toneMint
class node_explainer,node_quizgen,node_evaluator,node_summarizer,node_audio toneRose
class node_gemma,node_logger,node_learner,node_pdf toneIndigo
```

## Components

### Tutor interface

- [Streamlit tutor](https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/ui/app.py): `ui/app.py`

### Paper processing

- [PDF page extraction](https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/ingestor.py): `agent/ingestor.py`
- **Page text**

### Retrieval and QA

- [Document RAG index](https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/indexer.py): `agent/indexer.py`
- [Embedding model](https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/embeddings.py): `agent/embeddings.py`
- **FAISS search index**
- [Page-scoped Q&A](https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/page_qa.py): `agent/page_qa.py`

### Learning features

- [Page explainer](https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/explainer.py): `agent/explainer.py`
- [Quiz generation](https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/qg_generator.py): `agent/qg_generator.py`
- [Quiz grading](https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/evaluator.py): `agent/evaluator.py`
- [Local summarizer](https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/summarizer.py): `agent/summarizer.py`
- [Speech playback](https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/ui/app.py): `ui/app.py`

### Models and logging

- [Merged Gemma model](https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/tree/main/merged_full_model): `merged_full_model`
- [Interaction logging](https://github.com/somyajangir/paperqa-tutor-page-wise-research-assistant/blob/main/agent/logger.py): `agent/logger.py`

### Other components

- **Learner**
- **Uploaded PDF**
- **Gemini API**

## Connections

- Learner → Streamlit tutor: uses (evidence: `README.md`)
- Uploaded PDF → Streamlit tutor: uploads (evidence: `README.md`)
- Streamlit tutor → PDF page extraction: ingests PDF (evidence: `ui/app.py`)
- PDF page extraction → Page text: extracts pages (evidence: `agent/ingestor.py`)
- Streamlit tutor → Document RAG index: builds retrieval (evidence: `ui/app.py`)
- Document RAG index → Embedding model: encodes chunks (evidence: `agent/indexer.py`)
- Document RAG index → FAISS search index: stores vectors (evidence: `agent/indexer.py`)
- Streamlit tutor → Page-scoped Q&A: asks page questions (evidence: `ui/app.py`)
- Page-scoped Q&A → Embedding model: encodes chunks (evidence: `agent/page_qa.py`)
- Page-scoped Q&A → Gemini API: synthesizes answers (evidence: `agent/page_qa.py`)
- Streamlit tutor → Page explainer: requests explanations (evidence: `ui/app.py`)
- Page explainer → Gemini API: generates explanation (evidence: `agent/explainer.py`)
- Streamlit tutor → Quiz generation: generates quiz (evidence: `ui/app.py`)
- Quiz generation → Gemini API: generates questions (evidence: `agent/qg_generator.py`)
- Streamlit tutor → Quiz grading: submits answers (evidence: `ui/app.py`)
- Quiz grading → Gemini API: grades answers (evidence: `agent/evaluator.py`)
- Streamlit tutor → Local summarizer: requests summary (evidence: `ui/app.py`)
- Local summarizer → Merged Gemma model: loads weights (evidence: `agent/summarizer.py`)
- Streamlit tutor → Speech playback: plays speech (evidence: `README.md`)
- Streamlit tutor → Interaction logging: logs interactions (evidence: `ui/app.py`)
- Streamlit tutor → Learner: shows citations (evidence: `README.md`)
