# gangouch1/rag-pdf-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/gangouch1/rag-pdf-assistant
- Repository: https://github.com/gangouch1/rag-pdf-assistant

## Overview

This is a Streamlit PDF question-answering app backed by FastAPI-hosted Inngest functions. Users upload PDFs for background parsing, chunking, embedding, and Qdrant storage; questions trigger retrieval and a Gemini answer, which the UI displays with sources. The graph follows the sampled event calls and README architecture. The README also describes retries, throttling, and monitoring, but their implementation is not visible in the sampled source.

Main entry points: [`main.py`](https://github.com/gangouch1/rag-pdf-assistant/blob/main/main.py) (Ingest function), [`streamlit_app.py`](https://github.com/gangouch1/rag-pdf-assistant/blob/main/streamlit_app.py) (Streamlit UI), [`data_loader.py`](https://github.com/gangouch1/rag-pdf-assistant/blob/main/data_loader.py) (Text embedding), [`vector_db.py`](https://github.com/gangouch1/rag-pdf-assistant/blob/main/vector_db.py) (Qdrant storage adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["User interface"]
  node_streamlit["Streamlit UI<br/>[streamlit_app.py]"]
  node_uploads["Uploaded PDFs"]
end

subgraph group_orchestration["Event orchestration"]
  node_api["FastAPI event host<br/>[main.py]"]
  node_types["RAG data models<br/>[custom_types.py]"]
end

subgraph group_ingestion["PDF ingestion"]
  node_ingest["Ingest function<br/>[main.py]"]
  node_pdf_processing["PDF parsing and chunking<br/>[data_loader.py]"]
  node_embedding["Text embedding<br/>[data_loader.py]"]
  node_qdrant_adapter["Qdrant storage adapter<br/>[vector_db.py]"]
end

subgraph group_retrieval["Question answering"]
  node_query["Query function<br/>[main.py]"]
  node_retrieval_logic["Vector retrieval<br/>[vector_db.py]"]
  node_answer["Contextual answer generation<br/>[main.py]"]
end

subgraph group_services["External services"]
  node_inngest["Inngest"]
  node_gemini{{"Google Gemini"}}
  node_qdrant[("Qdrant vector database")]
end

node_user(("User"))

node_user -->|"uploads and asks"| node_streamlit
node_streamlit -->|"saves PDF"| node_uploads
node_streamlit -->|"sends events"| node_inngest
node_inngest -->|"dispatches events"| node_api
node_api -->|"serves function"| node_ingest
node_api -->|"serves function"| node_query
node_ingest -->|"loads and chunks"| node_pdf_processing
node_ingest -->|"embeds chunks"| node_embedding
node_embedding -->|"requests embeddings"| node_gemini
node_ingest -->|"upserts vectors"| node_qdrant_adapter
node_qdrant_adapter -->|"stores and searches"| node_qdrant
node_query -->|"embeds question"| node_embedding
node_query -->|"searches vectors"| node_retrieval_logic
node_query -->|"passes retrieved context"| node_answer
node_answer -->|"generates answer"| node_gemini
node_query -->|"uses result models"| node_types
node_ingest -->|"uses ingestion models"| node_types
node_streamlit -->|"polls run output"| node_inngest
node_inngest -->|"returns run output"| node_streamlit

click node_streamlit "https://github.com/gangouch1/rag-pdf-assistant/blob/main/streamlit_app.py"
click node_uploads "https://github.com/gangouch1/rag-pdf-assistant/tree/main/uploads"
click node_api "https://github.com/gangouch1/rag-pdf-assistant/blob/main/main.py"
click node_ingest "https://github.com/gangouch1/rag-pdf-assistant/blob/main/main.py"
click node_query "https://github.com/gangouch1/rag-pdf-assistant/blob/main/main.py"
click node_types "https://github.com/gangouch1/rag-pdf-assistant/blob/main/custom_types.py"
click node_pdf_processing "https://github.com/gangouch1/rag-pdf-assistant/blob/main/data_loader.py"
click node_embedding "https://github.com/gangouch1/rag-pdf-assistant/blob/main/data_loader.py"
click node_retrieval_logic "https://github.com/gangouch1/rag-pdf-assistant/blob/main/vector_db.py"
click node_answer "https://github.com/gangouch1/rag-pdf-assistant/blob/main/main.py"
click node_qdrant_adapter "https://github.com/gangouch1/rag-pdf-assistant/blob/main/vector_db.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_streamlit,node_uploads,node_user toneBlue
class node_api,node_types toneAmber
class node_ingest,node_pdf_processing,node_embedding,node_qdrant_adapter toneMint
class node_query,node_retrieval_logic,node_answer toneRose
class node_inngest,node_gemini,node_qdrant toneIndigo
```

## Components

### User interface

- [Streamlit UI](https://github.com/gangouch1/rag-pdf-assistant/blob/main/streamlit_app.py): `streamlit_app.py`
- [Uploaded PDFs](https://github.com/gangouch1/rag-pdf-assistant/tree/main/uploads): `uploads`

### Event orchestration

- [FastAPI event host](https://github.com/gangouch1/rag-pdf-assistant/blob/main/main.py): `main.py`
- [RAG data models](https://github.com/gangouch1/rag-pdf-assistant/blob/main/custom_types.py): `custom_types.py`

### PDF ingestion

- [Ingest function](https://github.com/gangouch1/rag-pdf-assistant/blob/main/main.py): `main.py`
- [PDF parsing and chunking](https://github.com/gangouch1/rag-pdf-assistant/blob/main/data_loader.py): `data_loader.py`
- [Text embedding](https://github.com/gangouch1/rag-pdf-assistant/blob/main/data_loader.py): `data_loader.py`
- [Qdrant storage adapter](https://github.com/gangouch1/rag-pdf-assistant/blob/main/vector_db.py): `vector_db.py`

### Question answering

- [Query function](https://github.com/gangouch1/rag-pdf-assistant/blob/main/main.py): `main.py`
- [Vector retrieval](https://github.com/gangouch1/rag-pdf-assistant/blob/main/vector_db.py): `vector_db.py`
- [Contextual answer generation](https://github.com/gangouch1/rag-pdf-assistant/blob/main/main.py): `main.py`

### External services

- **Inngest**
- **Google Gemini**
- **Qdrant vector database**

### Other components

- **User**

## Connections

- User → Streamlit UI: uploads and asks (evidence: `streamlit_app.py`)
- Streamlit UI → Uploaded PDFs: saves PDF (evidence: `streamlit_app.py`)
- Streamlit UI → Inngest: sends events (evidence: `streamlit_app.py`)
- Inngest → FastAPI event host: dispatches events (evidence: `main.py`)
- FastAPI event host → Ingest function: serves function (evidence: `main.py`)
- FastAPI event host → Query function: serves function (evidence: `main.py`)
- Ingest function → PDF parsing and chunking: loads and chunks (evidence: `main.py`)
- Ingest function → Text embedding: embeds chunks (evidence: `main.py`)
- Text embedding → Google Gemini: requests embeddings (evidence: `data_loader.py`)
- Ingest function → Qdrant storage adapter: upserts vectors (evidence: `main.py`)
- Qdrant storage adapter → Qdrant vector database: stores and searches (evidence: `vector_db.py`)
- Query function → Text embedding: embeds question (evidence: `main.py`)
- Query function → Vector retrieval: searches vectors (evidence: `main.py`)
- Query function → Contextual answer generation: passes retrieved context (evidence: `main.py`)
- Contextual answer generation → Google Gemini: generates answer (evidence: `main.py`)
- Query function → RAG data models: uses result models (evidence: `main.py`)
- Ingest function → RAG data models: uses ingestion models (evidence: `main.py`)
- Streamlit UI → Inngest: polls run output (evidence: `streamlit_app.py`)
- Inngest → Streamlit UI: returns run output (evidence: `streamlit_app.py`)
