# ishanth777/production-grade-rag-application architecture

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

- Interactive diagram: https://gitdiagram.com/ishanth777/production-grade-rag-application
- Repository: https://github.com/ishanth777/production-grade-rag-application

## Overview

DocuMind answers questions over uploaded PDFs through a FastAPI interface or interactive CLI. Its main workflow checks cached responses, applies input safety checks, retrieves Qdrant context, validates that context, generates an answer through a provider-fallback gateway, sanitizes the output, and caches the result. A separate document-management workflow loads PDFs, chunks them, and indexes them. The README describes Redis and Logfire capabilities; the sampled cache implementation is in-memory, and the source excerpts do not establish a Redis connection. Some optional integrations are therefore shown as unverified.

Main entry points: [`app.py`](https://github.com/ishanth777/production-grade-rag-application/blob/main/app.py) (FastAPI App), [`src/search.py`](https://github.com/ishanth777/production-grade-rag-application/blob/main/src/search.py) (RAG Search), [`src/vector_store.py`](https://github.com/ishanth777/production-grade-rag-application/blob/main/src/vector_store.py) (Vector Store), [`src/llm_gateway.py`](https://github.com/ishanth777/production-grade-rag-application/blob/main/src/llm_gateway.py) (LLM Gateway)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_web["FastAPI App<br/>[app.py]"]
  node_webui["Web UI<br/>[index.html]"]
  node_cli["Interactive CLI<br/>[cli.py]"]
end

subgraph group_rag["RAG Answering"]
  node_search["RAG Search<br/>[search.py]"]
  node_guards["Safety Guardrails<br/>[guardrails.py]"]
  node_gateway["LLM Gateway<br/>[llm_gateway.py]"]
  node_offline["Offline Fallback<br/>[llm_gateway.py]"]
end

subgraph group_knowledge["Document Indexing"]
  node_loader["PDF Loader<br/>[data_loader.py]"]
  node_chunks["Chunking Pipeline<br/>[embeddings.py]"]
  node_vectors[("Vector Store<br/>[vector_store.py]")]
  node_documents["PDF Documents"]
end

subgraph group_platform["State &amp; Observability"]
  node_cache[("Response Cache<br/>[cache.py]")]
  node_observability["Tracing<br/>[observability.py]"]
end

node_user(("User"))
node_groq{{"Groq"}}
node_openai{{"OpenAI"}}
node_qdrant[("Qdrant")]
node_redis[("Redis")]
node_logfire{{"Logfire"}}

node_user -->|"submits requests"| node_web
node_web -->|"renders"| node_webui
node_web -->|"runs search"| node_search
node_user -->|"enters queries"| node_cli
node_cli -->|"runs search"| node_search
node_search -->|"checks and stores"| node_cache
node_search -->|"checks query, context, answer"| node_guards
node_search -->|"retrieves context"| node_vectors
node_search -->|"requests generation"| node_gateway
node_gateway -->|"tries primary"| node_groq
node_gateway -->|"falls back"| node_openai
node_gateway -->|"falls back"| node_offline
node_web -->|"loads PDFs"| node_loader
node_web -->|"chunks documents"| node_chunks
node_web -->|"indexes chunks"| node_vectors
node_loader -->|"reads"| node_documents
node_vectors -->|"stores and searches"| node_qdrant
node_vectors -->|"loads on missing index"| node_loader
node_vectors -->|"chunks on missing index"| node_chunks
node_web -->|"initializes tracing"| node_observability
node_search -->|"creates spans"| node_observability
node_observability -->|"exports traces"| node_logfire
node_cache -.->|"optional backend"| node_redis

click node_web "https://github.com/ishanth777/production-grade-rag-application/blob/main/app.py"
click node_webui "https://github.com/ishanth777/production-grade-rag-application/blob/main/templates/index.html"
click node_cli "https://github.com/ishanth777/production-grade-rag-application/blob/main/cli.py"
click node_search "https://github.com/ishanth777/production-grade-rag-application/blob/main/src/search.py"
click node_guards "https://github.com/ishanth777/production-grade-rag-application/blob/main/src/guardrails.py"
click node_gateway "https://github.com/ishanth777/production-grade-rag-application/blob/main/src/llm_gateway.py"
click node_offline "https://github.com/ishanth777/production-grade-rag-application/blob/main/src/llm_gateway.py"
click node_loader "https://github.com/ishanth777/production-grade-rag-application/blob/main/src/data_loader.py"
click node_chunks "https://github.com/ishanth777/production-grade-rag-application/blob/main/src/embeddings.py"
click node_vectors "https://github.com/ishanth777/production-grade-rag-application/blob/main/src/vector_store.py"
click node_documents "https://github.com/ishanth777/production-grade-rag-application/tree/main/data"
click node_cache "https://github.com/ishanth777/production-grade-rag-application/blob/main/src/cache.py"
click node_observability "https://github.com/ishanth777/production-grade-rag-application/blob/main/src/observability.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_web,node_webui,node_cli,node_user toneBlue
class node_search,node_guards,node_gateway,node_offline,node_qdrant,node_redis toneAmber
class node_loader,node_chunks,node_vectors,node_documents toneMint
class node_cache,node_observability toneRose
class node_groq,node_openai,node_logfire toneIndigo
```

## Components

### User Interfaces

- [FastAPI App](https://github.com/ishanth777/production-grade-rag-application/blob/main/app.py): `app.py`
- [Web UI](https://github.com/ishanth777/production-grade-rag-application/blob/main/templates/index.html): `templates/index.html`
- [Interactive CLI](https://github.com/ishanth777/production-grade-rag-application/blob/main/cli.py): `cli.py`

### RAG Answering

- [RAG Search](https://github.com/ishanth777/production-grade-rag-application/blob/main/src/search.py): `src/search.py`
- [Safety Guardrails](https://github.com/ishanth777/production-grade-rag-application/blob/main/src/guardrails.py): `src/guardrails.py`
- [LLM Gateway](https://github.com/ishanth777/production-grade-rag-application/blob/main/src/llm_gateway.py): `src/llm_gateway.py`
- [Offline Fallback](https://github.com/ishanth777/production-grade-rag-application/blob/main/src/llm_gateway.py): `src/llm_gateway.py`

### Document Indexing

- [PDF Loader](https://github.com/ishanth777/production-grade-rag-application/blob/main/src/data_loader.py): `src/data_loader.py`
- [Chunking Pipeline](https://github.com/ishanth777/production-grade-rag-application/blob/main/src/embeddings.py): `src/embeddings.py`
- [Vector Store](https://github.com/ishanth777/production-grade-rag-application/blob/main/src/vector_store.py): `src/vector_store.py`
- [PDF Documents](https://github.com/ishanth777/production-grade-rag-application/tree/main/data): `data`

### State & Observability

- [Response Cache](https://github.com/ishanth777/production-grade-rag-application/blob/main/src/cache.py): `src/cache.py`
- [Tracing](https://github.com/ishanth777/production-grade-rag-application/blob/main/src/observability.py): `src/observability.py`

### Other components

- **User**
- **Groq**
- **OpenAI**
- **Qdrant**
- **Redis**
- **Logfire**

## Connections

- User → FastAPI App: submits requests (evidence: `app.py`)
- FastAPI App → Web UI: renders (evidence: `app.py`)
- FastAPI App → RAG Search: runs search (evidence: `app.py`)
- User → Interactive CLI: enters queries (evidence: `cli.py`)
- Interactive CLI → RAG Search: runs search (evidence: `cli.py`)
- RAG Search → Response Cache: checks and stores (evidence: `src/search.py`)
- RAG Search → Safety Guardrails: checks query, context, answer (evidence: `src/search.py`)
- RAG Search → Vector Store: retrieves context (evidence: `src/search.py`)
- RAG Search → LLM Gateway: requests generation (evidence: `src/search.py`)
- LLM Gateway → Groq: tries primary (evidence: `README.md`)
- LLM Gateway → OpenAI: falls back (evidence: `README.md`)
- LLM Gateway → Offline Fallback: falls back (evidence: `src/llm_gateway.py`)
- FastAPI App → PDF Loader: loads PDFs (evidence: `app.py`)
- FastAPI App → Chunking Pipeline: chunks documents (evidence: `app.py`)
- FastAPI App → Vector Store: indexes chunks (evidence: `app.py`)
- PDF Loader → PDF Documents: reads (evidence: `src/data_loader.py`)
- Vector Store → Qdrant: stores and searches (evidence: `src/vector_store.py`)
- Vector Store → PDF Loader: loads on missing index (evidence: `src/vector_store.py`)
- Vector Store → Chunking Pipeline: chunks on missing index (evidence: `src/vector_store.py`)
- FastAPI App → Tracing: initializes tracing (evidence: `app.py`)
- RAG Search → Tracing: creates spans (evidence: `src/search.py`)
- Tracing → Logfire: exports traces (evidence: `src/observability.py`)
- Response Cache → Redis: optional backend
