# atharva481/resin architecture

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

- Interactive diagram: https://gitdiagram.com/atharva481/resin
- Repository: https://github.com/atharva481/resin

## Overview

RESIN is an academic research workstation: researchers discover and organize papers, index full text, and ask questions answered from retrieved paper evidence with citations. The map includes the documented ingestion, multi-paper agent, summaries, and daily-triage capabilities. Some subsystem links are documented in the README but their implementation files were not sampled; those paths identify the existing enclosing directories, not inspected implementations.

Main entry points: [`backend/app/api/embed.py`](https://github.com/atharva481/resin/blob/main/backend/app/api/embed.py) (Index Endpoints), [`backend/app/api/chat.py`](https://github.com/atharva481/resin/blob/main/backend/app/api/chat.py) (Chat Endpoints), [`frontend/src/App.tsx`](https://github.com/atharva481/resin/blob/main/frontend/src/App.tsx) (Web App), [`backend/app/main.py`](https://github.com/atharva481/resin/blob/main/backend/app/main.py) (FastAPI App)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Research Workspace"]
  node_webapp["Web App<br/>[App.tsx]"]
  node_feed["Discovery Feed<br/>[Feed.tsx]"]
  node_papers["Paper Views<br/>[Papers.tsx]"]
  node_library["Library<br/>[Library.tsx]"]
  node_paperchat["Paper Chat<br/>[PaperChat.tsx]"]
  node_frontend_api["RAG API Client<br/>[ragApi.ts]"]
end

subgraph group_api["Backend API"]
  node_backend["FastAPI App<br/>[main.py]"]
  node_auth["Token Auth<br/>[auth.py]"]
  node_chat_api["Chat Endpoints<br/>[chat.py]"]
  node_index_api["Index Endpoints<br/>[embed.py]"]
  node_search_api["Paper Search Proxy<br/>[search.py]"]
end

subgraph group_ingestion["Paper Ingestion"]
  node_resolution["Canonical Resolution"]
  node_open_access["Open-Access Discovery<br/>[open_access.py]"]
  node_pdf["PDF Extraction<br/>[pdf.py]"]
  node_indexing["Chunking and Indexing<br/>[indexing.py]"]
end

subgraph group_intelligence["Search and Synthesis"]
  node_embeddings["Embedding Service<br/>[embeddings.py]"]
  node_retrieval["Vector Retrieval<br/>[retrieval.py]"]
  node_rag["Grounded Chat and Summary<br/>[rag.py]"]
  node_agent["Research Agent<br/>[agent.py]"]
  node_agent_tools["Agent Tools<br/>[tools.py]"]
  node_chat_history["Chat History<br/>[chat_service.py]"]
end

subgraph group_triage["Daily Triage"]
  node_triage_worker["Daily Triage Worker<br/>[daily-triage.js]"]
  node_feed_ingest["Feed Ingestion<br/>[ingest-feeds.js]"]
end

node_researcher(("Researcher"))
node_database[("Supabase and pgvector<br/>[supabase.py]")]
node_gemini{{"Gemini Models"}}
node_scholarly_sources{{"Scholarly Sources"}}

node_researcher -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_feed
node_webapp -->|"routes to"| node_papers
node_webapp -->|"routes to"| node_library
node_papers -.->|"offers chat"| node_paperchat
node_paperchat -.->|"requests answers"| node_frontend_api
node_frontend_api -->|"calls API"| node_backend
node_backend -->|"mounts routes"| node_chat_api
node_backend -->|"mounts routes"| node_index_api
node_backend -->|"mounts routes"| node_search_api
node_chat_api -->|"validates users"| node_auth
node_chat_api -->|"delegates chat"| node_rag
node_chat_api -->|"dispatches agent"| node_agent
node_chat_api -->|"persists turns"| node_chat_history
node_index_api -->|"validates users"| node_auth
node_index_api -->|"resolves papers"| node_resolution
node_index_api -->|"discovers documents"| node_open_access
node_index_api -->|"extracts documents"| node_pdf
node_index_api -->|"starts indexing"| node_indexing
node_open_access -->|"searches sources"| node_scholarly_sources
node_indexing -->|"creates vectors"| node_embeddings
node_indexing -->|"writes index"| node_database
node_search_api -->|"proxies searches"| node_scholarly_sources
node_rag -->|"retrieves evidence"| node_retrieval
node_retrieval -->|"embeds queries"| node_embeddings
node_retrieval -->|"searches vectors"| node_database
node_rag -->|"generates answers"| node_gemini
node_embeddings -->|"requests embeddings"| node_gemini
node_agent -->|"uses tools"| node_agent_tools
node_agent_tools -->|"searches library"| node_retrieval
node_triage_worker -.->|"uses feed data"| node_feed_ingest
node_triage_worker -->|"queries papers"| node_scholarly_sources
node_triage_worker -->|"filters candidates"| node_gemini

click node_webapp "https://github.com/atharva481/resin/blob/main/frontend/src/App.tsx"
click node_feed "https://github.com/atharva481/resin/blob/main/frontend/src/pages/Feed.tsx"
click node_papers "https://github.com/atharva481/resin/blob/main/frontend/src/pages/Papers.tsx"
click node_library "https://github.com/atharva481/resin/blob/main/frontend/src/pages/Library.tsx"
click node_paperchat "https://github.com/atharva481/resin/blob/main/frontend/src/components/PaperChat.tsx"
click node_frontend_api "https://github.com/atharva481/resin/blob/main/frontend/src/lib/ragApi.ts"
click node_backend "https://github.com/atharva481/resin/blob/main/backend/app/main.py"
click node_auth "https://github.com/atharva481/resin/blob/main/backend/app/core/auth.py"
click node_chat_api "https://github.com/atharva481/resin/blob/main/backend/app/api/chat.py"
click node_index_api "https://github.com/atharva481/resin/blob/main/backend/app/api/embed.py"
click node_search_api "https://github.com/atharva481/resin/blob/main/backend/app/api/search.py"
click node_resolution "https://github.com/atharva481/resin/blob/main/backend/app/services/paper_resolution.py"
click node_open_access "https://github.com/atharva481/resin/blob/main/backend/app/services/open_access.py"
click node_pdf "https://github.com/atharva481/resin/blob/main/backend/app/services/pdf.py"
click node_indexing "https://github.com/atharva481/resin/blob/main/backend/app/services/indexing.py"
click node_embeddings "https://github.com/atharva481/resin/blob/main/backend/app/services/embeddings.py"
click node_retrieval "https://github.com/atharva481/resin/blob/main/backend/app/services/retrieval.py"
click node_rag "https://github.com/atharva481/resin/blob/main/backend/app/services/rag.py"
click node_agent "https://github.com/atharva481/resin/blob/main/backend/app/agent/agent.py"
click node_agent_tools "https://github.com/atharva481/resin/blob/main/backend/app/agent/tools.py"
click node_chat_history "https://github.com/atharva481/resin/blob/main/backend/app/services/chat_service.py"
click node_database "https://github.com/atharva481/resin/blob/main/backend/app/core/supabase.py"
click node_triage_worker "https://github.com/atharva481/resin/blob/main/resin-triage/daily-triage.js"
click node_feed_ingest "https://github.com/atharva481/resin/blob/main/resin-triage/ingest-feeds.js"

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_webapp,node_feed,node_papers,node_library,node_paperchat,node_frontend_api toneBlue
class node_backend,node_auth,node_chat_api,node_index_api,node_search_api,node_database toneAmber
class node_resolution,node_open_access,node_pdf,node_indexing toneMint
class node_embeddings,node_retrieval,node_rag,node_agent,node_agent_tools,node_chat_history toneRose
class node_triage_worker,node_feed_ingest,node_researcher,node_gemini,node_scholarly_sources toneIndigo
```

## Components

### Research Workspace

- [Web App](https://github.com/atharva481/resin/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Discovery Feed](https://github.com/atharva481/resin/blob/main/frontend/src/pages/Feed.tsx): `frontend/src/pages/Feed.tsx`
- [Paper Views](https://github.com/atharva481/resin/blob/main/frontend/src/pages/Papers.tsx): `frontend/src/pages/Papers.tsx`
- [Library](https://github.com/atharva481/resin/blob/main/frontend/src/pages/Library.tsx): `frontend/src/pages/Library.tsx`
- [Paper Chat](https://github.com/atharva481/resin/blob/main/frontend/src/components/PaperChat.tsx): `frontend/src/components/PaperChat.tsx`
- [RAG API Client](https://github.com/atharva481/resin/blob/main/frontend/src/lib/ragApi.ts): `frontend/src/lib/ragApi.ts`

### Backend API

- [FastAPI App](https://github.com/atharva481/resin/blob/main/backend/app/main.py): `backend/app/main.py`
- [Token Auth](https://github.com/atharva481/resin/blob/main/backend/app/core/auth.py): `backend/app/core/auth.py`
- [Chat Endpoints](https://github.com/atharva481/resin/blob/main/backend/app/api/chat.py): `backend/app/api/chat.py`
- [Index Endpoints](https://github.com/atharva481/resin/blob/main/backend/app/api/embed.py): `backend/app/api/embed.py`
- [Paper Search Proxy](https://github.com/atharva481/resin/blob/main/backend/app/api/search.py): `backend/app/api/search.py`

### Paper Ingestion

- [Canonical Resolution](https://github.com/atharva481/resin/blob/main/backend/app/services/paper_resolution.py): `backend/app/services/paper_resolution.py`
- [Open-Access Discovery](https://github.com/atharva481/resin/blob/main/backend/app/services/open_access.py): `backend/app/services/open_access.py`
- [PDF Extraction](https://github.com/atharva481/resin/blob/main/backend/app/services/pdf.py): `backend/app/services/pdf.py`
- [Chunking and Indexing](https://github.com/atharva481/resin/blob/main/backend/app/services/indexing.py): `backend/app/services/indexing.py`

### Search and Synthesis

- [Embedding Service](https://github.com/atharva481/resin/blob/main/backend/app/services/embeddings.py): `backend/app/services/embeddings.py`
- [Vector Retrieval](https://github.com/atharva481/resin/blob/main/backend/app/services/retrieval.py): `backend/app/services/retrieval.py`
- [Grounded Chat and Summary](https://github.com/atharva481/resin/blob/main/backend/app/services/rag.py): `backend/app/services/rag.py`
- [Research Agent](https://github.com/atharva481/resin/blob/main/backend/app/agent/agent.py): `backend/app/agent/agent.py`
- [Agent Tools](https://github.com/atharva481/resin/blob/main/backend/app/agent/tools.py): `backend/app/agent/tools.py`
- [Chat History](https://github.com/atharva481/resin/blob/main/backend/app/services/chat_service.py): `backend/app/services/chat_service.py`

### Daily Triage

- [Daily Triage Worker](https://github.com/atharva481/resin/blob/main/resin-triage/daily-triage.js): `resin-triage/daily-triage.js`
- [Feed Ingestion](https://github.com/atharva481/resin/blob/main/resin-triage/ingest-feeds.js): `resin-triage/ingest-feeds.js`

### Other components

- **Researcher**
- [Supabase and pgvector](https://github.com/atharva481/resin/blob/main/backend/app/core/supabase.py): `backend/app/core/supabase.py`
- **Gemini Models**
- **Scholarly Sources**

## Connections

- Researcher → Web App: uses (evidence: `README.md`)
- Web App → Discovery Feed: routes to (evidence: `frontend/src/App.tsx`)
- Web App → Paper Views: routes to (evidence: `frontend/src/App.tsx`)
- Web App → Library: routes to (evidence: `frontend/src/App.tsx`)
- Paper Views → Paper Chat: offers chat
- Paper Chat → RAG API Client: requests answers
- RAG API Client → FastAPI App: calls API (evidence: `README.md`)
- FastAPI App → Chat Endpoints: mounts routes (evidence: `backend/app/main.py`)
- FastAPI App → Index Endpoints: mounts routes (evidence: `backend/app/main.py`)
- FastAPI App → Paper Search Proxy: mounts routes (evidence: `backend/app/main.py`)
- Chat Endpoints → Token Auth: validates users (evidence: `backend/app/api/chat.py`)
- Chat Endpoints → Grounded Chat and Summary: delegates chat (evidence: `backend/app/api/chat.py`)
- Chat Endpoints → Research Agent: dispatches agent (evidence: `backend/app/api/chat.py`)
- Chat Endpoints → Chat History: persists turns (evidence: `backend/app/api/chat.py`)
- Index Endpoints → Token Auth: validates users (evidence: `backend/app/api/embed.py`)
- Index Endpoints → Canonical Resolution: resolves papers (evidence: `backend/app/api/embed.py`)
- Index Endpoints → Open-Access Discovery: discovers documents (evidence: `backend/app/api/embed.py`)
- Index Endpoints → PDF Extraction: extracts documents (evidence: `backend/app/api/embed.py`)
- Index Endpoints → Chunking and Indexing: starts indexing (evidence: `backend/app/api/embed.py`)
- Open-Access Discovery → Scholarly Sources: searches sources (evidence: `README.md`)
- Chunking and Indexing → Embedding Service: creates vectors (evidence: `backend/app/services/indexing.py`)
- Chunking and Indexing → Supabase and pgvector: writes index (evidence: `backend/app/services/indexing.py`)
- Paper Search Proxy → Scholarly Sources: proxies searches (evidence: `backend/app/api/search.py`)
- Grounded Chat and Summary → Vector Retrieval: retrieves evidence (evidence: `backend/app/services/rag.py`)
- Vector Retrieval → Embedding Service: embeds queries (evidence: `backend/app/services/retrieval.py`)
- Vector Retrieval → Supabase and pgvector: searches vectors (evidence: `backend/app/services/retrieval.py`)
- Grounded Chat and Summary → Gemini Models: generates answers (evidence: `README.md`)
- Embedding Service → Gemini Models: requests embeddings (evidence: `backend/app/services/embeddings.py`)
- Research Agent → Agent Tools: uses tools (evidence: `README.md`)
- Agent Tools → Vector Retrieval: searches library (evidence: `backend/app/agent/tools.py`)
- Daily Triage Worker → Feed Ingestion: uses feed data
- Daily Triage Worker → Scholarly Sources: queries papers (evidence: `README.md`)
- Daily Triage Worker → Gemini Models: filters candidates (evidence: `README.md`)
