# madhavi-1801/rag-application architecture

> Architecture diagram of the GitHub repository madhavi-1801/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/madhavi-1801/rag-application
- Repository: https://github.com/madhavi-1801/rag-application

## Overview

This is a console-based, single-document RAG question-answering application. A user supplies a PDF, TXT, or DOCX path; the CLI delegates ingestion and question answering to RAGPipeline. Ingestion extracts text, chunks it, and builds an in-memory FAISS index; queries retrieve top-k chunks, assemble a grounded prompt, and invoke a configured LLM or offline mock. README documents optional local or cloud embeddings and OpenAI/Gemini LLMs. Edges follow explicit calls or README workflow; external model-provider links are documented integrations.

Main entry points: [`rag_pipeline.py`](https://github.com/madhavi-1801/rag-application/blob/main/rag_pipeline.py) (RAG orchestrator), [`main.py`](https://github.com/madhavi-1801/rag-application/blob/main/main.py) (Interactive CLI), [`embeddings.py`](https://github.com/madhavi-1801/rag-application/blob/main/embeddings.py) (Embedding factory), [`vector_store.py`](https://github.com/madhavi-1801/rag-application/blob/main/vector_store.py) (FAISS index and search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Console interface"]
  node_cli["Interactive CLI<br/>[main.py]"]
end

subgraph group_ingestion["Document ingestion"]
  node_loader["Document extraction<br/>[document_loader.py]"]
  node_chunker["Text chunking<br/>[chunker.py]"]
end

subgraph group_retrieval["Retrieval and indexing"]
  node_embedding_factory["Embedding factory<br/>[embeddings.py]"]
  node_vector_store[("FAISS index and search<br/>[vector_store.py]")]
end

subgraph group_answering["Answer generation"]
  node_pipeline["RAG orchestrator<br/>[rag_pipeline.py]"]
  node_llm["Configured LLM or mock<br/>[rag_pipeline.py]"]
end

node_user(("User"))
node_uploaded_document["PDF / TXT / DOCX"]
node_embedding_providers{{"HuggingFace / OpenAI / Gemini embeddings"}}
node_llm_providers{{"OpenAI / Google Gemini APIs"}}

node_user -->|"enters path and questions"| node_cli
node_cli -->|"calls"| node_pipeline
node_user -->|"selects"| node_uploaded_document
node_pipeline -->|"loads text"| node_loader
node_loader -->|"extracts from"| node_uploaded_document
node_pipeline -->|"splits text"| node_chunker
node_pipeline -->|"initializes"| node_embedding_factory
node_pipeline -->|"creates index"| node_vector_store
node_embedding_factory -->|"configures"| node_embedding_providers
node_vector_store -->|"embeds chunks and queries"| node_embedding_factory
node_pipeline -->|"searches top-k"| node_vector_store
node_pipeline -->|"invokes prompt"| node_llm
node_llm -->|"uses configured provider"| node_llm_providers
node_pipeline -->|"returns answer"| node_cli

click node_cli "https://github.com/madhavi-1801/rag-application/blob/main/main.py"
click node_pipeline "https://github.com/madhavi-1801/rag-application/blob/main/rag_pipeline.py"
click node_loader "https://github.com/madhavi-1801/rag-application/blob/main/document_loader.py"
click node_chunker "https://github.com/madhavi-1801/rag-application/blob/main/chunker.py"
click node_embedding_factory "https://github.com/madhavi-1801/rag-application/blob/main/embeddings.py"
click node_vector_store "https://github.com/madhavi-1801/rag-application/blob/main/vector_store.py"
click node_llm "https://github.com/madhavi-1801/rag-application/blob/main/rag_pipeline.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_cli,node_user toneBlue
class node_loader,node_chunker toneAmber
class node_embedding_factory,node_vector_store,node_llm_providers toneMint
class node_pipeline,node_llm toneRose
class node_uploaded_document,node_embedding_providers toneIndigo
```

## Components

### Console interface

- [Interactive CLI](https://github.com/madhavi-1801/rag-application/blob/main/main.py): `main.py`

### Document ingestion

- [Document extraction](https://github.com/madhavi-1801/rag-application/blob/main/document_loader.py): `document_loader.py`
- [Text chunking](https://github.com/madhavi-1801/rag-application/blob/main/chunker.py): `chunker.py`

### Retrieval and indexing

- [Embedding factory](https://github.com/madhavi-1801/rag-application/blob/main/embeddings.py): `embeddings.py`
- [FAISS index and search](https://github.com/madhavi-1801/rag-application/blob/main/vector_store.py): `vector_store.py`

### Answer generation

- [RAG orchestrator](https://github.com/madhavi-1801/rag-application/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [Configured LLM or mock](https://github.com/madhavi-1801/rag-application/blob/main/rag_pipeline.py): `rag_pipeline.py`

### Other components

- **User**
- **PDF / TXT / DOCX**
- **HuggingFace / OpenAI / Gemini embeddings**
- **OpenAI / Google Gemini APIs**

## Connections

- User → Interactive CLI: enters path and questions (evidence: `README.md`)
- Interactive CLI → RAG orchestrator: calls (evidence: `main.py`)
- User → PDF / TXT / DOCX: selects (evidence: `README.md`)
- RAG orchestrator → Document extraction: loads text (evidence: `rag_pipeline.py`)
- Document extraction → PDF / TXT / DOCX: extracts from (evidence: `README.md`)
- RAG orchestrator → Text chunking: splits text (evidence: `rag_pipeline.py`)
- RAG orchestrator → Embedding factory: initializes (evidence: `rag_pipeline.py`)
- RAG orchestrator → FAISS index and search: creates index (evidence: `rag_pipeline.py`)
- Embedding factory → HuggingFace / OpenAI / Gemini embeddings: configures (evidence: `README.md`)
- FAISS index and search → Embedding factory: embeds chunks and queries (evidence: `README.md`)
- RAG orchestrator → FAISS index and search: searches top-k (evidence: `rag_pipeline.py`)
- RAG orchestrator → Configured LLM or mock: invokes prompt (evidence: `rag_pipeline.py`)
- Configured LLM or mock → OpenAI / Google Gemini APIs: uses configured provider (evidence: `README.md`)
- RAG orchestrator → Interactive CLI: returns answer (evidence: `main.py`)
