# yonkosama/llmops_series-sunny-savita architecture

> Architecture diagram of the GitHub repository yonkosama/llmops_series-sunny-savita, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yonkosama/llmops_series-sunny-savita
- Repository: https://github.com/yonkosama/llmops_series-sunny-savita

## Overview

##### Project type and purpose
- From the README and file tree, this is a full-stack Retrieval-Augmented Generation (RAG) chat application built with FastAPI.
- Purpose: Let users upload documents, build per-session FAISS vector indexes, then chat with those documents via an LLM.

##### File structure
- Top-level scripts and config:
- main.py – FastAPI app entry point
- Dockerfile, docker-compose.jenkins.yml, Jenkinsfile.test – containerization & CI/CD
- .github/workflows – GitHub Actions for AWS deployment and CI
- Core application under `multi_doc_chat/`:
- config (config.yaml) & utils (config_loader, file_io, document_ops, model_loader)
- exception, logger modules
- model/models.py – data models (Pydantic, FAISS index metadata)
- prompts/prompt_library.py – prompt definitions
- src/document_ingestion – ingestion pipeline (file split, embedding, FAISS index creation)
- src/document_chat – retrieval and chat logic (load index, perform similarity search, call LLM)
- Frontend assets:
- templates/index.html
- static/styles.css
- Evaluations & notebooks:
- run_evaluations.py, notebook/*.ipynb – LangSmith evaluation harness
- Tests: unit and integration under `tests/`

##### README for additional insights
- Endpoints: `/upload`, `/chat`, `/health`, `/` (UI)
- Storage: `data/<session_id>/` for raw splits, `faiss_index/<session_id>/` for vector stores
- Session management: in-memory per-session chat history
- External dependencies: OpenAI (embeddings, chat) via ModelLoader, LangSmith/Google APIs for evaluation

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend
    subgraph "Frontend (Browser)"
        Index["Index Page"]:::frontend
        Styles["Stylesheet"]:::frontend
    end

    %% Backend
    subgraph "Backend (FastAPI)"
        API["API Layer\n/upload, /chat, /health, UI"]:::service
        Session["Session Manager\n(in-memory)"]:::service

        subgraph "Document Ingestion Service"
            Splitter["Splitter"]:::service
            Embedder["Embedder"]:::service
            Indexer["FAISS Indexer"]:::service
        end

        subgraph "Document Chat Service"
            Retriever["FAISS Retriever"]:::service
            ChatHandler["Chat Handler"]:::service
        end

        subgraph "Support & Config"
            ConfigYAML["config.yaml"]:::service
            ConfigLoader["Config Loader"]:::service
            FileIO["File I/O Utils"]:::service
            DocOps["Document Ops Utils"]:::service
            ModelLoader["Model Loader"]:::service
            DataModels["Data Models"]:::service
            Prompts["Prompt Library"]:::service
            Exception["Exception Handler"]:::service
            Logger["Logger"]:::service
        end
    end

    %% Persistence
    subgraph "Persistence"
        FileStore["File Storage\n(data/<session_id>/)"]:::storage
        VectorStore["Vector Store\n(faiss_index/<session_id>/)"]:::storage
    end

    %% External Services
    subgraph "External Services"
        EmbAPI["Embedding API"]:::external
        LLMAPI["LLM API"]:::external
        EvalAPI["LangSmith / Google APIs"]:::external
    end

    %% CI/CD
    subgraph "CI/CD & Deployment"
        Docker["Docker & Compose"]:::cicd
        GitHub["GitHub Actions"]:::cicd
        Jenkins["Jenkins Pipelines"]:::cicd
    end

    %% Evaluation Harness
    EvalScript["run_evaluations.py"]:::service
    Notebooks["Evaluation Notebooks"]:::service

    %% Connections - Frontend to Backend
    Index -->|HTTP Requests| API
    Styles -->|served as asset| API

    %% Upload Flow
    API -->|"upload"| Splitter
    Splitter -->|"chunks"| Embedder
    Embedder -->|"call embeddings"| EmbAPI
    EmbAPI -->|"embeddings"| Embedder
    Embedder -->|"vectors"| Indexer
    Indexer -->|"store splits"| FileStore
    Indexer -->|"store index"| VectorStore

    %% Chat Flow
    API -->|"chat"| Session
    API -->|"chat"| Retriever
    Retriever -->|"load index"| VectorStore
    Retriever -->|"similarity search"| Retriever
    Retriever -->|"query"| ChatHandler
    ChatHandler -->|"call LLM"| LLMAPI
    LLMAPI -->|"response"| ChatHandler
    ChatHandler -->|"update history"| Session
    ChatHandler -->|"reply"| API

    %% Evaluation Flow
    EvalScript -->|"invoke chat"| API
    EvalScript -->|"log"| EvalAPI
    Notebooks -->|"analysis"| EvalScript

    %% CI/CD Connections
    Docker -->|build/run| API
    GitHub -->|build & deploy| Docker
    Jenkins -->|test & build| Docker

    %% Support & Config dependencies
    API --> ConfigLoader
    API --> ConfigYAML
    API --> FileIO
    API --> DocOps
    API --> ModelLoader
    API --> DataModels
    API --> Prompts
    API --> Exception
    API --> Logger

    %% Click Events
    click Index "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/templates/index.html"
    click Styles "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/static/styles.css"
    click API "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/main.py"
    click Splitter "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/multi_doc_chat/src/document_ingestion/data_ingestion.py"
    click Retriever "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/multi_doc_chat/src/document_chat/retrieval.py"
    click ConfigYAML "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/multi_doc_chat/config/config.yaml"
    click ConfigLoader "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/multi_doc_chat/utils/config_loader.py"
    click FileIO "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/multi_doc_chat/utils/file_io.py"
    click DocOps "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/multi_doc_chat/utils/document_ops.py"
    click ModelLoader "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/multi_doc_chat/utils/model_loader.py"
    click DataModels "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/multi_doc_chat/model/models.py"
    click Prompts "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/multi_doc_chat/prompts/prompt_library.py"
    click Exception "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/multi_doc_chat/exception/custom_exception.py"
    click Logger "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/multi_doc_chat/logger/cutom_logger.py"
    click EvalScript "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/run_evaluations.py"
    click Notebooks "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/notebook/Evaluations.ipynb"
    click Notebooks "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/notebook/RAG.ipynb"
    click Notebooks "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/notebook/experiments.ipynb"
    click Docker "https://github.com/yonkosama/llmops_series-sunny-savita/tree/main/Dockerfile"
    click Docker "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/docker-compose.jenkins.yml"
    click Jenkins "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/Jenkinsfile.test"
    click GitHub "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/.github/workflows/aws.yml"
    click GitHub "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/.github/workflows/ci.yml"
    click GitHub "https://github.com/yonkosama/llmops_series-sunny-savita/blob/main/.github/workflows/task_defination.json"

    %% Styles
    classDef service fill:#ADD8E6,stroke:#000
    classDef storage fill:#90EE90,stroke:#000
    classDef external fill:#FFA500,stroke:#000
    classDef cicd fill:#DDA0DD,stroke:#000
    classDef frontend fill:#87CEFA,stroke:#000
```
