# dheerajgopi/rag-llmsmith-fastapi architecture

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

- Interactive diagram: https://gitdiagram.com/dheerajgopi/rag-llmsmith-fastapi
- Repository: https://github.com/dheerajgopi/rag-llmsmith-fastapi

## Overview

##### Main Components

a) External Components:
- Qdrant Vector Database (for storing embeddings)
- LLM Service (implied by LLMSmith usage)
- Client Applications (making API requests)

b) Internal Components:
- FastAPI Application Server
- Chat Module
- Configuration System
- Data Ingestion System

##### Client Layer
- HTTP Clients
- REST API Endpoints (/api/chat)

##### Application Layer
- FastAPI Server (main.py)
- Chat Module:
- API Controller (chat/api.py)
- Service Layer (chat/service.py)
- Models (chat/model.py)

##### Infrastructure Layer
- Qdrant Vector DB
- LLM Service
- Configuration (config/settings.py)
- Logging (core/log.py)

##### Flow Representation

Two main flows:
##### Data Ingestion Flow
- insert-sample-data.py → Embedding Service → Qdrant DB

##### Chat Flow
- Client → FastAPI → Chat Service → Vector DB (retrieval)
- Chat Service → LLM (generation)
- Chat Service → Client (response)

##### Key Relationships to Highlight

- The FastAPI application's dependency on configuration and environment variables
- The Chat module's interaction with both Qdrant and LLM services
- The separation between API handling and business logic in the chat module

##### Additional Details

Annotations for:
- Environment configuration (.env)
- Development tools (requirements.txt, pyproject.toml)
- Sample data flow (test-data directory)

##### Technical Details to Note

- FastAPI framework for REST API
- LLMSmith for LLM integration
- Qdrant for vector storage
- Python-based implementation
- Environment-based configuration

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef client fill:#A8E6CF
    classDef api fill:#3498DB,color:white
    classDef service fill:#85C1E9
    classDef database fill:#27AE60,color:white
    classDef external fill:#F1C40F
    classDef config fill:#E74C3C,color:white
    classDef core fill:#9B59B6,color:white

    %% Client Layer
    Client[Client Applications]:::client

    %% API Layer
    subgraph API
        FastAPI[FastAPI Server]:::api
        ChatAPI[Chat API Controller]:::api
    end

    %% Application Layer
    subgraph Application
        ChatService[Chat Service]:::service
        ChatModels[Chat Models]:::service
    end

    %% Infrastructure Layer
    subgraph Infrastructure
        Config[Configuration System]:::config
        Logging[Logging System]:::core
        DataIngestion[Data Ingestion System]:::service
        SampleData[Sample Data Storage]:::service
    end

    %% External Services
    subgraph External
        Qdrant[(Qdrant Vector DB)]:::database
        LLM[LLM Service]:::external
    end

    %% Development Components
    subgraph Development
        EnvConfig[Environment Config]:::config
        Dependencies[Dependencies]:::config
        DevDependencies[Dev Dependencies]:::config
        ProjectConfig[Project Config]:::config
    end

    %% Relationships
    Client --> FastAPI
    FastAPI --> ChatAPI
    ChatAPI --> ChatService
    ChatService --> ChatModels
    ChatService --> Qdrant
    ChatService --> LLM
    DataIngestion --> Qdrant
    DataIngestion --> SampleData

    %% Configuration Dependencies
    Config --> FastAPI
    Config --> ChatService
    Logging --> FastAPI
    Logging --> ChatService

    %% Click Events
    click FastAPI "https://github.com/dheerajgopi/rag-llmsmith-fastapi/blob/main/rag_llmsmith_fastapi/main.py"
    click ChatAPI "https://github.com/dheerajgopi/rag-llmsmith-fastapi/blob/main/rag_llmsmith_fastapi/chat/api.py"
    click ChatService "https://github.com/dheerajgopi/rag-llmsmith-fastapi/blob/main/rag_llmsmith_fastapi/chat/service.py"
    click ChatModels "https://github.com/dheerajgopi/rag-llmsmith-fastapi/blob/main/rag_llmsmith_fastapi/chat/model.py"
    click Config "https://github.com/dheerajgopi/rag-llmsmith-fastapi/blob/main/rag_llmsmith_fastapi/config/settings.py"
    click Logging "https://github.com/dheerajgopi/rag-llmsmith-fastapi/blob/main/rag_llmsmith_fastapi/core/log.py"
    click DataIngestion "https://github.com/dheerajgopi/rag-llmsmith-fastapi/blob/main/insert-sample-data.py"
    click SampleData "https://github.com/dheerajgopi/rag-llmsmith-fastapi/blob/main/test-data/stanford-dataset-dev-v2.0.json"
    click EnvConfig "https://github.com/dheerajgopi/rag-llmsmith-fastapi/blob/main/.env.template"
    click Dependencies "https://github.com/dheerajgopi/rag-llmsmith-fastapi/blob/main/requirements.txt"
    click DevDependencies "https://github.com/dheerajgopi/rag-llmsmith-fastapi/blob/main/requirements-dev.txt"
    click ProjectConfig "https://github.com/dheerajgopi/rag-llmsmith-fastapi/blob/main/pyproject.toml"
```
