# shivam-83/rag-agentic-ai architecture

> Architecture diagram of the GitHub repository shivam-83/rag-agentic-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shivam-83/rag-agentic-ai
- Repository: https://github.com/shivam-83/rag-agentic-ai

## Overview

This is a document-grounded RAG chatbot for the Agentic AI eBook. Its main workflow ingests the PDF into a Pinecone index, then retrieves relevant chunks and generates a strictly grounded answer with a fallback for unsupported questions. Users can query through either the FastAPI endpoint or the Streamlit chat, which displays confidence and retrieved citations. The graph reflects documented calls and README capabilities; unsampled subsystems are represented only where the README supports them.

Main entry points: [`src/graph.py`](https://github.com/shivam-83/rag-agentic-ai/blob/main/src/graph.py) (LangGraph Workflow), [`app.py`](https://github.com/shivam-83/rag-agentic-ai/blob/main/app.py) (FastAPI Chat API), [`streamlit_app.py`](https://github.com/shivam-83/rag-agentic-ai/blob/main/streamlit_app.py) (Streamlit Chat), [`src/ingestion.py`](https://github.com/shivam-83/rag-agentic-ai/blob/main/src/ingestion.py) (PDF Loading)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Document Ingestion"]
  node_pdf_load["PDF Loading<br/>[ingestion.py]"]
  node_chunking["Text Chunking<br/>[ingestion.py]"]
  node_embedding["Gemini Embeddings<br/>[ingestion.py]"]
  node_index_setup["Index Setup<br/>[ingestion.py]"]
  node_upsert["Chunk Upsert<br/>[ingestion.py]"]
end

subgraph group_retrieval["Knowledge Retrieval"]
  node_pinecone[("Pinecone Index")]
  node_retriever["Document Retrieval<br/>[retrieval.py]"]
end

subgraph group_workflow["Answer Workflow"]
  node_config["Runtime Configuration<br/>[config.py]"]
  node_rag_graph["LangGraph Workflow<br/>[graph.py]"]
  node_retrieve_node["Retrieve Node<br/>[graph.py]"]
  node_generate_node["Generate Node<br/>[graph.py]"]
end

subgraph group_interfaces["User Interfaces"]
  node_api["FastAPI Chat API<br/>[app.py]"]
  node_streamlit["Streamlit Chat<br/>[streamlit_app.py]"]
end

node_user(("User"))
node_ebook["Agentic AI eBook"]
node_gemini_chat{{"Gemini Chat Model"}}

node_ebook -->|"loads"| node_pdf_load
node_pdf_load -->|"splits pages"| node_chunking
node_chunking -->|"embeds chunks"| node_embedding
node_embedding -->|"provides vectors"| node_upsert
node_index_setup -->|"creates index"| node_pinecone
node_upsert -->|"upserts chunks"| node_pinecone
node_user -->|"submits query"| node_api
node_user -->|"asks question"| node_streamlit
node_api -->|"invokes"| node_rag_graph
node_streamlit -->|"invokes"| node_rag_graph
node_rag_graph -->|"dispatches"| node_retrieve_node
node_retrieve_node -->|"queries"| node_retriever
node_retriever -->|"searches index"| node_pinecone
node_retrieve_node -->|"passes context"| node_generate_node
node_generate_node -->|"invokes"| node_gemini_chat
node_rag_graph -->|"reads settings"| node_config
node_api -->|"returns answer"| node_user
node_streamlit -->|"shows answer and citations"| node_user

click node_ebook "https://github.com/shivam-83/rag-agentic-ai/blob/main/data/Ebook-Agentic-AI.pdf"
click node_pdf_load "https://github.com/shivam-83/rag-agentic-ai/blob/main/src/ingestion.py"
click node_chunking "https://github.com/shivam-83/rag-agentic-ai/blob/main/src/ingestion.py"
click node_embedding "https://github.com/shivam-83/rag-agentic-ai/blob/main/src/ingestion.py"
click node_index_setup "https://github.com/shivam-83/rag-agentic-ai/blob/main/src/ingestion.py"
click node_upsert "https://github.com/shivam-83/rag-agentic-ai/blob/main/src/ingestion.py"
click node_retriever "https://github.com/shivam-83/rag-agentic-ai/blob/main/src/retrieval.py"
click node_config "https://github.com/shivam-83/rag-agentic-ai/blob/main/src/config.py"
click node_rag_graph "https://github.com/shivam-83/rag-agentic-ai/blob/main/src/graph.py"
click node_retrieve_node "https://github.com/shivam-83/rag-agentic-ai/blob/main/src/graph.py"
click node_generate_node "https://github.com/shivam-83/rag-agentic-ai/blob/main/src/graph.py"
click node_api "https://github.com/shivam-83/rag-agentic-ai/blob/main/app.py"
click node_streamlit "https://github.com/shivam-83/rag-agentic-ai/blob/main/streamlit_app.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_load,node_chunking,node_embedding,node_index_setup,node_upsert,node_user toneBlue
class node_pinecone,node_retriever toneAmber
class node_config,node_rag_graph,node_retrieve_node,node_generate_node toneMint
class node_api,node_streamlit toneRose
class node_ebook toneTeal
class node_gemini_chat toneIndigo
```

## Components

### Document Ingestion

- [PDF Loading](https://github.com/shivam-83/rag-agentic-ai/blob/main/src/ingestion.py): `src/ingestion.py`
- [Text Chunking](https://github.com/shivam-83/rag-agentic-ai/blob/main/src/ingestion.py): `src/ingestion.py`
- [Gemini Embeddings](https://github.com/shivam-83/rag-agentic-ai/blob/main/src/ingestion.py): `src/ingestion.py`
- [Index Setup](https://github.com/shivam-83/rag-agentic-ai/blob/main/src/ingestion.py): `src/ingestion.py`
- [Chunk Upsert](https://github.com/shivam-83/rag-agentic-ai/blob/main/src/ingestion.py): `src/ingestion.py`

### Knowledge Retrieval

- **Pinecone Index**
- [Document Retrieval](https://github.com/shivam-83/rag-agentic-ai/blob/main/src/retrieval.py): `src/retrieval.py`

### Answer Workflow

- [Runtime Configuration](https://github.com/shivam-83/rag-agentic-ai/blob/main/src/config.py): `src/config.py`
- [LangGraph Workflow](https://github.com/shivam-83/rag-agentic-ai/blob/main/src/graph.py): `src/graph.py`
- [Retrieve Node](https://github.com/shivam-83/rag-agentic-ai/blob/main/src/graph.py): `src/graph.py`
- [Generate Node](https://github.com/shivam-83/rag-agentic-ai/blob/main/src/graph.py): `src/graph.py`

### User Interfaces

- [FastAPI Chat API](https://github.com/shivam-83/rag-agentic-ai/blob/main/app.py): `app.py`
- [Streamlit Chat](https://github.com/shivam-83/rag-agentic-ai/blob/main/streamlit_app.py): `streamlit_app.py`

### Other components

- **User**
- [Agentic AI eBook](https://github.com/shivam-83/rag-agentic-ai/blob/main/data/Ebook-Agentic-AI.pdf): `data/Ebook-Agentic-AI.pdf`
- **Gemini Chat Model**

## Connections

- Agentic AI eBook → PDF Loading: loads (evidence: `src/ingestion.py`)
- PDF Loading → Text Chunking: splits pages (evidence: `src/ingestion.py`)
- Text Chunking → Gemini Embeddings: embeds chunks (evidence: `src/ingestion.py`)
- Gemini Embeddings → Chunk Upsert: provides vectors (evidence: `src/ingestion.py`)
- Index Setup → Pinecone Index: creates index (evidence: `src/ingestion.py`)
- Chunk Upsert → Pinecone Index: upserts chunks (evidence: `src/ingestion.py`)
- User → FastAPI Chat API: submits query (evidence: `README.md`)
- User → Streamlit Chat: asks question (evidence: `README.md`)
- FastAPI Chat API → LangGraph Workflow: invokes (evidence: `app.py`)
- Streamlit Chat → LangGraph Workflow: invokes (evidence: `streamlit_app.py`)
- LangGraph Workflow → Retrieve Node: dispatches (evidence: `src/graph.py`)
- Retrieve Node → Document Retrieval: queries (evidence: `src/graph.py`)
- Document Retrieval → Pinecone Index: searches index (evidence: `src/retrieval.py`)
- Retrieve Node → Generate Node: passes context (evidence: `src/graph.py`)
- Generate Node → Gemini Chat Model: invokes (evidence: `src/graph.py`)
- LangGraph Workflow → Runtime Configuration: reads settings (evidence: `src/graph.py`)
- FastAPI Chat API → User: returns answer (evidence: `app.py`)
- Streamlit Chat → User: shows answer and citations (evidence: `streamlit_app.py`)
