# parthwhy/paperlens architecture

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

- Interactive diagram: https://gitdiagram.com/parthwhy/paperlens
- Repository: https://github.com/parthwhy/paperlens

## Overview

PaperLens turns an arXiv paper into a reader with grounded chat, contextual explanations, a concept map, and generated animations. The main workflow runs from paper submission through ingestion and storage, then serves separate reading and analysis capabilities to the browser. The README documents the API-level flow; excerpts and the source index support several internal calls. Some UI and backend implementations were not sampled, so their internal relationships are omitted where evidence is limited.

Main entry points: [`app/papers.py`](https://github.com/parthwhy/paperlens/blob/main/app/papers.py) (Paper API routes), [`new_ui/src/App.tsx`](https://github.com/parthwhy/paperlens/blob/main/new_ui/src/App.tsx) (App navigation), [`app/ingestion.py`](https://github.com/parthwhy/paperlens/blob/main/app/ingestion.py) (Paper ingestion), [`new_ui/src/services/api.ts`](https://github.com/parthwhy/paperlens/blob/main/new_ui/src/services/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Reader interface"]
  node_app["App navigation<br/>[App.tsx]"]
  node_landing["Paper submission<br/>[LandingPage.tsx]"]
  node_document["PDF reader and chat<br/>[DocumentView.tsx]"]
  node_concept_ui["Concept map view<br/>[ConceptMap.tsx]"]
  node_animation_ui["Animation dashboard<br/>[ManimDashboard.tsx]"]
  node_tooltip_ui["Selection tooltip"]
  node_tooltip_hook["Selection handling<br/>[useTooltip.ts]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["API orchestration"]
  node_api_entry["FastAPI entry<br/>[main.py]"]
  node_routes["Paper API routes<br/>[papers.py]"]
  node_contracts["API schemas<br/>[schemas.py]"]
end

subgraph group_paper["Paper processing"]
  node_ingestion["Paper ingestion<br/>[ingestion.py]"]
  node_vector_store[("ChromaDB vectors")]
  node_paper_history[("SQLite history")]
  node_pdf_cache[("PDF cache")]
end

subgraph group_assist["Research assistance"]
  node_rag["Grounded chat<br/>[rag_chat.py]"]
  node_tooltip_service["Tooltip explanations<br/>[tooltip.py]"]
  node_concept_service["Concept extraction<br/>[concept_map.py]"]
end

subgraph group_visual["Visual explanations"]
  node_manim["Animation generation<br/>[manim_service.py]"]
  node_animation_files[("Rendered animations")]
end

node_reader(("Researcher"))
node_arxiv["arXiv"]
node_groq{{"Groq inference"}}

node_reader -->|"uses"| node_app
node_app -->|"renders"| node_landing
node_app -->|"renders"| node_document
node_app -->|"renders"| node_concept_ui
node_app -->|"renders"| node_animation_ui
node_landing -.->|"submits paper"| node_api_client
node_document -->|"requests paper data"| node_api_client
node_concept_ui -->|"requests map"| node_api_client
node_document -->|"uses selection"| node_tooltip_hook
node_tooltip_hook -->|"provides tooltip"| node_tooltip_ui
node_api_client -->|"calls REST API"| node_routes
node_api_entry -->|"mounts routes"| node_routes
node_routes -->|"starts ingestion"| node_ingestion
node_routes -->|"dispatches chat"| node_rag
node_routes -->|"dispatches tooltip"| node_tooltip_service
node_routes -->|"dispatches map"| node_concept_service
node_routes -->|"dispatches animation"| node_manim
node_ingestion -->|"fetches paper"| node_arxiv
node_ingestion -->|"stores chunks"| node_vector_store
node_ingestion -->|"saves metadata"| node_paper_history
node_ingestion -->|"downloads PDF"| node_pdf_cache
node_rag -->|"retrieves chunks"| node_vector_store
node_rag -->|"generates answer"| node_groq
node_tooltip_service -.->|"generates explanation"| node_groq
node_concept_service -.->|"uses paper chunks"| node_vector_store
node_manim -->|"reads paper context"| node_vector_store
node_manim -->|"plans storyboard"| node_groq
node_manim -->|"renders video"| node_animation_files
node_animation_ui -.->|"requests animation"| node_api_client

click node_app "https://github.com/parthwhy/paperlens/blob/main/new_ui/src/App.tsx"
click node_landing "https://github.com/parthwhy/paperlens/blob/main/new_ui/src/components/LandingPage.tsx"
click node_document "https://github.com/parthwhy/paperlens/blob/main/new_ui/src/components/DocumentView.tsx"
click node_concept_ui "https://github.com/parthwhy/paperlens/blob/main/new_ui/src/components/ConceptMap.tsx"
click node_animation_ui "https://github.com/parthwhy/paperlens/blob/main/new_ui/src/components/ManimDashboard.tsx"
click node_tooltip_ui "https://github.com/parthwhy/paperlens/blob/main/new_ui/src/components/SelectionTooltip.tsx"
click node_tooltip_hook "https://github.com/parthwhy/paperlens/blob/main/new_ui/src/hooks/useTooltip.ts"
click node_api_client "https://github.com/parthwhy/paperlens/blob/main/new_ui/src/services/api.ts"
click node_api_entry "https://github.com/parthwhy/paperlens/blob/main/app/main.py"
click node_routes "https://github.com/parthwhy/paperlens/blob/main/app/papers.py"
click node_contracts "https://github.com/parthwhy/paperlens/blob/main/app/schemas.py"
click node_ingestion "https://github.com/parthwhy/paperlens/blob/main/app/ingestion.py"
click node_rag "https://github.com/parthwhy/paperlens/blob/main/app/rag_chat.py"
click node_tooltip_service "https://github.com/parthwhy/paperlens/blob/main/app/tooltip.py"
click node_concept_service "https://github.com/parthwhy/paperlens/blob/main/app/concept_map.py"
click node_manim "https://github.com/parthwhy/paperlens/blob/main/app/manim_service.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,node_landing,node_document,node_concept_ui,node_animation_ui,node_tooltip_ui,node_tooltip_hook,node_api_client toneBlue
class node_api_entry,node_routes,node_contracts toneAmber
class node_ingestion,node_vector_store,node_paper_history,node_pdf_cache toneMint
class node_rag,node_tooltip_service,node_concept_service toneRose
class node_manim,node_animation_files,node_reader,node_arxiv,node_groq toneIndigo
```

## Components

### Reader interface

- [App navigation](https://github.com/parthwhy/paperlens/blob/main/new_ui/src/App.tsx): `new_ui/src/App.tsx`
- [Paper submission](https://github.com/parthwhy/paperlens/blob/main/new_ui/src/components/LandingPage.tsx): `new_ui/src/components/LandingPage.tsx`
- [PDF reader and chat](https://github.com/parthwhy/paperlens/blob/main/new_ui/src/components/DocumentView.tsx): `new_ui/src/components/DocumentView.tsx`
- [Concept map view](https://github.com/parthwhy/paperlens/blob/main/new_ui/src/components/ConceptMap.tsx): `new_ui/src/components/ConceptMap.tsx`
- [Animation dashboard](https://github.com/parthwhy/paperlens/blob/main/new_ui/src/components/ManimDashboard.tsx): `new_ui/src/components/ManimDashboard.tsx`
- [Selection tooltip](https://github.com/parthwhy/paperlens/blob/main/new_ui/src/components/SelectionTooltip.tsx): `new_ui/src/components/SelectionTooltip.tsx`
- [Selection handling](https://github.com/parthwhy/paperlens/blob/main/new_ui/src/hooks/useTooltip.ts): `new_ui/src/hooks/useTooltip.ts`
- [API client](https://github.com/parthwhy/paperlens/blob/main/new_ui/src/services/api.ts): `new_ui/src/services/api.ts`

### API orchestration

- [FastAPI entry](https://github.com/parthwhy/paperlens/blob/main/app/main.py): `app/main.py`
- [Paper API routes](https://github.com/parthwhy/paperlens/blob/main/app/papers.py): `app/papers.py`
- [API schemas](https://github.com/parthwhy/paperlens/blob/main/app/schemas.py): `app/schemas.py`

### Paper processing

- [Paper ingestion](https://github.com/parthwhy/paperlens/blob/main/app/ingestion.py): `app/ingestion.py`
- **ChromaDB vectors**
- **SQLite history**
- **PDF cache**

### Research assistance

- [Grounded chat](https://github.com/parthwhy/paperlens/blob/main/app/rag_chat.py): `app/rag_chat.py`
- [Tooltip explanations](https://github.com/parthwhy/paperlens/blob/main/app/tooltip.py): `app/tooltip.py`
- [Concept extraction](https://github.com/parthwhy/paperlens/blob/main/app/concept_map.py): `app/concept_map.py`

### Visual explanations

- [Animation generation](https://github.com/parthwhy/paperlens/blob/main/app/manim_service.py): `app/manim_service.py`
- **Rendered animations**

### Other components

- **Researcher**
- **arXiv**
- **Groq inference**

## Connections

- Researcher → App navigation: uses (evidence: `new_ui/src/App.tsx`)
- App navigation → Paper submission: renders (evidence: `new_ui/src/App.tsx`)
- App navigation → PDF reader and chat: renders (evidence: `new_ui/src/App.tsx`)
- App navigation → Concept map view: renders (evidence: `new_ui/src/App.tsx`)
- App navigation → Animation dashboard: renders (evidence: `new_ui/src/App.tsx`)
- Paper submission → API client: submits paper
- PDF reader and chat → API client: requests paper data (evidence: `new_ui/src/components/DocumentView.tsx`)
- Concept map view → API client: requests map (evidence: `new_ui/src/components/ConceptMap.tsx`)
- PDF reader and chat → Selection handling: uses selection (evidence: `new_ui/src/components/DocumentView.tsx`)
- Selection handling → Selection tooltip: provides tooltip (evidence: `new_ui/src/hooks/useTooltip.ts`)
- API client → Paper API routes: calls REST API (evidence: `README.md`)
- FastAPI entry → Paper API routes: mounts routes (evidence: `app/main.py`)
- Paper API routes → Paper ingestion: starts ingestion (evidence: `app/papers.py`)
- Paper API routes → Grounded chat: dispatches chat (evidence: `app/papers.py`)
- Paper API routes → Tooltip explanations: dispatches tooltip (evidence: `app/papers.py`)
- Paper API routes → Concept extraction: dispatches map (evidence: `README.md`)
- Paper API routes → Animation generation: dispatches animation (evidence: `app/papers.py`)
- Paper ingestion → arXiv: fetches paper (evidence: `app/ingestion.py`)
- Paper ingestion → ChromaDB vectors: stores chunks (evidence: `app/ingestion.py`)
- Paper ingestion → SQLite history: saves metadata (evidence: `app/ingestion.py`)
- Paper ingestion → PDF cache: downloads PDF (evidence: `app/ingestion.py`)
- Grounded chat → ChromaDB vectors: retrieves chunks (evidence: `app/rag_chat.py`)
- Grounded chat → Groq inference: generates answer (evidence: `app/rag_chat.py`)
- Tooltip explanations → Groq inference: generates explanation
- Concept extraction → ChromaDB vectors: uses paper chunks (evidence: `README.md`)
- Animation generation → ChromaDB vectors: reads paper context (evidence: `app/manim_service.py`)
- Animation generation → Groq inference: plans storyboard (evidence: `app/manim_service.py`)
- Animation generation → Rendered animations: renders video (evidence: `README.md`)
- Animation dashboard → API client: requests animation
