# aliraza-amjad-shaikh/rag-document-qa architecture

> Architecture diagram of the GitHub repository aliraza-amjad-shaikh/rag-document-qa, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aliraza-amjad-shaikh/rag-document-qa
- Repository: https://github.com/aliraza-amjad-shaikh/rag-document-qa

## Overview

This is a Streamlit RAG document Q&A app. Users provide an OpenAI key, upload PDFs or images, and ask questions to receive cited, confidence-scored answers or a low-confidence fallback. The documented workflow routes overview questions to stored summaries and specific questions through retrieval. The README supplies several workflow details not visible in the partial excerpts; unsampled implementation links are therefore limited to those explicitly documented.

Main entry points: [`app.py`](https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/app.py) (Streamlit interface), [`ingestion.py`](https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/ingestion.py) (Ingestion orchestration), [`retrieval.py`](https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/retrieval.py) (Vector retrieval), [`config.py`](https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/config.py) (App configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["App and access"]
  node_app["Streamlit interface<br/>[app.py]"]
  node_auth["Key validation<br/>[auth.py]"]
end

subgraph group_ingestion["Document ingestion"]
  node_ingest["Ingestion orchestration<br/>[ingestion.py]"]
  node_pdf["PDF extraction<br/>[ingestion.py]"]
  node_image["Image analysis<br/>[ingestion.py]"]
  node_chunk["Semantic chunking<br/>[ingestion.py]"]
  node_summarize["Document summaries<br/>[ingestion.py]"]
end

subgraph group_qa["Question answering"]
  node_retrieval["Vector retrieval<br/>[retrieval.py]"]
  node_index[("FAISS index<br/>[retrieval.py]")]
  node_routing["Query routing<br/>[retrieval.py]"]
  node_answer["Answer generation<br/>[generation.py]"]
end

subgraph group_state["Document state"]
  node_docstore[("Summary store<br/>[document_store.py]")]
end

subgraph group_runtime["Runtime configuration"]
  node_config["App configuration<br/>[config.py]"]
end

node_user(("User"))
node_openai{{"OpenAI API"}}

node_user -->|"uses"| node_app
node_app -->|"validates key"| node_auth
node_auth -->|"tests key"| node_openai
node_app -->|"starts ingestion"| node_ingest
node_ingest -->|"routes PDFs"| node_pdf
node_ingest -->|"routes images"| node_image
node_pdf -->|"supplies text"| node_chunk
node_image -->|"supplies text"| node_chunk
node_chunk -->|"indexes chunks"| node_retrieval
node_ingest -->|"creates summaries"| node_summarize
node_summarize -->|"stores summary"| node_docstore
node_app -->|"classifies question"| node_routing
node_routing -->|"routes overview"| node_docstore
node_app -->|"requests chunks"| node_retrieval
node_retrieval -->|"searches index"| node_index
node_retrieval -->|"embeds query"| node_openai
node_app -->|"generates response"| node_answer
node_answer -->|"reads summaries"| node_docstore
node_answer -->|"requests answer"| node_openai
node_app -->|"uses settings"| node_config
node_auth -->|"uses model setting"| node_config
node_ingest -->|"uses ingestion settings"| node_config
node_retrieval -->|"uses retrieval settings"| node_config
node_answer -->|"uses model setting"| node_config

click node_app "https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/app.py"
click node_auth "https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/auth.py"
click node_ingest "https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/ingestion.py"
click node_pdf "https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/ingestion.py"
click node_image "https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/ingestion.py"
click node_chunk "https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/ingestion.py"
click node_retrieval "https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/retrieval.py"
click node_index "https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/retrieval.py"
click node_routing "https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/retrieval.py"
click node_answer "https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/generation.py"
click node_summarize "https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/ingestion.py"
click node_docstore "https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/document_store.py"
click node_config "https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/config.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_auth,node_user toneBlue
class node_ingest,node_pdf,node_image,node_chunk,node_summarize toneAmber
class node_retrieval,node_index,node_routing,node_answer,node_openai toneMint
class node_docstore toneRose
class node_config toneIndigo
```

## Components

### App and access

- [Streamlit interface](https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/app.py): `app.py`
- [Key validation](https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/auth.py): `auth.py`

### Document ingestion

- [Ingestion orchestration](https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/ingestion.py): `ingestion.py`
- [PDF extraction](https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/ingestion.py): `ingestion.py`
- [Image analysis](https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/ingestion.py): `ingestion.py`
- [Semantic chunking](https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/ingestion.py): `ingestion.py`
- [Document summaries](https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/ingestion.py): `ingestion.py`

### Question answering

- [Vector retrieval](https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/retrieval.py): `retrieval.py`
- [FAISS index](https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/retrieval.py): `retrieval.py`
- [Query routing](https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/retrieval.py): `retrieval.py`
- [Answer generation](https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/generation.py): `generation.py`

### Document state

- [Summary store](https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/document_store.py): `document_store.py`

### Runtime configuration

- [App configuration](https://github.com/aliraza-amjad-shaikh/rag-document-qa/blob/main/config.py): `config.py`

### Other components

- **User**
- **OpenAI API**

## Connections

- User → Streamlit interface: uses (evidence: `README.md`)
- Streamlit interface → Key validation: validates key (evidence: `app.py`)
- Key validation → OpenAI API: tests key (evidence: `auth.py`)
- Streamlit interface → Ingestion orchestration: starts ingestion (evidence: `app.py`)
- Ingestion orchestration → PDF extraction: routes PDFs (evidence: `README.md`)
- Ingestion orchestration → Image analysis: routes images (evidence: `README.md`)
- PDF extraction → Semantic chunking: supplies text (evidence: `README.md`)
- Image analysis → Semantic chunking: supplies text (evidence: `README.md`)
- Semantic chunking → Vector retrieval: indexes chunks (evidence: `README.md`)
- Ingestion orchestration → Document summaries: creates summaries (evidence: `README.md`)
- Document summaries → Summary store: stores summary (evidence: `ingestion.py`)
- Streamlit interface → Query routing: classifies question (evidence: `app.py`)
- Query routing → Summary store: routes overview (evidence: `README.md`)
- Streamlit interface → Vector retrieval: requests chunks (evidence: `app.py`)
- Vector retrieval → FAISS index: searches index (evidence: `retrieval.py`)
- Vector retrieval → OpenAI API: embeds query (evidence: `retrieval.py`)
- Streamlit interface → Answer generation: generates response (evidence: `app.py`)
- Answer generation → Summary store: reads summaries (evidence: `generation.py`)
- Answer generation → OpenAI API: requests answer (evidence: `generation.py`)
- Streamlit interface → App configuration: uses settings (evidence: `app.py`)
- Key validation → App configuration: uses model setting (evidence: `auth.py`)
- Ingestion orchestration → App configuration: uses ingestion settings (evidence: `ingestion.py`)
- Vector retrieval → App configuration: uses retrieval settings (evidence: `retrieval.py`)
- Answer generation → App configuration: uses model setting (evidence: `generation.py`)
