# amreshmavi/semantic-document-retrieval-system architecture

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

- Interactive diagram: https://gitdiagram.com/amreshmavi/semantic-document-retrieval-system
- Repository: https://github.com/amreshmavi/semantic-document-retrieval-system

## Overview

The product is a PDF-based RAG application: users upload PDFs for ingestion, then ask questions answered from retrieved document context. The Streamlit interface sends Inngest events; FastAPI-registered functions orchestrate loading, embedding, vector storage, retrieval, and answer generation. The README describes additional production controls and observability, while the sampled ingestion function shows throttling and rate limiting. Source excerpts do not show the Inngest service internals, so the graph treats it as an external runtime and avoids claiming unshown workflow details.

Main entry points: [`main.py`](https://github.com/amreshmavi/semantic-document-retrieval-system/blob/main/main.py) (Ingestion function), [`streamlit_app.py`](https://github.com/amreshmavi/semantic-document-retrieval-system/blob/main/streamlit_app.py) (Streamlit app), [`vector_db.py`](https://github.com/amreshmavi/semantic-document-retrieval-system/blob/main/vector_db.py) (Qdrant storage), [`data_loader.py`](https://github.com/amreshmavi/semantic-document-retrieval-system/blob/main/data_loader.py) (PDF chunking)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_streamlit["Streamlit app<br/>[streamlit_app.py]"]
end

subgraph group_orchestration["Inngest orchestration"]
  node_inngest["Inngest runtime"]
  node_ingest_fn["Ingestion function<br/>[main.py]"]
  node_query_fn["Query function<br/>[main.py]"]
end

subgraph group_rag["RAG pipeline"]
  node_rag_types["RAG result types<br/>[custom_types.py]"]
  node_pdf_loader["PDF chunking<br/>[data_loader.py]"]
  node_embedding["Text embeddings<br/>[data_loader.py]"]
  node_vector_store[("Qdrant storage<br/>[vector_db.py]")]
end

subgraph group_services["External services"]
  node_openai{{"OpenAI API"}}
  node_qdrant[("Qdrant service")]
  node_inngest_api{{"Inngest run API"}}
end

node_user(("User"))

node_user -->|"uploads or asks"| node_streamlit
node_streamlit -->|"sends events"| node_inngest
node_streamlit -->|"polls run output"| node_inngest_api
node_inngest -->|"dispatches ingestion"| node_ingest_fn
node_inngest -->|"dispatches query"| node_query_fn
node_ingest_fn -->|"loads and chunks"| node_pdf_loader
node_ingest_fn -->|"embeds chunks"| node_embedding
node_ingest_fn -->|"upserts vectors"| node_vector_store
node_query_fn -->|"embeds question"| node_embedding
node_query_fn -->|"searches vectors"| node_vector_store
node_query_fn -->|"generates answer"| node_openai
node_pdf_loader -->|"requests embeddings"| node_openai
node_vector_store -->|"reads and writes"| node_qdrant
node_ingest_fn -->|"uses result types"| node_rag_types
node_query_fn -->|"uses result types"| node_rag_types

click node_streamlit "https://github.com/amreshmavi/semantic-document-retrieval-system/blob/main/streamlit_app.py"
click node_ingest_fn "https://github.com/amreshmavi/semantic-document-retrieval-system/blob/main/main.py"
click node_query_fn "https://github.com/amreshmavi/semantic-document-retrieval-system/blob/main/main.py"
click node_rag_types "https://github.com/amreshmavi/semantic-document-retrieval-system/blob/main/custom_types.py"
click node_pdf_loader "https://github.com/amreshmavi/semantic-document-retrieval-system/blob/main/data_loader.py"
click node_embedding "https://github.com/amreshmavi/semantic-document-retrieval-system/blob/main/data_loader.py"
click node_vector_store "https://github.com/amreshmavi/semantic-document-retrieval-system/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_user toneBlue
class node_inngest,node_ingest_fn,node_query_fn toneAmber
class node_rag_types,node_pdf_loader,node_embedding,node_vector_store toneMint
class node_openai,node_qdrant,node_inngest_api toneRose
```

## Components

### User interface

- [Streamlit app](https://github.com/amreshmavi/semantic-document-retrieval-system/blob/main/streamlit_app.py): `streamlit_app.py`

### Inngest orchestration

- **Inngest runtime**
- [Ingestion function](https://github.com/amreshmavi/semantic-document-retrieval-system/blob/main/main.py): `main.py`
- [Query function](https://github.com/amreshmavi/semantic-document-retrieval-system/blob/main/main.py): `main.py`

### RAG pipeline

- [RAG result types](https://github.com/amreshmavi/semantic-document-retrieval-system/blob/main/custom_types.py): `custom_types.py`
- [PDF chunking](https://github.com/amreshmavi/semantic-document-retrieval-system/blob/main/data_loader.py): `data_loader.py`
- [Text embeddings](https://github.com/amreshmavi/semantic-document-retrieval-system/blob/main/data_loader.py): `data_loader.py`
- [Qdrant storage](https://github.com/amreshmavi/semantic-document-retrieval-system/blob/main/vector_db.py): `vector_db.py`

### External services

- **OpenAI API**
- **Qdrant service**
- **Inngest run API**

### Other components

- **User**

## Connections

- User → Streamlit app: uploads or asks (evidence: `README.md`)
- Streamlit app → Inngest runtime: sends events (evidence: `streamlit_app.py`)
- Streamlit app → Inngest run API: polls run output (evidence: `streamlit_app.py`)
- Inngest runtime → Ingestion function: dispatches ingestion (evidence: `main.py`)
- Inngest runtime → Query function: dispatches query (evidence: `main.py`)
- Ingestion function → PDF chunking: loads and chunks (evidence: `main.py`)
- Ingestion function → Text embeddings: embeds chunks (evidence: `main.py`)
- Ingestion function → Qdrant storage: upserts vectors (evidence: `main.py`)
- Query function → Text embeddings: embeds question (evidence: `main.py`)
- Query function → Qdrant storage: searches vectors (evidence: `main.py`)
- Query function → OpenAI API: generates answer (evidence: `main.py`)
- PDF chunking → OpenAI API: requests embeddings (evidence: `data_loader.py`)
- Qdrant storage → Qdrant service: reads and writes (evidence: `vector_db.py`)
- Ingestion function → RAG result types: uses result types (evidence: `main.py`)
- Query function → RAG result types: uses result types (evidence: `main.py`)
