# kazars24/large-language-sommelier architecture

> Architecture diagram of the GitHub repository kazars24/large-language-sommelier, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kazars24/large-language-sommelier
- Repository: https://github.com/kazars24/large-language-sommelier

## Overview

##### Main Components

a) Client Layer:
- Telegram Bot (from app.py)
- REST API Clients

b) API Layer:
- FastAPI Service (src/api/main.py)
- Recommendation Service (src/api/services.py)

c) Core Components:
- RAG Engine (src/retriever/)
- Model Management (src/utils/loaders.py)
- Configuration Management (src/core/config.py)

d) External Services:
- LLM Backends (Ollama, GigaChat)
- Embedding Model (multilingual-e5-small)

e) Validation Framework:
- Testing Framework (validation/core/)
- Metrics Collection (validation/core/metrics.py)
- Validation UI (validation/ui/app.py)

**[Client Layer]**
- ↓
**[API Layer]**
- ↓
**[Core Components]**
- ↓
**[External Services]**

##### Component Relationships

- Data flow between components
- Dependencies between modules
- API calls to external services

##### Detailed Component Breakdown

RAG Pipeline (central focus):
**[Document Splitter] → [Semantic Retriever] → [LLM Integration] → [Response Generation]**

##### Specific Elements

a) Configuration Flow:
**[Environment Variables] → [Config Module] → [Component Configuration]**

b) Model Management:
**[Model Loader] → [Model Server Selection] → [LLM Backend]**

##### Technical Details

- FastAPI endpoints
- Telegram Bot integration
- RAG component interaction
- Database connections (if any)
- External API connections

##### Validation Framework Integration

How the validation framework:
- Connects to the main system
- Collects metrics
- Provides feedback through the UI
- Integrates with Langfuse

- The retrieval augmentation process
- Multiple model backend support
- API and bot interfaces
- Validation and testing capabilities

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef external fill:#333,stroke:#333,color:white
    classDef internal fill:#0066cc,stroke:#0066cc,color:white
    classDef layer fill:none,stroke:none,color:black

    %% Client Layer
    subgraph CL["Client Layer"]
        TB["Telegram Bot"]:::external
        API["API Service"]:::external
    end

    %% Application Layer
    subgraph AL["Application Layer"]
        RAG["RAG Engine"]:::internal
        RS["Recommendation Service"]:::internal
        VF["Validation Framework"]:::internal

        subgraph RAGComponents["RAG Components"]
            SS["Semantic Splitter"]:::internal
            RT["Retriever"]:::internal
        end
    end

    %% Infrastructure Layer
    subgraph IL["Infrastructure Layer"]
        OL["Ollama"]:::external
        GC["GigaChat"]:::external
        LF["Langfuse"]:::external
    end

    %% Connections
    TB --> API
    API --> RAG
    RAG --> RAGComponents
    SS --> RT
    RAG --> RS
    RS --> VF
    VF --> OL
    VF --> GC
    VF -.-> LF

    %% Click Events
    click API "https://github.com/kazars24/large-language-sommelier/blob/main/src/api/main.py"
    click RAG "https://github.com/kazars24/large-language-sommelier/tree/main/src/retriever/"
    click SS "https://github.com/kazars24/large-language-sommelier/blob/main/src/retriever/semantic_splitter.py"
    click VF "https://github.com/kazars24/large-language-sommelier/tree/main/validation/"
    click OL "https://github.com/kazars24/large-language-sommelier/blob/main/validation/utils/ollama_api.py"

    %% Legend
    subgraph Legend
        E["External Service"]:::external
        I["Internal Component"]:::internal
    end
```
