# mdsohail07/rag_agent architecture

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

- Interactive diagram: https://gitdiagram.com/mdsohail07/rag_agent
- Repository: https://github.com/mdsohail07/rag_agent

## Overview

This repository is a small LangChain learning project, centered on a Streamlit PDF RAG agent, with a separate Gemini Q&A chatbot. The main workflow uploads PDFs, loads and chunks them, embeds them into an in-memory vector store, then answers questions through an agent with retrieval and conversation checkpointing. The README also advertises streaming responses, represented here as a capability; its implementation was not inspected. Edges reflect the sampled app code or README; notebook experiments are not expanded into runtime components.

Main entry points: [`apps/rag_agent.py`](https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py) (RAG workflow), [`apps/1_qna_bot.py`](https://github.com/mdsohail07/rag_agent/blob/main/apps/1_qna_bot.py) (Gemini chat UI), [`apps/doc_files`](https://github.com/mdsohail07/rag_agent/tree/main/apps/doc_files) (Uploaded PDFs), [`notebooks/streaming_response.ipynb`](https://github.com/mdsohail07/rag_agent/blob/main/notebooks/streaming_response.ipynb) (Streaming responses)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_rag["PDF RAG"]
  node_rag_ui["Upload and chat UI<br/>[rag_agent.py]"]
  node_workflow["RAG workflow<br/>[rag_agent.py]"]
  node_pdfs[("Uploaded PDFs")]
  node_loader["PDF loader<br/>[rag_agent.py]"]
  node_splitter["Text chunking<br/>[rag_agent.py]"]
  node_embeddings["Gemini embeddings<br/>[rag_agent.py]"]
  node_embedding_service{{"Gemini embedding API"}}
  node_vector_store[("In-memory vector store<br/>[rag_agent.py]")]
  node_agent["Question-answer agent<br/>[rag_agent.py]"]
  node_retrieval["Context retrieval tool<br/>[rag_agent.py]"]
  node_groq{{"Groq LLM"}}
  node_memory[("Conversation checkpoint<br/>[rag_agent.py]")]
  node_streaming["Streaming responses"]
end

subgraph group_chat["Gemini Chat"]
  node_chat_ui["Gemini chat UI<br/>[1_qna_bot.py]"]
  node_gemini_chat{{"Gemini chat model"}}
end

node_user(("User"))

node_user -->|"uploads, asks"| node_rag_ui
node_rag_ui -->|"processes upload"| node_workflow
node_workflow -->|"writes files"| node_pdfs
node_loader -->|"loads PDFs"| node_pdfs
node_workflow -->|"loads documents"| node_loader
node_workflow -->|"splits documents"| node_splitter
node_workflow -->|"creates vectors"| node_embeddings
node_embeddings -->|"requests embeddings"| node_embedding_service
node_workflow -->|"indexes chunks"| node_vector_store
node_workflow -->|"creates agent"| node_agent
node_agent -->|"registers tool"| node_retrieval
node_retrieval -->|"searches vectors"| node_vector_store
node_agent -->|"uses model"| node_groq
node_agent -->|"configures checkpoint"| node_memory
node_user -->|"asks question"| node_chat_ui
node_chat_ui -->|"invokes model"| node_gemini_chat
node_workflow -.->|"supports streaming"| node_streaming

click node_rag_ui "https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py"
click node_workflow "https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py"
click node_pdfs "https://github.com/mdsohail07/rag_agent/tree/main/apps/doc_files"
click node_loader "https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py"
click node_splitter "https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py"
click node_embeddings "https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py"
click node_vector_store "https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py"
click node_agent "https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py"
click node_retrieval "https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py"
click node_memory "https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py"
click node_streaming "https://github.com/mdsohail07/rag_agent/blob/main/notebooks/streaming_response.ipynb"
click node_chat_ui "https://github.com/mdsohail07/rag_agent/blob/main/apps/1_qna_bot.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_rag_ui,node_workflow,node_pdfs,node_loader,node_splitter,node_embeddings,node_embedding_service,node_vector_store,node_agent,node_retrieval,node_groq,node_memory,node_streaming,node_user toneBlue
class node_chat_ui,node_gemini_chat toneAmber
```

## Components

### PDF RAG

- [Upload and chat UI](https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py): `apps/rag_agent.py`
- [RAG workflow](https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py): `apps/rag_agent.py`
- [Uploaded PDFs](https://github.com/mdsohail07/rag_agent/tree/main/apps/doc_files): `apps/doc_files`
- [PDF loader](https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py): `apps/rag_agent.py`
- [Text chunking](https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py): `apps/rag_agent.py`
- [Gemini embeddings](https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py): `apps/rag_agent.py`
- **Gemini embedding API**
- [In-memory vector store](https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py): `apps/rag_agent.py`
- [Question-answer agent](https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py): `apps/rag_agent.py`
- [Context retrieval tool](https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py): `apps/rag_agent.py`
- **Groq LLM**
- [Conversation checkpoint](https://github.com/mdsohail07/rag_agent/blob/main/apps/rag_agent.py): `apps/rag_agent.py`
- [Streaming responses](https://github.com/mdsohail07/rag_agent/blob/main/notebooks/streaming_response.ipynb): `notebooks/streaming_response.ipynb`

### Gemini Chat

- [Gemini chat UI](https://github.com/mdsohail07/rag_agent/blob/main/apps/1_qna_bot.py): `apps/1_qna_bot.py`
- **Gemini chat model**

### Other components

- **User**

## Connections

- User → Upload and chat UI: uploads, asks (evidence: `apps/rag_agent.py`)
- Upload and chat UI → RAG workflow: processes upload (evidence: `apps/rag_agent.py`)
- RAG workflow → Uploaded PDFs: writes files (evidence: `apps/rag_agent.py`)
- PDF loader → Uploaded PDFs: loads PDFs (evidence: `apps/rag_agent.py`)
- RAG workflow → PDF loader: loads documents (evidence: `apps/rag_agent.py`)
- RAG workflow → Text chunking: splits documents (evidence: `apps/rag_agent.py`)
- RAG workflow → Gemini embeddings: creates vectors (evidence: `apps/rag_agent.py`)
- Gemini embeddings → Gemini embedding API: requests embeddings (evidence: `apps/rag_agent.py`)
- RAG workflow → In-memory vector store: indexes chunks (evidence: `apps/rag_agent.py`)
- RAG workflow → Question-answer agent: creates agent (evidence: `apps/rag_agent.py`)
- Question-answer agent → Context retrieval tool: registers tool (evidence: `apps/rag_agent.py`)
- Context retrieval tool → In-memory vector store: searches vectors (evidence: `apps/rag_agent.py`)
- Question-answer agent → Groq LLM: uses model (evidence: `apps/rag_agent.py`)
- Question-answer agent → Conversation checkpoint: configures checkpoint (evidence: `apps/rag_agent.py`)
- User → Gemini chat UI: asks question (evidence: `apps/1_qna_bot.py`)
- Gemini chat UI → Gemini chat model: invokes model (evidence: `apps/1_qna_bot.py`)
- RAG workflow → Streaming responses: supports streaming (evidence: `README.md`)
