# swethaguru-snsihub/agenticai_workshop architecture

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

- Interactive diagram: https://gitdiagram.com/swethaguru-snsihub/agenticai_workshop
- Repository: https://github.com/swethaguru-snsihub/agenticai_workshop

## Overview

##### Project type and purpose
- This “Conversational AI” folder is a Python-based Retrieval-Augmented Generation (RAG) chat system.
- It ingests domain data (JSON files), indexes them in a FAISS vector store, and uses an LLM (wrapped in `gemini_model.py`) to answer user queries with retrieved context.

##### File structure
- Top-level script:
- `main.py` – orchestrates the end-to-end flow (load data, build or load index, handle queries).
- Data sources:
- `datas/koramangala_stores.json` and `datas/stores_data.json` – JSON knowledge bases.
- Vector index:
- `faiss_index/index.faiss` + `index.pkl` – serialized FAISS index & metadata.
- Models:
- `models/gemini_model.py` – wraps the LLM (e.g., OpenAI, Vertex AI) with predict/generation logic.
- Services (business logic):
- `services/vector_store_service.py` – create embeddings, persist/load the FAISS index.
- `services/rag_utils.py` – assemble prompt with retrieved docs.
- `services/langgraph_agent.py` – manage agent loop, tool invocation patterns.
- `services/stores.py` – data-loader for JSON store files.
- Config/dependencies:
- `requirements.txt` – Python packages (e.g., faiss-cpu, langchain, openai).

##### Key architectural insights from README (assumed)
- The system uses RAG: retrieval from vector store plus LLM generation.
- Modular services separate concerns: data loading, indexing, retrieval, prompting, LLM inference.

a. Main components:
1. User Interface (CLI or API endpoint in `main.py`)
2. Data Layer
– JSON Knowledge Bases (`datas/…`)
– FAISS Vector Store (`faiss_index/…`)
3. Service Layer
– Data Loader Service (`stores.py`)
– Vector Store Service (`vector_store_service.py`)
– RAG Utilities (`rag_utils.py`)
– Agent Controller (`langgraph_agent.py`)
4. Model Layer
– LLM Wrapper (`gemini_model.py`)
5. (Optional) Logging/Monitoring or Config (not present but can be shown)
b. Relationships & interactions:
- The UI calls the Agent Controller.
- The Agent invokes Vector Store Service to retrieve top-k docs.
- RAG Utilities combine docs + user query into prompt.
- LLM Wrapper is invoked with prompt → generates answer.
- Answer returned to UI.
- On first run or data-update, Data Loader Service parses JSON → Vector Store Service builds or refreshes FAISS index.
c. Architectural patterns & principles:
– Layered architecture: Interface → Services → Models → Data
– Single responsibility per module (data loading vs. indexing vs. prompting vs. inference)
– Separation of concerns: index persistence decoupled from model inference
d. Key technologies & libraries:
– FAISS for vector-based retrieval
– An LLM API (via `gemini_model.py`)
– JSON as the knowledge-base format
– Python packaging (`requirements.txt`)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    UI["User Interface (CLI/API)"]:::ui
    click UI "https://github.com/swethaguru-snsihub/agenticai_workshop/blob/main/Conversational AI/Conversational AI/main.py"

    %% Data Layer
    subgraph "Data Layer"
        JSON1["koramangala_stores.json"]:::data
        JSON2["stores_data.json"]:::data
        INDEX_FAISS["index.faiss"]:::data
        INDEX_PKL["index.pkl"]:::data
    end
    click JSON1 "https://github.com/swethaguru-snsihub/agenticai_workshop/blob/main/Conversational AI/Conversational AI/datas/koramangala_stores.json"
    click JSON2 "https://github.com/swethaguru-snsihub/agenticai_workshop/blob/main/Conversational AI/Conversational AI/datas/stores_data.json"
    click INDEX_FAISS "https://github.com/swethaguru-snsihub/agenticai_workshop/blob/main/Conversational AI/Conversational AI/faiss_index/index.faiss"
    click INDEX_PKL "https://github.com/swethaguru-snsihub/agenticai_workshop/blob/main/Conversational AI/Conversational AI/faiss_index/index.pkl"

    %% Service Layer
    subgraph "Service Layer"
        DataLoader["Data Loader Service"]:::service
        VectorService["Vector Store Service"]:::service
        RAGUtils["RAG Utilities"]:::service
        AgentController["Agent Controller"]:::service
    end
    click DataLoader "https://github.com/swethaguru-snsihub/agenticai_workshop/blob/main/Conversational AI/Conversational AI/services/stores.py"
    click VectorService "https://github.com/swethaguru-snsihub/agenticai_workshop/blob/main/Conversational AI/Conversational AI/services/vector_store_service.py"
    click RAGUtils "https://github.com/swethaguru-snsihub/agenticai_workshop/blob/main/Conversational AI/Conversational AI/services/rag_utils.py"
    click AgentController "https://github.com/swethaguru-snsihub/agenticai_workshop/blob/main/Conversational AI/Conversational AI/services/langgraph_agent.py"

    %% Model Layer
    subgraph "Model Layer"
        LLMWrapper["LLM Wrapper"]:::model
    end
    click LLMWrapper "https://github.com/swethaguru-snsihub/agenticai_workshop/blob/main/Conversational AI/Conversational AI/models/gemini_model.py"

    %% Config/Docs
    Config["requirements.txt"]:::config
    Doc["README.md"]:::config
    click Config "https://github.com/swethaguru-snsihub/agenticai_workshop/blob/main/Conversational AI/Conversational AI/requirements.txt"
    click Doc "https://github.com/swethaguru-snsihub/agenticai_workshop/blob/main/Conversational AI/Conversational AI/README.md"

    %% Indexing Flow
    JSON1 -->|load JSON| DataLoader
    JSON2 -->|load JSON| DataLoader
    DataLoader -->|create embeddings| VectorService
    VectorService -->|persist index| INDEX_FAISS
    VectorService -->|persist metadata| INDEX_PKL

    %% Query Flow
    UI -->|user query| AgentController
    AgentController -->|retrieve docs| VectorService
    VectorService -->|top-k docs| RAGUtils
    RAGUtils -->|assemble prompt| LLMWrapper
    LLMWrapper -->|generate answer| AgentController
    AgentController -->|return answer| UI

    %% Styles
    classDef data fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef service fill:#d4edda,stroke:#333,stroke-width:1px
    classDef model fill:#ffe5b4,stroke:#333,stroke-width:1px
    classDef ui fill:#d6d0fb,stroke:#333,stroke-width:1px
    classDef config fill:#f0e68c,stroke:#333,stroke-width:1px
```
