# arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack architecture

> Architecture diagram of the GitHub repository arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack
- Repository: https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack

## Overview

RAG PDF Chat is a browser-based document assistant: users upload a PDF, then ask questions grounded in its contents. The backend extracts and chunks the document, embeds and indexes it per anonymous session, retrieves relevant passages, and generates answers through a multi-agent pipeline with provider failover; answers may stream over SSE. The frontend also offers local chat history and preferences, plus health/status and optional Sentry capabilities. Some connections are supported by README documentation rather than sampled implementation; unsampled details are not inferred.

Main entry points: [`frontend/src/components/chat/chat-container.tsx`](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/frontend/src/components/chat/chat-container.tsx) (Chat interface), [`backend/app/main.py`](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/services/vector_store.py`](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/services/vector_store.py) (FAISS index and retrieval), [`backend/app/routes/upload.py`](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/routes/upload.py) (PDF upload)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser app"]
  node_chat_ui["Chat interface<br/>[chat-container.tsx]"]
  node_chat_parts["Chat controls"]
  node_local_history[("Local chat data<br/>[storage.ts]")]
  node_session_prefs["Session and preferences<br/>[chat-session.ts]"]
  node_app_routes["App routes<br/>[App.tsx]"]
end

subgraph group_api["API routes"]
  node_api_service["FastAPI application<br/>[main.py]"]
  node_upload_route["PDF upload<br/>[upload.py]"]
  node_chat_route["Chat endpoints<br/>[chat.py]"]
  node_status_routes["Health and status"]
end

subgraph group_rag["Document RAG"]
  node_pdf_processing["PDF extraction and chunking<br/>[pdf_processor.py]"]
  node_vector_store[("FAISS index and retrieval<br/>[vector_store.py]")]
  node_embedding_clients["Embedding providers"]
end

subgraph group_generation["Answer generation"]
  node_agent_pipeline["Multi-agent pipeline<br/>[pipeline.py]"]
  node_agent_stages["Agent stages"]
  node_llm["LLM failover<br/>[llm_service.py]"]
end

subgraph group_operations["Session and operations"]
  node_session_registry["Session vector registry"]
  node_rate_limits["Rate limiting<br/>[ip_rate_limit.py]"]
  node_usage["Usage counters<br/>[usage_counters.py]"]
  node_cleanup["FAISS session cleanup"]
end

node_visitor(("Visitor"))
node_providers["External model providers"]
node_sentry["Sentry"]

node_visitor -->|"asks questions"| node_chat_ui
node_app_routes -->|"routes to"| node_chat_ui
node_chat_ui -->|"uses controls"| node_chat_parts
node_chat_ui -->|"stores history"| node_local_history
node_chat_ui -->|"uses session identity"| node_session_prefs
node_chat_ui -->|"calls API"| node_api_service
node_api_service -->|"registers routes"| node_upload_route
node_api_service -->|"registers routes"| node_chat_route
node_api_service -->|"registers routes"| node_status_routes
node_upload_route -->|"processes PDF"| node_pdf_processing
node_upload_route -->|"gets session store"| node_session_registry
node_upload_route -->|"writes chunks"| node_vector_store
node_session_registry -->|"creates stores"| node_vector_store
node_vector_store -->|"creates embeddings"| node_embedding_clients
node_vector_store -.->|"requests embeddings"| node_providers
node_chat_route -->|"runs pipeline"| node_agent_pipeline
node_chat_route -->|"checks ask limit"| node_rate_limits
node_chat_route -->|"updates counters"| node_usage
node_agent_pipeline -->|"retrieves passages"| node_vector_store
node_agent_pipeline -->|"executes stages"| node_agent_stages
node_agent_pipeline -->|"generates answer"| node_llm
node_llm -->|"fails over"| node_providers
node_api_service -->|"prunes indexes"| node_cleanup
node_chat_ui -.->|"reports errors"| node_sentry

click node_chat_ui "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/frontend/src/components/chat/chat-container.tsx"
click node_chat_parts "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/tree/main/frontend/src/components/chat"
click node_local_history "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/frontend/src/lib/storage.ts"
click node_session_prefs "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/frontend/src/lib/chat-session.ts"
click node_app_routes "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/frontend/src/App.tsx"
click node_api_service "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/main.py"
click node_upload_route "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/routes/upload.py"
click node_chat_route "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/routes/chat.py"
click node_status_routes "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/tree/main/backend/app/routes"
click node_pdf_processing "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/services/pdf_processor.py"
click node_session_registry "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/services/session_vector_registry.py"
click node_vector_store "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/services/vector_store.py"
click node_embedding_clients "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/services/embedding_clients.py"
click node_agent_pipeline "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/agents/pipeline.py"
click node_agent_stages "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/tree/main/backend/app/agents"
click node_llm "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/services/llm_service.py"
click node_rate_limits "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/services/ip_rate_limit.py"
click node_usage "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/services/usage_counters.py"
click node_cleanup "https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/services/faiss_session_cleanup.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_chat_ui,node_chat_parts,node_local_history,node_session_prefs,node_app_routes toneBlue
class node_api_service,node_upload_route,node_chat_route,node_status_routes toneAmber
class node_pdf_processing,node_vector_store,node_embedding_clients toneMint
class node_agent_pipeline,node_agent_stages,node_llm toneRose
class node_session_registry,node_rate_limits,node_usage,node_cleanup,node_visitor,node_providers,node_sentry toneIndigo
```

## Components

### Browser app

- [Chat interface](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/frontend/src/components/chat/chat-container.tsx): `frontend/src/components/chat/chat-container.tsx`
- [Chat controls](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/tree/main/frontend/src/components/chat): `frontend/src/components/chat`
- [Local chat data](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/frontend/src/lib/storage.ts): `frontend/src/lib/storage.ts`
- [Session and preferences](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/frontend/src/lib/chat-session.ts): `frontend/src/lib/chat-session.ts`
- [App routes](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`

### API routes

- [FastAPI application](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/main.py): `backend/app/main.py`
- [PDF upload](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/routes/upload.py): `backend/app/routes/upload.py`
- [Chat endpoints](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/routes/chat.py): `backend/app/routes/chat.py`
- [Health and status](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/tree/main/backend/app/routes): `backend/app/routes`

### Document RAG

- [PDF extraction and chunking](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/services/pdf_processor.py): `backend/app/services/pdf_processor.py`
- [FAISS index and retrieval](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/services/vector_store.py): `backend/app/services/vector_store.py`
- [Embedding providers](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/services/embedding_clients.py): `backend/app/services/embedding_clients.py`

### Answer generation

- [Multi-agent pipeline](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/agents/pipeline.py): `backend/app/agents/pipeline.py`
- [Agent stages](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/tree/main/backend/app/agents): `backend/app/agents`
- [LLM failover](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/services/llm_service.py): `backend/app/services/llm_service.py`

### Session and operations

- [Session vector registry](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/services/session_vector_registry.py): `backend/app/services/session_vector_registry.py`
- [Rate limiting](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/services/ip_rate_limit.py): `backend/app/services/ip_rate_limit.py`
- [Usage counters](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/services/usage_counters.py): `backend/app/services/usage_counters.py`
- [FAISS session cleanup](https://github.com/arnobt78/rag-pdf-chat-multi-agent-pipeline--python-react-fullstack/blob/main/backend/app/services/faiss_session_cleanup.py): `backend/app/services/faiss_session_cleanup.py`

### Other components

- **Visitor**
- **External model providers**
- **Sentry**

## Connections

- Visitor → Chat interface: asks questions (evidence: `README.md`)
- App routes → Chat interface: routes to (evidence: `frontend/src/App.tsx`)
- Chat interface → Chat controls: uses controls (evidence: `frontend/src/components/chat/chat-container.tsx`)
- Chat interface → Local chat data: stores history (evidence: `README.md`)
- Chat interface → Session and preferences: uses session identity (evidence: `README.md`)
- Chat interface → FastAPI application: calls API (evidence: `README.md`)
- FastAPI application → PDF upload: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Chat endpoints: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Health and status: registers routes (evidence: `backend/app/main.py`)
- PDF upload → PDF extraction and chunking: processes PDF (evidence: `backend/app/routes/upload.py`)
- PDF upload → Session vector registry: gets session store (evidence: `backend/app/routes/upload.py`)
- PDF upload → FAISS index and retrieval: writes chunks (evidence: `backend/app/routes/upload.py`)
- Session vector registry → FAISS index and retrieval: creates stores (evidence: `backend/app/services/session_vector_registry.py`)
- FAISS index and retrieval → Embedding providers: creates embeddings (evidence: `backend/app/services/vector_store.py`)
- FAISS index and retrieval → External model providers: requests embeddings
- Chat endpoints → Multi-agent pipeline: runs pipeline (evidence: `backend/app/routes/chat.py`)
- Chat endpoints → Rate limiting: checks ask limit (evidence: `backend/app/routes/chat.py`)
- Chat endpoints → Usage counters: updates counters (evidence: `backend/app/routes/chat.py`)
- Multi-agent pipeline → FAISS index and retrieval: retrieves passages (evidence: `backend/app/agents/pipeline.py`)
- Multi-agent pipeline → Agent stages: executes stages (evidence: `backend/app/agents/pipeline.py`)
- Multi-agent pipeline → LLM failover: generates answer (evidence: `backend/app/agents/pipeline.py`)
- LLM failover → External model providers: fails over (evidence: `backend/app/services/llm_service.py`)
- FastAPI application → FAISS session cleanup: prunes indexes (evidence: `backend/app/main.py`)
- Chat interface → Sentry: reports errors
