# jimjyothish-dotcom/rag-transformer-qa architecture

> Architecture diagram of the GitHub repository jimjyothish-dotcom/rag-transformer-qa, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jimjyothish-dotcom/rag-transformer-qa
- Repository: https://github.com/jimjyothish-dotcom/rag-transformer-qa

## Overview

This repository is a small RAG application for answering questions grounded in the Transformer paper. Users ask through either the Streamlit interface or the CLI; each builds a retrieval-and-generation chain that retrieves paper chunks, prompts Gemini, and returns an answer. Separate scripts load and chunk the PDF and persist embeddings in ChromaDB. The README documents the major stages; the sampled code confirms both query entry points and the indexing script. Some retrieval behavior is provided by LangChain and Chroma rather than repository-defined modules.

Main entry points: [`rag_query.py`](https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/rag_query.py) (Top-3 retrieval), [`rag_app.py`](https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/rag_app.py) (Streamlit chat), [`embed_and_store.py`](https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/embed_and_store.py) (Indexing script), [`transformer_paper.pdf`](https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/transformer_paper.pdf) (Transformer paper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["Question interfaces"]
  node_web["Streamlit chat<br/>[rag_app.py]"]
  node_cli["CLI questions<br/>[rag_query.py]"]
  node_answer["Grounded answer"]
end

subgraph group_indexing["Document indexing"]
  node_indexer["Indexing script<br/>[embed_and_store.py]"]
  node_loader["PDF loading<br/>[embed_and_store.py]"]
  node_chunker["Text chunking<br/>[embed_and_store.py]"]
  node_embedder{{"Gemini embeddings"}}
end

subgraph group_qa["Retrieval and answering"]
  node_retriever["Top-3 retrieval<br/>[rag_query.py]"]
  node_prompt["Context prompt<br/>[rag_query.py]"]
  node_generator{{"Gemini answer model"}}
  node_parser["Answer parser<br/>[rag_query.py]"]
end

subgraph group_state["Persistent data"]
  node_store[("Chroma vector store")]
end

node_user(("Question asker"))
node_paper["Transformer paper"]

node_user -->|"asks via"| node_web
node_user -->|"asks via"| node_cli
node_paper -->|"loads pages"| node_loader
node_indexer -->|"loads"| node_loader
node_loader -->|"splits pages"| node_chunker
node_indexer -->|"embeds chunks"| node_embedder
node_indexer -->|"writes vectors"| node_store
node_embedder -->|"provides vectors"| node_store
node_web -->|"loads at setup"| node_paper
node_cli -->|"loads at startup"| node_paper
node_web -->|"invokes chain"| node_retriever
node_cli -->|"invokes chain"| node_retriever
node_retriever -->|"searches chunks"| node_store
node_retriever -->|"embeds question"| node_embedder
node_retriever -->|"supplies context"| node_prompt
node_prompt -->|"sends prompt"| node_generator
node_generator -->|"returns response"| node_parser
node_parser -->|"extracts text"| node_answer
node_answer -->|"displays"| node_web
node_answer -->|"prints"| node_cli

click node_paper "https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/transformer_paper.pdf"
click node_web "https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/rag_app.py"
click node_cli "https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/rag_query.py"
click node_indexer "https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/embed_and_store.py"
click node_loader "https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/embed_and_store.py"
click node_chunker "https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/embed_and_store.py"
click node_retriever "https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/rag_query.py"
click node_prompt "https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/rag_query.py"
click node_parser "https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/rag_query.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_cli,node_answer toneBlue
class node_indexer,node_loader,node_chunker,node_embedder toneAmber
class node_retriever,node_prompt,node_generator,node_parser toneMint
class node_store toneRose
class node_user toneIndigo
class node_paper toneTeal
```

## Components

### Question interfaces

- [Streamlit chat](https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/rag_app.py): `rag_app.py`
- [CLI questions](https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/rag_query.py): `rag_query.py`
- **Grounded answer**

### Document indexing

- [Indexing script](https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/embed_and_store.py): `embed_and_store.py`
- [PDF loading](https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/embed_and_store.py): `embed_and_store.py`
- [Text chunking](https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/embed_and_store.py): `embed_and_store.py`
- **Gemini embeddings**

### Retrieval and answering

- [Top-3 retrieval](https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/rag_query.py): `rag_query.py`
- [Context prompt](https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/rag_query.py): `rag_query.py`
- **Gemini answer model**
- [Answer parser](https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/rag_query.py): `rag_query.py`

### Persistent data

- **Chroma vector store**

### Other components

- **Question asker**
- [Transformer paper](https://github.com/jimjyothish-dotcom/rag-transformer-qa/blob/main/transformer_paper.pdf): `transformer_paper.pdf`

## Connections

- Question asker → Streamlit chat: asks via
- Question asker → CLI questions: asks via
- Transformer paper → PDF loading: loads pages
- Indexing script → PDF loading: loads
- PDF loading → Text chunking: splits pages
- Indexing script → Gemini embeddings: embeds chunks
- Indexing script → Chroma vector store: writes vectors
- Gemini embeddings → Chroma vector store: provides vectors
- Streamlit chat → Transformer paper: loads at setup
- CLI questions → Transformer paper: loads at startup
- Streamlit chat → Top-3 retrieval: invokes chain
- CLI questions → Top-3 retrieval: invokes chain
- Top-3 retrieval → Chroma vector store: searches chunks
- Top-3 retrieval → Gemini embeddings: embeds question
- Top-3 retrieval → Context prompt: supplies context
- Context prompt → Gemini answer model: sends prompt
- Gemini answer model → Answer parser: returns response
- Answer parser → Grounded answer: extracts text
- Grounded answer → Streamlit chat: displays
- Grounded answer → CLI questions: prints
