# gurmeet289/agentic-rag-system-multi-file-upload---embed---chat- architecture

> Architecture diagram of the GitHub repository gurmeet289/agentic-rag-system-multi-file-upload---embed---chat-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gurmeet289/agentic-rag-system-multi-file-upload---embed---chat-
- Repository: https://github.com/gurmeet289/agentic-rag-system-multi-file-upload---embed---chat-

## Overview

##### Project Type and Purpose
- This is a “full-stack” single-page application built with Streamlit for the UI and Python scripts for the backend logic.
- Purpose: let users upload multiple PDF/TXT docs, embed them into a local vector store (ChromaDB), then chat and automatically route questions to a calculator, RAG (using embedded docs), or web search.

##### File Structure
- Top-level directory:
- app.py ­– Streamlit UI, tabbed interface (“Upload & Embed” and “Chat/Ask”)
- rag_core.py ­– defines the agentic routing logic (calculator / RAG / web search) and LLM calls via LangChain & Gemini
- ingest_incremental.py ­– handles incremental ingestion: file load, chunking, embedding, saving into ChromaDB
- data/ ­– raw uploaded documents
- chroma_db_hf/ ­– persistent vector store on disk
- .env ­– API keys (Gemini)
- No traditional “frontend vs backend” directories, but the separation is logical: app.py (presentation) vs rag_core.py & ingest_incremental.py (business logic) vs vector store & data folder (persistence).

##### README for Additional Insights
- Confirms three workflows: Upload & Embed, Chat/Ask, and internal routing logic.
- Lists key technologies (Streamlit, LangChain, ChromaDB, local HF embeddings, Gemini, duckduckgo-search).

a. Main Components
- User Browser (Streamlit UI)
- Streamlit App (app.py)
- Ingestion Module (ingest_incremental.py)
- Routing & LLM Module (rag_core.py)
- Vector Store (ChromaDB on disk)
- Embedding Engine (local HuggingFace model)
- LLM Service (Gemini via LangChain)
- Tools / External Services:
- Calculator (native Python)
- Web Search (DuckDuckGo API)
- Data Persistence: raw docs folder + vector store folder + .env for config

b. Relationships & Data Flows
1. Upload & Embed Flow:
- User → UI → Ingestion Module → Chunk → Embed → store in ChromaDB
2. Chat / Ask Flow:
- User question → UI → Routing Module
– If math → Calculator → return answer
– If docs context → Vector Store lookup + LLM → return answer + sources
– If time-sensitive → Web Search → return answer + snippet
3. Both flows return results back to UI for display

c. Architectural Patterns & Design Principles
- Agentic Tool Routing Pattern (deterministic routing to tools)
- Retrieval-Augmented Generation (RAG)
- Incremental Ingestion (idempotent embeddings)
- Persistent Vector Store for statefulness

d. Key Technologies & Frameworks
- Presentation: Streamlit (app.py)
- Business Logic: Python scripts, LangChain wrappers
- Embeddings: local HuggingFace models (no API cost)
- Vector Store: ChromaDB
- LLM: Google Gemini via LangChain-Google-GenAI
- Search: duckduckgo-search

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layer 1: Presentation
    subgraph "Layer 1: Presentation"
        User["User Browser"]:::external
        UI["Streamlit UI"]:::ui
    end

    %% Layer 2: Application Logic
    subgraph "Layer 2: Application Logic"
        Ingest["Ingestion Module"]:::logic
        Routing["Routing & LLM Module"]:::logic
    end

    %% Layer 3: Data & AI Services
    subgraph "Layer 3: Data & AI Services"
        Embedding["Embedding Engine\n(Local HF Model)"]:::ai
        VectorStore["Vector Store\n(ChromaDB)"]:::ai
        LLM["LLM Service\n(Gemini via LangChain)"]:::ai
        Calculator["Calculator Tool"]:::tool
        WebSearch["Web Search Tool\n(DuckDuckGo API)"]:::tool
    end

    %% Layer 4: Persistence & Config
    subgraph "Layer 4: Persistence & Config"
        RawData["Raw Data Folder"]:::persistence
        PDF1["Agentic AI – the new frontier in GenAI.pdf"]:::persistence
        PDF2["Ebook-Agentic-AI.pdf"]:::persistence
        PDF3["Final-Web-Version-Report-AI-Agents.pdf"]:::persistence
        PDF4["a-practical-guide-to-building-agents.pdf"]:::persistence
        Env[".env (API Keys)"]:::persistence
        README["README.md"]:::persistence
        LICENSE["LICENSE"]:::persistence
    end

    %% Connections
    User -->|"Interacts with"| UI
    UI -->|"Upload & Embed"| Ingest
    Ingest -->|"Chunk & Embed"| Embedding
    Embedding -->|"Store Embeddings"| VectorStore
    VectorStore -->|"Check for new docs"| Ingest

    UI -->|"User Query"| Routing
    Routing -->|"Math?"| Calculator
    Routing -->|"Docs Context?"| VectorStore
    VectorStore -->|"Retrieve + RAG"| LLM
    Routing -->|"Time-Sensitive?"| WebSearch

    Calculator -->|"Answer"| UI
    LLM -->|"Answer + Sources"| UI
    WebSearch -->|"Answer + Snippet"| UI

    Env -->|"API Keys"| LLM
    Env -->|"API Keys"| WebSearch

    RawData --> PDF1
    RawData --> PDF2
    RawData --> PDF3
    RawData --> PDF4

    %% Click Events
    click UI "https://github.com/gurmeet289/agentic-rag-system-multi-file-upload---embed---chat-/blob/main/Agentic_RAG/app.py"
    click Ingest "https://github.com/gurmeet289/agentic-rag-system-multi-file-upload---embed---chat-/blob/main/Agentic_RAG/ingest_incremental.py"
    click Routing "https://github.com/gurmeet289/agentic-rag-system-multi-file-upload---embed---chat-/blob/main/Agentic_RAG/rag_core.py"
    click RawData "https://github.com/gurmeet289/agentic-rag-system-multi-file-upload---embed---chat-/tree/main/Agentic_RAG/data/"
    click PDF1 "https://github.com/gurmeet289/agentic-rag-system-multi-file-upload---embed---chat-/blob/main/Agentic_RAG/data/Agentic AI – the new frontier in GenAI.pdf"
    click PDF2 "https://github.com/gurmeet289/agentic-rag-system-multi-file-upload---embed---chat-/blob/main/Agentic_RAG/data/Ebook-Agentic-AI.pdf"
    click PDF3 "https://github.com/gurmeet289/agentic-rag-system-multi-file-upload---embed---chat-/blob/main/Agentic_RAG/data/Final-Web-Version-Report-AI-Agents.pdf"
    click PDF4 "https://github.com/gurmeet289/agentic-rag-system-multi-file-upload---embed---chat-/blob/main/Agentic_RAG/data/a-practical-guide-to-building-agents.pdf"
    click README "https://github.com/gurmeet289/agentic-rag-system-multi-file-upload---embed---chat-/blob/main/README.md"
    click LICENSE "https://github.com/gurmeet289/agentic-rag-system-multi-file-upload---embed---chat-/tree/main/LICENSE"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#1E70BF,stroke-width:2px
    classDef logic fill:#E0F4E0,stroke:#2E8B2E,stroke-width:2px
    classDef ai fill:#FFE8B0,stroke:#D38F00,stroke-width:2px
    classDef persistence fill:#F0F0F0,stroke:#888888,stroke-width:1px
    classDef external fill:#FFFFFF,stroke:#000000,stroke-width:1px,stroke-dasharray: 5 5
    classDef tool fill:#F4E1FF,stroke:#8A2BE2,stroke-width:2px
```
