# menawang/agentic-rag-with-llamaindex architecture

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

- Interactive diagram: https://gitdiagram.com/menawang/agentic-rag-with-llamaindex
- Repository: https://github.com/menawang/agentic-rag-with-llamaindex

## Overview

##### Project type and purpose
- This is a tutorial/demo project that showcases how to build “agentic RAG” (Retrieval-Augmented Generation) workflows on top of LlamaIndex.
- It consists of four Jupyter notebooks (L1–L4) which each demonstrate a lesson:
- L1: Router engine that dispatches queries to either a vector-search Q&A tool or a summarization tool.
- L2: Tool-calling where the LLM infers parameters for downstream tools.
- L3: A multi-step agent using AgentRunner/AgentWorker with human-in-the-loop steering.
- L4: “RAG over tools” where a retriever selects a subset of document-specific tools to feed into the agent.

##### File structure
- Top level:
- .gitignore
- requirements_py311.txt — dependency list (e.g. llamaindex, openai, faiss, etc.).
- helper.py, utils.py — library modules that encapsulate core functions:
– get_router_query_engine()
– get_doc_tools()
– helpers to build retrievers, agent runners/workers.
- Four Jupyter notebooks (L1_…–L4_…) as the orchestration layer.

##### README for architectural hints
- AgentRunner ↔ AgentWorker
- RAG over tools
- It mentions components: router engine, vector store Q&A, summary tool, retriever, AgentRunner, AgentWorker, human-in-loop.

##### Don’t overthink—capture every major component and its connections. The goal is
- How queries flow
- How tools and retrievers are invoked
- Where human oversight fits
- Which libraries/APIs are in play

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    User["User"]:::user

    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        L1["L1: Router Engine"]:::presentation
        L2["L2: Tool-Calling"]:::presentation
        L3["L3: Multi-Step Agent"]:::presentation
        L4["L4: RAG over Tools"]:::presentation
    end

    %% Service/Library Layer
    subgraph "Service/Library Layer"
        direction TB
        Helper["helper.py"]:::service
        Utils["utils.py"]:::service
    end

    %% Router Engine
    Router["Router Engine"]:::service

    %% Retrieval & Tools
    subgraph "Retrieval & Tools"
        direction TB
        VectorStore["Vector Store"]:::datastore
        Retriever["Retriever"]:::tool
        QA["Q&A Tool"]:::tool
        Summary["Summarization Tool"]:::tool
        DocTools["Document-Specific Tools"]:::tool
    end

    %% Agent Components
    subgraph "Agent Components"
        direction TB
        Runner["AgentRunner (Planner)"]:::service
        Worker["AgentWorker (Executor)"]:::service
    end

    %% External Services
    subgraph "External Services"
        direction TB
        LLMAPI["LLM API"]:::external
        VectorDB["Vector DB Service"]:::external
    end

    %% Support Files
    subgraph "Support Files"
        direction TB
        README["README.md"]:::support
        Requirements["requirements_py311.txt"]:::support
        Images["image/"]:::support
        Gitignore[".gitignore"]:::support
    end

    %% Connections
    User -->|"opens notebook"| L1
    User --> L2
    User --> L3
    User --> L4

    L1 -->|uses| Helper
    L2 -->|uses| Helper
    L3 -->|uses| Helper
    L4 -->|uses| Helper

    L1 -->|uses| Utils
    L2 -->|uses| Utils
    L3 -->|uses| Utils
    L4 -->|uses| Utils

    Helper --> Router
    Utils --> Router

    Router -->|routes to| QA
    Router -->|routes to| Summary

    QA --> Retriever
    Summary --> LLMAPI

    Retriever --> VectorStore
    Retriever -->|embeddings| LLMAPI

    DocTools --> Retriever

    Runner --> Worker
    Runner -->|invokes| QA
    Runner -->|invokes| Summary
    Runner -->|invokes| DocTools
    Worker -->|executes steps| QA
    Worker -->|executes steps| Summary

    Runner -->|retrieves tools via| Retriever
    L4 -->|configures| Runner

    QA --> LLMAPI
    DocTools --> LLMAPI

    VectorStore --> VectorDB

    README
    Requirements
    Images
    Gitignore

    %% Click Events
    click L1 "https://github.com/menawang/agentic-rag-with-llamaindex/blob/main/L1_Router_Engine.ipynb"
    click L2 "https://github.com/menawang/agentic-rag-with-llamaindex/blob/main/L2_Tool_Calling.ipynb"
    click L3 "https://github.com/menawang/agentic-rag-with-llamaindex/blob/main/L3_Building_an_Agent_Reasoning_Loop.ipynb"
    click L4 "https://github.com/menawang/agentic-rag-with-llamaindex/blob/main/L4_Building_a_Multi-Document_Agent.ipynb"
    click Helper "https://github.com/menawang/agentic-rag-with-llamaindex/blob/main/helper.py"
    click Utils "https://github.com/menawang/agentic-rag-with-llamaindex/blob/main/utils.py"
    click README "https://github.com/menawang/agentic-rag-with-llamaindex/blob/main/README.md"
    click Requirements "https://github.com/menawang/agentic-rag-with-llamaindex/blob/main/requirements_py311.txt"
    click Images "https://github.com/menawang/agentic-rag-with-llamaindex/tree/main/image/"
    click Gitignore "https://github.com/menawang/agentic-rag-with-llamaindex/blob/main/.gitignore"

    %% Styles
    classDef user fill:#f2f2f2,stroke:#333,stroke-width:1px
    classDef presentation fill:#cce5ff,stroke:#005cbf,stroke-width:1px
    classDef service fill:#d4edda,stroke:#155724,stroke-width:1px
    classDef tool fill:#d1ecf1,stroke:#0c5460,stroke-width:1px
    classDef datastore fill:#fff3cd,stroke:#856404,stroke-width:1px
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:1px
    classDef support fill:#e2e3e5,stroke:#6c757d,stroke-width:1px
```
