# campusx-official/rag-papeer-project architecture

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

- Interactive diagram: https://gitdiagram.com/campusx-official/rag-papeer-project
- Repository: https://github.com/campusx-official/rag-papeer-project

## Overview

Papeer is a Streamlit research-paper Q&A app. Users create chat sessions, add files or arXiv papers, then ask questions; the app streams answers from a LangGraph workflow that can retrieve paper passages, assess relevance, rewrite a query, verify claims, or answer directly. The app also offers a `/btw` side channel for general questions and optional live web search. Uploads are chunked before indexing in session-specific Qdrant collections. Workflow routing details are only partly excerpted, so internal graph transitions are not expanded here.

Main entry points: [`app.py`](https://github.com/campusx-official/rag-papeer-project/blob/main/app.py) (Streamlit app), [`backend/rag_graph.py`](https://github.com/campusx-official/rag-papeer-project/blob/main/backend/rag_graph.py) (RAG graph), [`backend/btw_handler.py`](https://github.com/campusx-official/rag-papeer-project/blob/main/backend/btw_handler.py) (BTW handler), [`backend/vector_store.py`](https://github.com/campusx-official/rag-papeer-project/blob/main/backend/vector_store.py) (Vector store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Chat and sessions"]
  node_app["Streamlit app<br/>[app.py]"]
  node_sessions["Chat sessions<br/>[app.py]"]
end

subgraph group_documents["Paper ingestion"]
  node_ingest["Paper loading<br/>[paper_loader.py]"]
end

subgraph group_research["Research workflow"]
  node_rag["RAG graph<br/>[rag_graph.py]"]
  node_models["Decision models<br/>[models.py]"]
  node_btw["BTW handler<br/>[btw_handler.py]"]
end

subgraph group_storage["Index and persistence"]
  node_vectors[("Vector store<br/>[vector_store.py]")]
end

node_user(("Researcher"))
node_qdrant[("Qdrant")]
node_openai{{"OpenAI models"}}
node_tavily{{"Tavily search"}}

node_user -->|"asks or uploads"| node_app
node_app -->|"loads and saves"| node_sessions
node_app -->|"loads papers"| node_ingest
node_app -->|"adds and lists"| node_vectors
node_app -->|"streams queries"| node_rag
node_app -->|"routes /btw"| node_btw
node_rag -->|"searches passages"| node_vectors
node_rag -->|"uses decisions"| node_models
node_btw -->|"structures routing"| node_models
node_btw -->|"routes and answers"| node_openai
node_btw -->|"searches when needed"| node_tavily
node_rag -->|"routes and answers"| node_openai
node_rag -->|"searches web"| node_tavily
node_vectors -->|"stores vectors"| node_qdrant

click node_app "https://github.com/campusx-official/rag-papeer-project/blob/main/app.py"
click node_sessions "https://github.com/campusx-official/rag-papeer-project/blob/main/app.py"
click node_ingest "https://github.com/campusx-official/rag-papeer-project/blob/main/backend/paper_loader.py"
click node_rag "https://github.com/campusx-official/rag-papeer-project/blob/main/backend/rag_graph.py"
click node_models "https://github.com/campusx-official/rag-papeer-project/blob/main/backend/models.py"
click node_btw "https://github.com/campusx-official/rag-papeer-project/blob/main/backend/btw_handler.py"
click node_vectors "https://github.com/campusx-official/rag-papeer-project/blob/main/backend/vector_store.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_sessions toneBlue
class node_ingest,node_qdrant toneAmber
class node_rag,node_models,node_btw toneMint
class node_vectors toneRose
class node_user,node_openai,node_tavily toneIndigo
```

## Components

### Chat and sessions

- [Streamlit app](https://github.com/campusx-official/rag-papeer-project/blob/main/app.py): `app.py`
- [Chat sessions](https://github.com/campusx-official/rag-papeer-project/blob/main/app.py): `app.py`

### Paper ingestion

- [Paper loading](https://github.com/campusx-official/rag-papeer-project/blob/main/backend/paper_loader.py): `backend/paper_loader.py`

### Research workflow

- [RAG graph](https://github.com/campusx-official/rag-papeer-project/blob/main/backend/rag_graph.py): `backend/rag_graph.py`
- [Decision models](https://github.com/campusx-official/rag-papeer-project/blob/main/backend/models.py): `backend/models.py`
- [BTW handler](https://github.com/campusx-official/rag-papeer-project/blob/main/backend/btw_handler.py): `backend/btw_handler.py`

### Index and persistence

- [Vector store](https://github.com/campusx-official/rag-papeer-project/blob/main/backend/vector_store.py): `backend/vector_store.py`

### Other components

- **Researcher**
- **Qdrant**
- **OpenAI models**
- **Tavily search**

## Connections

- Researcher → Streamlit app: asks or uploads (evidence: `app.py`)
- Streamlit app → Chat sessions: loads and saves (evidence: `app.py`)
- Streamlit app → Paper loading: loads papers (evidence: `app.py`)
- Streamlit app → Vector store: adds and lists (evidence: `app.py`)
- Streamlit app → RAG graph: streams queries (evidence: `app.py`)
- Streamlit app → BTW handler: routes /btw (evidence: `app.py`)
- RAG graph → Vector store: searches passages (evidence: `backend/rag_graph.py`)
- RAG graph → Decision models: uses decisions (evidence: `backend/rag_graph.py`)
- BTW handler → Decision models: structures routing (evidence: `backend/btw_handler.py`)
- BTW handler → OpenAI models: routes and answers (evidence: `backend/btw_handler.py`)
- BTW handler → Tavily search: searches when needed (evidence: `backend/btw_handler.py`)
- RAG graph → OpenAI models: routes and answers (evidence: `backend/rag_graph.py`)
- RAG graph → Tavily search: searches web (evidence: `backend/rag_graph.py`)
- Vector store → Qdrant: stores vectors (evidence: `backend/vector_store.py`)
