# akarshvyas/genai-part2-rag-implementation architecture

> Architecture diagram of the GitHub repository akarshvyas/genai-part2-rag-implementation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/akarshvyas/genai-part2-rag-implementation
- Repository: https://github.com/akarshvyas/genai-part2-rag-implementation

## Overview

This repository contains experiments and a command-line retrieval-augmented generation (RAG) workflow. The clearest end-to-end path is: build a Chroma index from a PDF, then accept a user question, retrieve relevant chunks, construct a context-grounded prompt, and generate an answer with Mistral. Other files indicate web loading and alternative retrieval experiments, but their wiring is not shown. The app module and several retrievers were not sampled, so their roles and relationships remain uncertain.

Main entry points: [`main.py`](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/main.py) (RAG command loop), [`create_database.py`](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/create_database.py) (Index builder), [`chroma_db`](https://github.com/akarshvyas/genai-part2-rag-implementation/tree/main/chroma_db) (Persistent Chroma index), [`document loaders/deeplearning.pdf`](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/document%20loaders/deeplearning.pdf) (Deep-learning PDF)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_indexing["Document indexing"]
  node_pdf["Deep-learning PDF<br/>[deeplearning.pdf]"]
  node_splitter["Text chunking<br/>[create_database.py]"]
  node_index_embeddings["OpenAI embeddings<br/>[create_database.py]"]
  node_index_builder["Index builder<br/>[create_database.py]"]
  node_chroma_db[("Persistent Chroma index")]
end

subgraph group_answering["RAG answering"]
  node_cli_rag["RAG command loop<br/>[main.py]"]
  node_mmr_retriever["MMR retrieval<br/>[main.py]"]
  node_answer_embeddings["OpenAI embeddings<br/>[main.py]"]
  node_prompt["Context prompt<br/>[main.py]"]
  node_mistral["Mistral chat model<br/>[main.py]"]
  node_answer["Generated answer<br/>[main.py]"]
  node_app["App module<br/>[app.py]"]
end

subgraph group_experiments["Retrieval experiments"]
  node_multiquery["Multi-query experiment<br/>[multiquery.py]"]
  node_arixv["Arxiv retriever<br/>[arixv.py]"]
  node_mmr_experiment["MMR experiment<br/>[mmr.py]"]
  node_db_demo["Vector-store demo<br/>[DB.py]"]
end

subgraph group_loading["Document loading"]
  node_web_loader["Web page loader<br/>[page.py]"]
  node_pdf_loader["PDF loader module<br/>[pdf.py]"]
  node_web["Apple product page"]
end

node_user(("Questioner"))

node_pdf -->|"loads from"| node_index_builder
node_index_builder -->|"splits documents"| node_splitter
node_index_builder -->|"embeds chunks"| node_index_embeddings
node_index_builder -->|"writes index"| node_chroma_db
node_user -->|"enters question"| node_cli_rag
node_cli_rag -->|"invokes retrieval"| node_mmr_retriever
node_mmr_retriever -.->|"searches index"| node_chroma_db
node_cli_rag -->|"configures embeddings"| node_answer_embeddings
node_cli_rag -->|"formats context"| node_prompt
node_cli_rag -->|"invokes model"| node_mistral
node_cli_rag -->|"prints response"| node_answer
node_web_loader -->|"loads page"| node_web

click node_pdf "https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/document%20loaders/deeplearning.pdf"
click node_splitter "https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/create_database.py"
click node_index_embeddings "https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/create_database.py"
click node_index_builder "https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/create_database.py"
click node_chroma_db "https://github.com/akarshvyas/genai-part2-rag-implementation/tree/main/chroma_db"
click node_cli_rag "https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/main.py"
click node_mmr_retriever "https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/main.py"
click node_answer_embeddings "https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/main.py"
click node_prompt "https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/main.py"
click node_mistral "https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/main.py"
click node_answer "https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/main.py"
click node_app "https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/app.py"
click node_multiquery "https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/retrievers/multiquery.py"
click node_arixv "https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/retrievers/arixv.py"
click node_mmr_experiment "https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/retrievers/mmr.py"
click node_db_demo "https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/vector%20store/DB.py"
click node_web_loader "https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/document%20loaders/page.py"
click node_pdf_loader "https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/document%20loaders/pdf.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_pdf,node_splitter,node_index_embeddings,node_index_builder,node_chroma_db toneBlue
class node_cli_rag,node_mmr_retriever,node_answer_embeddings,node_prompt,node_mistral,node_answer,node_app toneAmber
class node_multiquery,node_arixv,node_mmr_experiment,node_db_demo toneMint
class node_web_loader,node_pdf_loader,node_web toneRose
class node_user toneIndigo
```

## Components

### Document indexing

- [Deep-learning PDF](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/document%20loaders/deeplearning.pdf): `document loaders/deeplearning.pdf`
- [Text chunking](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/create_database.py): `create_database.py`
- [OpenAI embeddings](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/create_database.py): `create_database.py`
- [Index builder](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/create_database.py): `create_database.py`
- [Persistent Chroma index](https://github.com/akarshvyas/genai-part2-rag-implementation/tree/main/chroma_db): `chroma_db`

### RAG answering

- [RAG command loop](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/main.py): `main.py`
- [MMR retrieval](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/main.py): `main.py`
- [OpenAI embeddings](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/main.py): `main.py`
- [Context prompt](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/main.py): `main.py`
- [Mistral chat model](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/main.py): `main.py`
- [Generated answer](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/main.py): `main.py`
- [App module](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/app.py): `app.py`

### Retrieval experiments

- [Multi-query experiment](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/retrievers/multiquery.py): `retrievers/multiquery.py`
- [Arxiv retriever](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/retrievers/arixv.py): `retrievers/arixv.py`
- [MMR experiment](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/retrievers/mmr.py): `retrievers/mmr.py`
- [Vector-store demo](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/vector%20store/DB.py): `vector store/DB.py`

### Document loading

- [Web page loader](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/document%20loaders/page.py): `document loaders/page.py`
- [PDF loader module](https://github.com/akarshvyas/genai-part2-rag-implementation/blob/main/document%20loaders/pdf.py): `document loaders/pdf.py`
- **Apple product page**

### Other components

- **Questioner**

## Connections

- Deep-learning PDF → Index builder: loads from (evidence: `create_database.py`)
- Index builder → Text chunking: splits documents (evidence: `create_database.py`)
- Index builder → OpenAI embeddings: embeds chunks (evidence: `create_database.py`)
- Index builder → Persistent Chroma index: writes index (evidence: `create_database.py`)
- Questioner → RAG command loop: enters question (evidence: `main.py`)
- RAG command loop → MMR retrieval: invokes retrieval (evidence: `main.py`)
- MMR retrieval → Persistent Chroma index: searches index
- RAG command loop → OpenAI embeddings: configures embeddings (evidence: `main.py`)
- RAG command loop → Context prompt: formats context (evidence: `main.py`)
- RAG command loop → Mistral chat model: invokes model (evidence: `main.py`)
- RAG command loop → Generated answer: prints response (evidence: `main.py`)
- Web page loader → Apple product page: loads page (evidence: `document loaders/page.py`)
