# gowthamt-22/rag-q-a-system-intelligent-document-question-answering architecture

> Architecture diagram of the GitHub repository gowthamt-22/rag-q-a-system-intelligent-document-question-answering, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering
- Repository: https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering

## Overview

This is a FastAPI PDF question-answering service. Its main workflow accepts a question, retrieves relevant indexed chunks, generates a context-grounded answer, and returns page-level citations. PDFs enter through the upload endpoint or the documented batch-ingestion runner; both extract page text, chunk it, and store it for later retrieval. The graph also shows configuration and prompt construction. Edges reflect the sampled callers and README-documented capabilities; the batch runner is included as a product ingestion entry point, not as build machinery.

Main entry points: [`app/main.py`](https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/main.py) (REST API), [`app/ingestion/vector_store.py`](https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/ingestion/vector_store.py) (Vector Store), [`app/config.py`](https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/config.py) (Settings), [`app/llm/generator.py`](https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/llm/generator.py) (Answer Generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API"]
  node_api["REST API<br/>[main.py]"]
  node_schemas["API Models<br/>[api_models.py]"]
  node_pipeline["RAG Pipeline<br/>[rag_pipeline.py]"]
  node_settings["Settings<br/>[config.py]"]
end

subgraph group_ingest["PDF Ingestion"]
  node_batch["Batch Ingestion<br/>[ingest.py]"]
  node_pdf["PDF Extraction<br/>[pdf_loader.py]"]
  node_chunker["Text Chunking<br/>[chunker.py]"]
  node_store[("Vector Store<br/>[vector_store.py]")]
end

subgraph group_search["Retrieval"]
  node_retriever["Semantic Retrieval<br/>[retriever.py]"]
end

subgraph group_answer["Answer Generation"]
  node_generator["Answer Generator<br/>[generator.py]"]
  node_prompt["Grounding Prompt<br/>[prompts.py]"]
end

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

node_user -->|"asks or uploads"| node_api
node_api -->|"validates and formats"| node_schemas
node_api -->|"initializes and calls"| node_pipeline
node_api -->|"loads uploaded PDF"| node_pdf
node_api -->|"chunks upload text"| node_chunker
node_api -->|"stores upload chunks"| node_store
node_batch -->|"loads PDFs"| node_pdf
node_batch -->|"chunks pages"| node_chunker
node_batch -->|"stores chunks"| node_store
node_pipeline -->|"retrieves context"| node_retriever
node_pipeline -->|"generates answer"| node_generator
node_retriever -->|"searches vectors"| node_store
node_generator -->|"builds prompt from"| node_prompt
node_pdf -->|"reads settings"| node_settings
node_chunker -->|"reads settings"| node_settings
node_store -->|"reads settings"| node_settings
node_retriever -->|"reads settings"| node_settings
node_generator -->|"reads settings"| node_settings
node_store -.->|"embeds text"| node_openai
node_generator -.->|"calls chat model"| node_openai

click node_api "https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/main.py"
click node_schemas "https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/schemas/api_models.py"
click node_pipeline "https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/rag_pipeline.py"
click node_settings "https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/config.py"
click node_batch "https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/scripts/ingest.py"
click node_pdf "https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/ingestion/pdf_loader.py"
click node_chunker "https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/ingestion/chunker.py"
click node_store "https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/ingestion/vector_store.py"
click node_retriever "https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/retrieval/retriever.py"
click node_generator "https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/llm/generator.py"
click node_prompt "https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/llm/prompts.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_api,node_schemas,node_pipeline,node_settings,node_user toneBlue
class node_batch,node_pdf,node_chunker,node_store toneAmber
class node_retriever toneMint
class node_generator,node_prompt toneRose
class node_openai toneIndigo
```

## Components

### API

- [REST API](https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/main.py): `app/main.py`
- [API Models](https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/schemas/api_models.py): `app/schemas/api_models.py`
- [RAG Pipeline](https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/rag_pipeline.py): `app/rag_pipeline.py`
- [Settings](https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/config.py): `app/config.py`

### PDF Ingestion

- [Batch Ingestion](https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/scripts/ingest.py): `scripts/ingest.py`
- [PDF Extraction](https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/ingestion/pdf_loader.py): `app/ingestion/pdf_loader.py`
- [Text Chunking](https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/ingestion/chunker.py): `app/ingestion/chunker.py`
- [Vector Store](https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/ingestion/vector_store.py): `app/ingestion/vector_store.py`

### Retrieval

- [Semantic Retrieval](https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/retrieval/retriever.py): `app/retrieval/retriever.py`

### Answer Generation

- [Answer Generator](https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/llm/generator.py): `app/llm/generator.py`
- [Grounding Prompt](https://github.com/gowthamt-22/rag-q-a-system-intelligent-document-question-answering/blob/main/app/llm/prompts.py): `app/llm/prompts.py`

### Other components

- **User**
- **OpenAI Models**

## Connections

- User → REST API: asks or uploads (evidence: `README.md`)
- REST API → API Models: validates and formats (evidence: `app/main.py`)
- REST API → RAG Pipeline: initializes and calls (evidence: `app/main.py`)
- REST API → PDF Extraction: loads uploaded PDF (evidence: `app/main.py`)
- REST API → Text Chunking: chunks upload text (evidence: `app/main.py`)
- REST API → Vector Store: stores upload chunks (evidence: `app/main.py`)
- Batch Ingestion → PDF Extraction: loads PDFs (evidence: `scripts/ingest.py`)
- Batch Ingestion → Text Chunking: chunks pages (evidence: `scripts/ingest.py`)
- Batch Ingestion → Vector Store: stores chunks (evidence: `scripts/ingest.py`)
- RAG Pipeline → Semantic Retrieval: retrieves context (evidence: `app/rag_pipeline.py`)
- RAG Pipeline → Answer Generator: generates answer (evidence: `app/rag_pipeline.py`)
- Semantic Retrieval → Vector Store: searches vectors (evidence: `app/retrieval/retriever.py`)
- Answer Generator → Grounding Prompt: builds prompt from (evidence: `app/llm/generator.py`)
- PDF Extraction → Settings: reads settings (evidence: `app/ingestion/pdf_loader.py`)
- Text Chunking → Settings: reads settings (evidence: `app/ingestion/chunker.py`)
- Vector Store → Settings: reads settings (evidence: `app/ingestion/vector_store.py`)
- Semantic Retrieval → Settings: reads settings (evidence: `app/retrieval/retriever.py`)
- Answer Generator → Settings: reads settings (evidence: `app/llm/generator.py`)
- Vector Store → OpenAI Models: embeds text (evidence: `README.md`)
- Answer Generator → OpenAI Models: calls chat model (evidence: `README.md`)
