# shreyas8905/resector architecture

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

- Interactive diagram: https://gitdiagram.com/shreyas8905/resector
- Repository: https://github.com/shreyas8905/resector

## Overview

ReSector is a local-first research workstation: users explore papers, upload PDFs for session-grounded chat, and run structured research tools; results and sessions are retained for later search. The graph also preserves documented citation mapping, provider choices, and research modules. Backend relationships are supported by excerpts or the SOURCE INDEX; several frontend-to-backend links are shown as dashed and unverified because the frontend request wiring was not excerpted.

Main entry points: [`backend/main.py`](https://github.com/shreyas8905/resector/blob/main/backend/main.py) (HTTP API), [`backend/services/rag_agent.py`](https://github.com/shreyas8905/resector/blob/main/backend/services/rag_agent.py) (Grounded chat agent), [`backend/tools.py`](https://github.com/shreyas8905/resector/blob/main/backend/tools.py) (Research tool logic), [`backend/database.py`](https://github.com/shreyas8905/resector/blob/main/backend/database.py) (Session database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Research experience"]
  node_workspace["Research workspace<br/>[page.tsx]"]
  node_paperchat["Paper chat<br/>[page.tsx]"]
  node_graphui["Citation graph<br/>[PaperGraphView.tsx]"]
  node_sifterui["Methodology sifter<br/>[SifterTool.tsx]"]
  node_critiqueui["Adversarial critique<br/>[CritiqueTool.tsx]"]
  node_jargonui["Jargon simplifier<br/>[JargonTool.tsx]"]
  node_historyui["Research archive"]
  node_toolui["Tool presentation<br/>[ToolUI.tsx]"]
  node_settingsui["Provider settings<br/>[SettingsDrawer.tsx]"]
end

subgraph group_api["API orchestration"]
  node_api["HTTP API<br/>[main.py]"]
  node_tools["Research tool logic<br/>[tools.py]"]
end

subgraph group_research["Research services"]
  node_rag["Grounded chat agent<br/>[rag_agent.py]"]
  node_pdf["PDF indexing<br/>[pdf_processor.py]"]
  node_graph["Citation traversal<br/>[graph_service.py]"]
  node_providers["LLM provider factory"]
end

subgraph group_state["Persistence and configuration"]
  node_sql[("Session database<br/>[database.py]")]
  node_vectors[("Chroma vectors<br/>[database.py]")]
  node_config["Runtime configuration<br/>[config.py]"]
end

node_researcher(("Researcher"))
node_academic["Academic metadata sources"]
node_websearch["Web search"]
node_llmservices["LLM providers"]

node_researcher -->|"explores"| node_workspace
node_researcher -->|"chats with papers"| node_paperchat
node_researcher -->|"maps literature"| node_graphui
node_researcher -->|"extracts methods"| node_sifterui
node_researcher -->|"stress-tests claims"| node_critiqueui
node_researcher -->|"simplifies terms"| node_jargonui
node_researcher -->|"searches archive"| node_historyui
node_sifterui -->|"uses presentation"| node_toolui
node_critiqueui -->|"uses presentation"| node_toolui
node_jargonui -->|"uses presentation"| node_toolui
node_workspace -.->|"calls API"| node_api
node_paperchat -.->|"calls API"| node_api
node_graphui -.->|"requests graph"| node_api
node_sifterui -.->|"requests extraction"| node_api
node_critiqueui -.->|"requests critique"| node_api
node_jargonui -.->|"requests simplification"| node_api
node_api -->|"runs tools"| node_tools
node_api -->|"handles chat"| node_rag
node_api -->|"starts indexing"| node_pdf
node_api -->|"generates graph"| node_graph
node_api -->|"validates providers"| node_providers
node_api -->|"stores sessions"| node_sql
node_pdf -->|"updates documents"| node_sql
node_pdf -->|"indexes chunks"| node_vectors
node_rag -->|"retrieves chunks"| node_vectors
node_rag -->|"loads chat history"| node_sql
node_rag -->|"uses web search"| node_tools
node_tools -->|"creates agent model"| node_providers
node_tools -->|"logs research"| node_sql
node_tools -->|"indexes research"| node_vectors
node_providers -->|"creates model"| node_llmservices
node_rag -->|"creates chat model"| node_providers
node_graph -->|"queries papers"| node_academic
node_tools -->|"searches literature"| node_websearch
node_rag -.->|"optionally searches"| node_websearch
node_sql -->|"reads database URL"| node_config

click node_workspace "https://github.com/shreyas8905/resector/blob/main/frontend/src/app/page.tsx"
click node_paperchat "https://github.com/shreyas8905/resector/blob/main/frontend/src/app/paper-chat/page.tsx"
click node_graphui "https://github.com/shreyas8905/resector/blob/main/frontend/src/components/PaperGraphView.tsx"
click node_sifterui "https://github.com/shreyas8905/resector/blob/main/frontend/src/components/SifterTool.tsx"
click node_critiqueui "https://github.com/shreyas8905/resector/blob/main/frontend/src/components/CritiqueTool.tsx"
click node_jargonui "https://github.com/shreyas8905/resector/blob/main/frontend/src/components/JargonTool.tsx"
click node_historyui "https://github.com/shreyas8905/resector/blob/main/frontend/src/components/ResearchHistory.tsx"
click node_toolui "https://github.com/shreyas8905/resector/blob/main/frontend/src/components/ToolUI.tsx"
click node_settingsui "https://github.com/shreyas8905/resector/blob/main/frontend/src/components/SettingsDrawer.tsx"
click node_api "https://github.com/shreyas8905/resector/blob/main/backend/main.py"
click node_tools "https://github.com/shreyas8905/resector/blob/main/backend/tools.py"
click node_rag "https://github.com/shreyas8905/resector/blob/main/backend/services/rag_agent.py"
click node_pdf "https://github.com/shreyas8905/resector/blob/main/backend/services/pdf_processor.py"
click node_graph "https://github.com/shreyas8905/resector/blob/main/backend/services/graph_service.py"
click node_providers "https://github.com/shreyas8905/resector/blob/main/backend/provider_factory.py"
click node_sql "https://github.com/shreyas8905/resector/blob/main/backend/database.py"
click node_vectors "https://github.com/shreyas8905/resector/blob/main/backend/database.py"
click node_config "https://github.com/shreyas8905/resector/blob/main/backend/config.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_workspace,node_paperchat,node_graphui,node_sifterui,node_critiqueui,node_jargonui,node_historyui,node_toolui,node_settingsui toneBlue
class node_api,node_tools toneAmber
class node_rag,node_pdf,node_graph,node_providers toneMint
class node_sql,node_vectors,node_config toneRose
class node_researcher,node_academic,node_websearch,node_llmservices toneIndigo
```

## Components

### Research experience

- [Research workspace](https://github.com/shreyas8905/resector/blob/main/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`
- [Paper chat](https://github.com/shreyas8905/resector/blob/main/frontend/src/app/paper-chat/page.tsx): `frontend/src/app/paper-chat/page.tsx`
- [Citation graph](https://github.com/shreyas8905/resector/blob/main/frontend/src/components/PaperGraphView.tsx): `frontend/src/components/PaperGraphView.tsx`
- [Methodology sifter](https://github.com/shreyas8905/resector/blob/main/frontend/src/components/SifterTool.tsx): `frontend/src/components/SifterTool.tsx`
- [Adversarial critique](https://github.com/shreyas8905/resector/blob/main/frontend/src/components/CritiqueTool.tsx): `frontend/src/components/CritiqueTool.tsx`
- [Jargon simplifier](https://github.com/shreyas8905/resector/blob/main/frontend/src/components/JargonTool.tsx): `frontend/src/components/JargonTool.tsx`
- [Research archive](https://github.com/shreyas8905/resector/blob/main/frontend/src/components/ResearchHistory.tsx): `frontend/src/components/ResearchHistory.tsx`
- [Tool presentation](https://github.com/shreyas8905/resector/blob/main/frontend/src/components/ToolUI.tsx): `frontend/src/components/ToolUI.tsx`
- [Provider settings](https://github.com/shreyas8905/resector/blob/main/frontend/src/components/SettingsDrawer.tsx): `frontend/src/components/SettingsDrawer.tsx`

### API orchestration

- [HTTP API](https://github.com/shreyas8905/resector/blob/main/backend/main.py): `backend/main.py`
- [Research tool logic](https://github.com/shreyas8905/resector/blob/main/backend/tools.py): `backend/tools.py`

### Research services

- [Grounded chat agent](https://github.com/shreyas8905/resector/blob/main/backend/services/rag_agent.py): `backend/services/rag_agent.py`
- [PDF indexing](https://github.com/shreyas8905/resector/blob/main/backend/services/pdf_processor.py): `backend/services/pdf_processor.py`
- [Citation traversal](https://github.com/shreyas8905/resector/blob/main/backend/services/graph_service.py): `backend/services/graph_service.py`
- [LLM provider factory](https://github.com/shreyas8905/resector/blob/main/backend/provider_factory.py): `backend/provider_factory.py`

### Persistence and configuration

- [Session database](https://github.com/shreyas8905/resector/blob/main/backend/database.py): `backend/database.py`
- [Chroma vectors](https://github.com/shreyas8905/resector/blob/main/backend/database.py): `backend/database.py`
- [Runtime configuration](https://github.com/shreyas8905/resector/blob/main/backend/config.py): `backend/config.py`

### Other components

- **Researcher**
- **Academic metadata sources**
- **Web search**
- **LLM providers**

## Connections

- Researcher → Research workspace: explores (evidence: `README.md`)
- Researcher → Paper chat: chats with papers (evidence: `README.md`)
- Researcher → Citation graph: maps literature (evidence: `README.md`)
- Researcher → Methodology sifter: extracts methods (evidence: `README.md`)
- Researcher → Adversarial critique: stress-tests claims (evidence: `README.md`)
- Researcher → Jargon simplifier: simplifies terms (evidence: `README.md`)
- Researcher → Research archive: searches archive (evidence: `README.md`)
- Methodology sifter → Tool presentation: uses presentation (evidence: `frontend/src/components/SifterTool.tsx`)
- Adversarial critique → Tool presentation: uses presentation (evidence: `frontend/src/components/CritiqueTool.tsx`)
- Jargon simplifier → Tool presentation: uses presentation (evidence: `frontend/src/components/JargonTool.tsx`)
- Research workspace → HTTP API: calls API
- Paper chat → HTTP API: calls API
- Citation graph → HTTP API: requests graph
- Methodology sifter → HTTP API: requests extraction
- Adversarial critique → HTTP API: requests critique
- Jargon simplifier → HTTP API: requests simplification
- HTTP API → Research tool logic: runs tools (evidence: `backend/main.py`)
- HTTP API → Grounded chat agent: handles chat (evidence: `backend/main.py`)
- HTTP API → PDF indexing: starts indexing (evidence: `backend/main.py`)
- HTTP API → Citation traversal: generates graph (evidence: `backend/main.py`)
- HTTP API → LLM provider factory: validates providers (evidence: `backend/main.py`)
- HTTP API → Session database: stores sessions (evidence: `backend/main.py`)
- PDF indexing → Session database: updates documents (evidence: `backend/services/pdf_processor.py`)
- PDF indexing → Chroma vectors: indexes chunks (evidence: `backend/services/pdf_processor.py`)
- Grounded chat agent → Chroma vectors: retrieves chunks (evidence: `backend/services/rag_agent.py`)
- Grounded chat agent → Session database: loads chat history (evidence: `backend/services/rag_agent.py`)
- Grounded chat agent → Research tool logic: uses web search (evidence: `backend/services/rag_agent.py`)
- Research tool logic → LLM provider factory: creates agent model (evidence: `backend/tools.py`)
- Research tool logic → Session database: logs research (evidence: `backend/tools.py`)
- Research tool logic → Chroma vectors: indexes research (evidence: `backend/tools.py`)
- LLM provider factory → LLM providers: creates model (evidence: `backend/provider_factory.py`)
- Grounded chat agent → LLM provider factory: creates chat model (evidence: `backend/services/rag_agent.py`)
- Citation traversal → Academic metadata sources: queries papers (evidence: `backend/services/graph_service.py`)
- Research tool logic → Web search: searches literature (evidence: `backend/tools.py`)
- Grounded chat agent → Web search: optionally searches (evidence: `backend/services/rag_agent.py`)
- Session database → Runtime configuration: reads database URL (evidence: `backend/database.py`)
