# nandishh18/rag-agent-judge architecture

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

- Interactive diagram: https://gitdiagram.com/nandishh18/rag-agent-judge
- Repository: https://github.com/nandishh18/rag-agent-judge

## Overview

This repository is a paper-focused RAG chatbot. Its main workflow builds a local searchable index from a PDF, then embeds a user question, retrieves relevant chunks, and sends them with the question to Groq for a grounded answer. It also supports generating a Markdown answer set for 15 assignment questions. The relationships below are supported by the sampled source and README; the generated index is documented but is not present in the file tree.

Main entry points: [`src/rag_chat.py`](https://github.com/nandishh18/rag-agent-judge/blob/main/src/rag_chat.py) (Chunk Retrieval), [`src/build_index.py`](https://github.com/nandishh18/rag-agent-judge/blob/main/src/build_index.py) (Index Builder), [`src/answer_questions.py`](https://github.com/nandishh18/rag-agent-judge/blob/main/src/answer_questions.py) (Question Runner), [`src/ingest.py`](https://github.com/nandishh18/rag-agent-judge/blob/main/src/ingest.py) (PDF Extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_indexing["Indexing"]
  node_index_build["Index Builder<br/>[build_index.py]"]
  node_pdf_ingest["PDF Extraction<br/>[ingest.py]"]
  node_embedding["Text Embeddings<br/>[build_index.py]"]
  node_vector_index[("FAISS Index<br/>[build_index.py]")]
  node_chunk_metadata["Chunk Metadata<br/>[build_index.py]"]
end

subgraph group_chat["Question Answering"]
  node_interactive["Interactive Chat<br/>[rag_chat.py]"]
  node_chatbot["RAG Chatbot<br/>[rag_chat.py]"]
  node_query_embedding["Query Embedding<br/>[rag_chat.py]"]
  node_retrieval["Chunk Retrieval<br/>[rag_chat.py]"]
  node_prompt["Prompt Assembly<br/>[rag_chat.py]"]
  node_answer["Grounded Answer<br/>[rag_chat.py]"]
end

subgraph group_batch["Batch Answers"]
  node_batch_runner["Question Runner"]
  node_report["Answer Report"]
end

node_pdf["Paper PDF"]
node_user(("User"))
node_groq["Groq LLM"]

node_pdf -->|"extracts pages"| node_pdf_ingest
node_pdf_ingest -->|"loads chunks"| node_index_build
node_index_build -->|"embeds chunks"| node_embedding
node_embedding -->|"adds vectors"| node_vector_index
node_index_build -->|"writes metadata"| node_chunk_metadata
node_user -->|"asks questions"| node_interactive
node_interactive -->|"calls answer"| node_chatbot
node_chatbot -->|"retrieves chunks"| node_retrieval
node_retrieval -->|"embeds query"| node_query_embedding
node_retrieval -->|"searches index"| node_vector_index
node_retrieval -->|"reads chunks"| node_chunk_metadata
node_chatbot -->|"assembles context"| node_prompt
node_prompt -->|"requests completion"| node_groq
node_groq -->|"returns answer"| node_answer
node_answer -->|"prints answer"| node_interactive
node_batch_runner -->|"calls answer"| node_chatbot
node_batch_runner -->|"writes report"| node_report

click node_pdf "https://github.com/nandishh18/rag-agent-judge/blob/main/data/agent_as_a_judge.pdf"
click node_index_build "https://github.com/nandishh18/rag-agent-judge/blob/main/src/build_index.py"
click node_pdf_ingest "https://github.com/nandishh18/rag-agent-judge/blob/main/src/ingest.py"
click node_embedding "https://github.com/nandishh18/rag-agent-judge/blob/main/src/build_index.py"
click node_vector_index "https://github.com/nandishh18/rag-agent-judge/blob/main/src/build_index.py"
click node_chunk_metadata "https://github.com/nandishh18/rag-agent-judge/blob/main/src/build_index.py"
click node_interactive "https://github.com/nandishh18/rag-agent-judge/blob/main/src/rag_chat.py"
click node_chatbot "https://github.com/nandishh18/rag-agent-judge/blob/main/src/rag_chat.py"
click node_query_embedding "https://github.com/nandishh18/rag-agent-judge/blob/main/src/rag_chat.py"
click node_retrieval "https://github.com/nandishh18/rag-agent-judge/blob/main/src/rag_chat.py"
click node_prompt "https://github.com/nandishh18/rag-agent-judge/blob/main/src/rag_chat.py"
click node_answer "https://github.com/nandishh18/rag-agent-judge/blob/main/src/rag_chat.py"
click node_batch_runner "https://github.com/nandishh18/rag-agent-judge/blob/main/src/answer_questions.py"
click node_report "https://github.com/nandishh18/rag-agent-judge/blob/main/src/answer_questions.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_index_build,node_pdf_ingest,node_embedding,node_vector_index,node_chunk_metadata,node_user toneBlue
class node_interactive,node_chatbot,node_query_embedding,node_retrieval,node_prompt,node_answer toneAmber
class node_batch_runner,node_report toneMint
class node_pdf toneTeal
class node_groq toneIndigo
```

## Components

### Indexing

- [Index Builder](https://github.com/nandishh18/rag-agent-judge/blob/main/src/build_index.py): `src/build_index.py`
- [PDF Extraction](https://github.com/nandishh18/rag-agent-judge/blob/main/src/ingest.py): `src/ingest.py`
- [Text Embeddings](https://github.com/nandishh18/rag-agent-judge/blob/main/src/build_index.py): `src/build_index.py`
- [FAISS Index](https://github.com/nandishh18/rag-agent-judge/blob/main/src/build_index.py): `src/build_index.py`
- [Chunk Metadata](https://github.com/nandishh18/rag-agent-judge/blob/main/src/build_index.py): `src/build_index.py`

### Question Answering

- [Interactive Chat](https://github.com/nandishh18/rag-agent-judge/blob/main/src/rag_chat.py): `src/rag_chat.py`
- [RAG Chatbot](https://github.com/nandishh18/rag-agent-judge/blob/main/src/rag_chat.py): `src/rag_chat.py`
- [Query Embedding](https://github.com/nandishh18/rag-agent-judge/blob/main/src/rag_chat.py): `src/rag_chat.py`
- [Chunk Retrieval](https://github.com/nandishh18/rag-agent-judge/blob/main/src/rag_chat.py): `src/rag_chat.py`
- [Prompt Assembly](https://github.com/nandishh18/rag-agent-judge/blob/main/src/rag_chat.py): `src/rag_chat.py`
- [Grounded Answer](https://github.com/nandishh18/rag-agent-judge/blob/main/src/rag_chat.py): `src/rag_chat.py`

### Batch Answers

- [Question Runner](https://github.com/nandishh18/rag-agent-judge/blob/main/src/answer_questions.py): `src/answer_questions.py`
- [Answer Report](https://github.com/nandishh18/rag-agent-judge/blob/main/src/answer_questions.py): `src/answer_questions.py`

### Other components

- [Paper PDF](https://github.com/nandishh18/rag-agent-judge/blob/main/data/agent_as_a_judge.pdf): `data/agent_as_a_judge.pdf`
- **User**
- **Groq LLM**

## Connections

- Paper PDF → PDF Extraction: extracts pages (evidence: `README.md`)
- PDF Extraction → Index Builder: loads chunks (evidence: `src/build_index.py`)
- Index Builder → Text Embeddings: embeds chunks (evidence: `src/build_index.py`)
- Text Embeddings → FAISS Index: adds vectors (evidence: `src/build_index.py`)
- Index Builder → Chunk Metadata: writes metadata (evidence: `src/build_index.py`)
- User → Interactive Chat: asks questions (evidence: `README.md`)
- Interactive Chat → RAG Chatbot: calls answer (evidence: `src/rag_chat.py`)
- RAG Chatbot → Chunk Retrieval: retrieves chunks (evidence: `src/rag_chat.py`)
- Chunk Retrieval → Query Embedding: embeds query (evidence: `src/rag_chat.py`)
- Chunk Retrieval → FAISS Index: searches index (evidence: `src/rag_chat.py`)
- Chunk Retrieval → Chunk Metadata: reads chunks (evidence: `src/rag_chat.py`)
- RAG Chatbot → Prompt Assembly: assembles context (evidence: `src/rag_chat.py`)
- Prompt Assembly → Groq LLM: requests completion (evidence: `src/rag_chat.py`)
- Groq LLM → Grounded Answer: returns answer (evidence: `src/rag_chat.py`)
- Grounded Answer → Interactive Chat: prints answer (evidence: `src/rag_chat.py`)
- Question Runner → RAG Chatbot: calls answer (evidence: `src/answer_questions.py`)
- Question Runner → Answer Report: writes report (evidence: `src/answer_questions.py`)
