# giovannipasq/agentic-rag-for-dummies architecture

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

- Interactive diagram: https://gitdiagram.com/giovannipasq/agentic-rag-for-dummies
- Repository: https://github.com/giovannipasq/agentic-rag-for-dummies

## Overview

1. **What this repository is**
   This repo is a reference implementation of an **Agentic RAG** system: a document question-answering pipeline that combines retrieval, query rewriting, clarification, multi-step reasoning, and answer synthesis. The repo is split into a **learning path** (`notebooks/`) and a **modular runnable app** (`project/`).

2. **Two main delivery surfaces**
   - **Notebooks**: step-by-step experimentation for chunking, retrieval, evaluation, and observability.
   - **Project app**: the production-shaped code path, launched from `project/app.py`, with modular packages for config, storage, graph orchestration, and UI.

3. **Document ingestion and preprocessing**
   The ingestion pipeline converts PDFs to Markdown, then splits them into a **hierarchical index**:
   - **Parent chunks**: larger markdown-based sections, stored as JSON files in a local parent store.
   - **Child chunks**: smaller retrieval units embedded into Qdrant.
   This design lets retrieval search precise snippets first, then pull larger surrounding context when needed.

4. **Storage boundary**
   The architecture intentionally separates **two retrieval stores**:
   - `project/db/vector_db_manager.py` for vector-backed child-chunk retrieval.
   - `project/db/parent_store_manager.py` for local parent-chunk persistence.
   That split is the key architectural boundary between **semantic search** and **full-context document loading**.

5. **RAG orchestration layer**
   The `project/core/` package holds the higher-level RAG plumbing:
   - `rag_system.py` coordinates the overall retrieval/answering workflow.
   - `document_manager.py` handles document lifecycle and indexing concerns.
   - `chat_interface.py` and `execution_logger.py` support conversational execution and run tracking.
   - `observability.py` integrates tracing/monitoring hooks.
   This layer is the bridge between UI, storage, and the agent graph.

6. **Agent workflow as a LangGraph state machine**
   The `project/rag_agent/` package defines the core reasoning graph:
   - `graph.py`, `nodes.py`, and `edges.py` describe the state transitions.
   - `graph_state.py` defines the conversation and agent state objects.
   - `tools.py` exposes retrieval tools to the LLM.
   - `prompts.py` contains the system prompts for rewriting, orchestration, compression, and synthesis.
   - `schemas.py` defines structured outputs used during query analysis.
   This is the main control plane of the system.

7. **How a question flows through the system**
   A user question enters the main graph, which:
   - summarizes older conversation history,
   - rewrites the query using recent context,
   - optionally pauses for clarification,
   - fans out into parallel agent subgraphs for multiple sub-questions,
   - retrieves child chunks and, if needed, parent chunks,
   - compresses intermediate context when the loop grows too large,
   - aggregates answers into one final response.
   This is a multi-stage retrieval-and-reasoning pipeline rather than a single prompt call.

8. **Human-in-the-loop behavior**
   The system explicitly treats ambiguous follow-ups as a separate boundary. If the query depends on unresolved references, the graph can interrupt and ask for clarification before spending retrieval budget. That makes the architecture interactive and stateful, not just stateless search + generation.

9. **State, memory, and execution limits**
   The graph uses structured state to keep:
   - conversation summary,
   - rewritten questions,
   - pending clarification context,
   - retrieval history,
   - per-agent answer drafts.
   The agent subgraph also enforces hard limits on tool calls and iterations, which protects against infinite retrieval loops and controls token growth.

10. **Retrieval strategy**
   Retrieval is hybrid and hierarchical:
   - Qdrant stores child chunks with vector search.
   - The agent first searches children for precision.
   - It loads parent chunks only when the child evidence is too fragmented.
   This is the central data-flow pattern in the repo.

11. **Interface and runtime**
   The UI is a **Gradio** chat application in `project/ui/`, with CSS customization and a chat wrapper that drives the graph. The repository also includes:
   - a `Dockerfile` for containerized execution,
   - `.env.example` for runtime configuration,
   - `requirements.txt` for Python dependencies.
   The default runtime is Python 3.11+.

12. **Model/provider flexibility**
   The README emphasizes provider-agnostic LLM support through LangChain. Ollama is the default runnable setup, but the architecture is designed so the chat model can be swapped for OpenAI, Anthropic, Google, or other LangChain-supported providers without changing the overall graph structure.

13. **Observability and evaluation**
   The repo has two non-production support tracks:
   - **Observability** notebook and `core/observability.py` for tracing tool use and graph execution.
   - **Evaluation** notebook with RAGAS-based scoring of retrieval and answer quality.
   These are important because the system is agentic: correctness depends on intermediate retrieval behavior, not just final output.

14. **How to think about the architecture diagram**
   A good diagram should show four major boundaries:
   1) document ingestion/indexing,
   2) persistent retrieval stores,
   3) LangGraph-based agent orchestration,
   4) Gradio chat front end.
   The critical arrows are: user input → query rewriting/clarification → retrieval tools → child/parent stores → answer synthesis → UI response, with observability and evaluation as side channels.

Main entry points: [`project/core/rag_system.py`](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/core/rag_system.py) (RAG System), [`README.md`](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/README.md) (Agentic RAG), [`project/rag_agent/nodes.py`](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/rag_agent/nodes.py) (Agent Nodes), [`project/document_chunker.py`](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/document_chunker.py) (Chunker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_notebooks["Notebooks"]
  node_n2["PDF→Markdown<br/>notebook workflow"]
  node_n3["RAG Walkthrough<br/>notebook workflow<br/>[agentic_rag.ipynb]"]
  node_n4["Eval Notebook<br/>evaluation<br/>[evaluation.ipynb]"]
  node_n5["Obs Notebook<br/>observability"]
end

subgraph group_runtime["Project App"]
  node_n6(("App Entry<br/>runtime entrypoint<br/>[app.py]"))
  node_n7["Config<br/>[config.py]"]
end

subgraph group_ingest["Ingestion"]
  node_n13["Chunker<br/>preprocessor"]
end

subgraph group_storage["Storage"]
  node_n14[("Vector Store<br/>qdrant retrieval")]
  node_n15[("Parent Store<br/>local document store")]
end

subgraph group_core["Core"]
  node_n8["RAG System<br/>orchestrator<br/>[rag_system.py]"]
  node_n9["Docs Manager<br/>lifecycle/indexing"]
  node_n10["Chat Interface<br/>conversation layer<br/>[chat_interface.py]"]
  node_n11["Execution Log<br/>run tracking"]
  node_n12["Observability<br/>tracing hooks<br/>[observability.py]"]
end

subgraph group_agent["Agent Graph"]
  node_n16["Graph State<br/>state model<br/>[graph_state.py]"]
  node_n17["Graph Control<br/>langgraph state machine<br/>[graph.py]"]
  node_n18["Agent Nodes<br/>agent stages<br/>[nodes.py]"]
  node_n19["Tools<br/>[tools.py]"]
  node_n20["Prompts<br/>prompt set<br/>[prompts.py]"]
  node_n21["Schemas<br/>structured outputs<br/>[schemas.py]"]
end

subgraph group_ui["UI"]
  node_n22["Gradio UI<br/>chat frontend<br/>[gradio_app.py]"]
  node_n23["UI Styles<br/>presentation<br/>[css.py]"]
end

node_n1["Agentic RAG<br/>reference implementation<br/>[README.md]"]

node_n1 -->|"learns via"| node_n2
node_n1 -->|"shows"| node_n3
node_n1 -->|"evaluates"| node_n4
node_n1 -->|"observes"| node_n5
node_n6 -->|"starts"| node_n8
node_n6 -->|"serves"| node_n22
node_n7 -->|"configures"| node_n6
node_n22 -->|"routes to"| node_n10
node_n10 -->|"delegates to"| node_n8
node_n8 -->|"indexes"| node_n9
node_n9 -->|"chunks"| node_n13
node_n13 -->|"embeds"| node_n14
node_n13 -->|"persists"| node_n15
node_n8 -->|"runs"| node_n17
node_n17 -->|"mutates"| node_n16
node_n17 -->|"executes"| node_n18
node_n18 -->|"calls"| node_n19
node_n18 -->|"guided by"| node_n20
node_n18 -->|"emits"| node_n21
node_n19 -->|"searches"| node_n14
node_n19 -->|"loads"| node_n15
node_n8 -.->|"logs"| node_n11
node_n8 -.->|"traces"| node_n12
node_n12 -.->|"inspires"| node_n5
node_n22 -->|"styles"| node_n23
node_n14 -->|"hierarchy"| node_n15

click node_n1 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/README.md"
click node_n2 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/notebooks/pdf_to_markdown.ipynb"
click node_n3 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/notebooks/agentic_rag.ipynb"
click node_n4 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/notebooks/evaluation.ipynb"
click node_n5 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/notebooks/observability.ipynb"
click node_n6 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/app.py"
click node_n7 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/config.py"
click node_n8 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/core/rag_system.py"
click node_n9 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/core/document_manager.py"
click node_n10 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/core/chat_interface.py"
click node_n11 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/core/execution_logger.py"
click node_n12 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/core/observability.py"
click node_n13 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/document_chunker.py"
click node_n14 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/db/vector_db_manager.py"
click node_n15 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/db/parent_store_manager.py"
click node_n16 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/rag_agent/graph_state.py"
click node_n17 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/rag_agent/graph.py"
click node_n18 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/rag_agent/nodes.py"
click node_n19 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/rag_agent/tools.py"
click node_n20 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/rag_agent/prompts.py"
click node_n21 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/rag_agent/schemas.py"
click node_n22 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/ui/gradio_app.py"
click node_n23 "https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/ui/css.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_n2,node_n3,node_n4,node_n5,node_n22,node_n23 toneBlue
class node_n6,node_n7 toneAmber
class node_n13 toneMint
class node_n14,node_n15 toneRose
class node_n8,node_n9,node_n10,node_n11,node_n12 toneIndigo
class node_n16,node_n17,node_n18,node_n19,node_n20,node_n21 toneTeal
class node_n1 toneNeutral
```

## Components

### Notebooks

Exploration, evaluation, and observability walkthroughs.

- [PDF→Markdown](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/notebooks/pdf_to_markdown.ipynb): notebook workflow · Experimentation path for document conversion and preprocessing. · `notebooks/pdf_to_markdown.ipynb`
- [RAG Walkthrough](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/notebooks/agentic_rag.ipynb): notebook workflow · End-to-end agentic RAG experimentation and iteration. · `notebooks/agentic_rag.ipynb`
- [Eval Notebook](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/notebooks/evaluation.ipynb): evaluation · RAGAS-based quality scoring and retrieval/answer assessment. · `notebooks/evaluation.ipynb`
- [Obs Notebook](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/notebooks/observability.ipynb): observability · Tracing and execution inspection for the agentic pipeline. · `notebooks/observability.ipynb`

### Project App

Runnable application and supporting packages.

- [App Entry](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/app.py): runtime entrypoint · Launches the modular application runtime. · `project/app.py`
- [Config](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/config.py): runtime config · Central application and provider configuration. · `project/config.py`

### Ingestion

PDF-to-markdown conversion and chunking.

- [Chunker](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/document_chunker.py): preprocessor · Splits markdown into hierarchical parent and child chunks. · `project/document_chunker.py`

### Storage

Vector and parent chunk persistence.

- [Vector Store](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/db/vector_db_manager.py): qdrant retrieval · Embeds and searches child chunks for precise semantic retrieval. · `project/db/vector_db_manager.py`
- [Parent Store](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/db/parent_store_manager.py): local document store · Persists parent chunks as JSON for larger surrounding context. · `project/db/parent_store_manager.py`

### Core

RAG coordination and execution support.

- [RAG System](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/core/rag_system.py): orchestrator · Top-level RAG coordination between UI, agent graph, and storage. · `project/core/rag_system.py`
- [Docs Manager](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/core/document_manager.py): lifecycle/indexing · Document lifecycle, indexing, and preparation for retrieval. · `project/core/document_manager.py`
- [Chat Interface](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/core/chat_interface.py): conversation layer · Conversation handling and response shaping for the app runtime. · `project/core/chat_interface.py`
- [Execution Log](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/core/execution_logger.py): run tracking · Execution logging and run bookkeeping for graph activity. · `project/core/execution_logger.py`
- [Observability](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/core/observability.py): tracing hooks · Monitoring and tracing integration for agent execution. · `project/core/observability.py`

### Agent Graph

LangGraph-based reasoning and retrieval control plane.

- [Graph State](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/rag_agent/graph_state.py): state model · Conversation, retrieval, clarification, and draft state for the agent. · `project/rag_agent/graph_state.py`
- [Graph Control](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/rag_agent/graph.py): langgraph state machine · Defines agent flow, node transitions, and interruption points. · `project/rag_agent/graph.py`
- [Agent Nodes](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/rag_agent/nodes.py): agent stages · Query rewriting, clarification, retrieval, compression, and synthesis steps. · `project/rag_agent/nodes.py`
- [Tools](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/rag_agent/tools.py): retrieval tools · LLM-facing access to child and parent retrieval functions. · `project/rag_agent/tools.py`
- [Prompts](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/rag_agent/prompts.py): prompt set · System prompts for rewriting, orchestration, compression, and answer synthesis. · `project/rag_agent/prompts.py`
- [Schemas](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/rag_agent/schemas.py): structured outputs · Typed outputs used for query analysis and agent decisions. · `project/rag_agent/schemas.py`

### UI

Chat front end.

- [Gradio UI](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/ui/gradio_app.py): chat frontend · Interactive chat application that drives the agentic pipeline. · `project/ui/gradio_app.py`
- [UI Styles](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/project/ui/css.py): presentation · CSS customization for the chat experience. · `project/ui/css.py`

### Other components

- [Agentic RAG](https://github.com/giovannipasq/agentic-rag-for-dummies/blob/main/README.md): reference implementation · Notebook-driven learning path and modular runnable app for agentic retrieval-augmented QA. · `README.md`

## Connections

- Agentic RAG → PDF→Markdown: learns via · The repository’s notebook path begins with conversion and preprocessing exploration.
- Agentic RAG → RAG Walkthrough: shows · The main learning workflow demonstrates the agentic RAG pipeline.
- Agentic RAG → Eval Notebook: evaluates · Evaluation notebook measures retrieval and answer quality.
- Agentic RAG → Obs Notebook: observes · Observability notebook inspects tracing and execution behavior.
- App Entry → RAG System: starts · The application entrypoint launches the RAG system.
- App Entry → Gradio UI: serves · The app runtime exposes the Gradio chat interface.
- Config → App Entry: configures · Runtime settings and model/provider choices feed startup.
- Gradio UI → Chat Interface: routes to · User chat is handled through the core conversation layer.
- Chat Interface → RAG System: delegates to · Conversation requests are handed to the RAG orchestrator.
- RAG System → Docs Manager: indexes · The orchestrator relies on document lifecycle and indexing management.
- Docs Manager → Chunker: chunks · Documents are split into hierarchical parent and child chunks.
- Chunker → Vector Store: embeds · Child chunks are prepared for vector retrieval.
- Chunker → Parent Store: persists · Parent chunks are stored for later full-context loading.
- RAG System → Graph Control: runs · The RAG system drives the LangGraph control plane.
- Graph Control → Graph State: mutates · Graph execution reads and updates structured agent state.
- Graph Control → Agent Nodes: executes · The control plane advances through reasoning and retrieval nodes.
- Agent Nodes → Tools: calls · Agent stages use retrieval tools for child and parent lookup.
- Agent Nodes → Prompts: guided by · Prompt templates steer rewriting, compression, and synthesis behavior.
- Agent Nodes → Schemas: emits · Structured schemas constrain analysis and decision outputs.
- Tools → Vector Store: searches · Primary retrieval queries the vector store for child chunks.
- Tools → Parent Store: loads · When child evidence is sparse, parent context is fetched.
- RAG System → Execution Log: logs · Execution bookkeeping captures run-level activity.
- RAG System → Observability: traces · Observability hooks instrument agent execution.
- Observability → Obs Notebook: inspires · Notebook-based observability mirrors runtime tracing.
- Gradio UI → UI Styles: styles · The UI is customized through shared CSS settings.
- Vector Store → Parent Store: hierarchy · Semantic child retrieval is paired with parent-context expansion.
