# khanhthanhdev/rag-application architecture

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

- Interactive diagram: https://gitdiagram.com/khanhthanhdev/rag-application
- Repository: https://github.com/khanhthanhdev/rag-application

## Overview

##### Main Components

a) Frontend Layer:
- Admin UI (port 8000/admin)
- Chat UI (port 8000)
- Management UI (for multiple RAGapps deployment)

b) Backend Services:
- RAGapp Core Service
- Manager Service (for orchestrating multiple RAGapps)
- Authentication Service (Keycloak integration)

c) External Integrations:
- AI Model Providers (OpenAI, Gemini, Ollama)
- Vector Databases (Qdrant, Chroma)
- API Gateway/Traefik (for routing and security)

##### Specific Components to Detail

Backend Structure:
**Controllers -> Services -> Engine -> VectorDBs**
- > Workflows
- > Models

Frontend Structure:
**UI Components -> Client APIs -> Backend Routes**

**[Client Layer]**
- ↓
**[API Gateway/Security Layer]**
- ↓
**[Application Layer]**
- ↓
**[Services Layer]**
- ↓
**[Storage Layer]**

##### Key Relationships to Highlight

- How the Manager service orchestrates multiple RAGapp instances
- Interaction between RAGapp and various AI providers
- Demonstrate the security flow through the API Gateway
- Vector database integration points

##### Important Technical Details

- Port mappings (8000)
- Docker container boundaries
- Configuration points (YAML files)
- API endpoints (/admin, /docs, /)

##### Deployment Variations

Two deployment scenarios:
##### Multiple RAGapps with management UI

This system design should emphasize the enterprise-ready nature of the application while showing its flexibility in supporting different AI models and deployment scenarios.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#E1F5FE,stroke:#01579B
    classDef backend fill:#E8F5E9,stroke:#1B5E20
    classDef auth fill:#EDE7F6,stroke:#4527A0
    classDef ai fill:#FFF3E0,stroke:#E65100
    classDef storage fill:#FFEBEE,stroke:#B71C1C
    classDef infra fill:#ECEFF1,stroke:#263238
    
    %% Client Layer
    subgraph ClientLayer["Client Layer"]
        AdminUI["Admin UI (8000/admin)"]:::frontend
        ChatUI["Chat UI (8000)"]:::frontend
        ManageUI["Management UI"]:::frontend
    end

    %% API Gateway Layer
    subgraph GatewayLayer["API Gateway Layer"]
        Traefik["API Gateway/Traefik"]:::infra
        Keycloak["Authentication Service"]:::auth
    end

    %% Application Layer
    subgraph AppLayer["Application Layer"]
        Manager["Manager Service"]:::backend
        RAGCore["RAGapp Core Service"]:::backend
    end

    %% Services Layer
    subgraph ServicesLayer["Services Layer"]
        Controllers["Controllers"]:::backend
        Services["Services"]:::backend
        Engine["Engine"]:::backend
        Workflows["Workflows"]:::backend
        Models["Models"]:::backend
    end

    %% External Services
    subgraph ExternalLayer["External Services"]
        AIProviders["AI Model Providers<br>(OpenAI/Gemini/Ollama)"]:::ai
        VectorDB["Vector Databases<br>(Qdrant/Chroma)"]:::storage
    end

    %% Relationships
    AdminUI --> Traefik
    ChatUI --> Traefik
    ManageUI --> Traefik
    
    Traefik --> Keycloak
    Traefik --> Manager
    Traefik --> RAGCore
    
    Manager --> RAGCore
    
    RAGCore --> Controllers
    Controllers --> Services
    Services --> Engine
    Services --> Workflows
    Services --> Models
    
    Engine --> AIProviders
    Engine --> VectorDB

    %% Click Events
    click AdminUI "https://github.com/khanhthanhdev/rag-application/tree/main/src/ragapp/admin-ui/"
    click ChatUI "https://github.com/khanhthanhdev/rag-application/tree/main/src/ragapp/patch/frontend/app/chat/"
    click ManageUI "https://github.com/khanhthanhdev/rag-application/tree/main/src/manager/frontend/"
    click RAGCore "https://github.com/khanhthanhdev/rag-application/tree/main/src/ragapp/backend/"
    click Manager "https://github.com/khanhthanhdev/rag-application/tree/main/src/manager/app/"
    click Keycloak "https://github.com/khanhthanhdev/rag-application/tree/main/deployments/multiple-ragapps/data/keycloak/"
    click AIProviders "https://github.com/khanhthanhdev/rag-application/tree/main/src/ragapp/admin-ui/client/providers/"
    click VectorDB "https://github.com/khanhthanhdev/rag-application/tree/main/src/ragapp/backend/engine/vectordbs/"
    click Traefik "https://github.com/khanhthanhdev/rag-application/tree/main/deployments/multiple-ragapps/data/traefik/"
    click Controllers "https://github.com/khanhthanhdev/rag-application/tree/main/src/ragapp/backend/controllers/"
    click Engine "https://github.com/khanhthanhdev/rag-application/tree/main/src/ragapp/backend/engine/"
    click Workflows "https://github.com/khanhthanhdev/rag-application/tree/main/src/ragapp/backend/workflows/"
    click Models "https://github.com/khanhthanhdev/rag-application/tree/main/src/ragapp/backend/models/"
    click Services "https://github.com/khanhthanhdev/rag-application/tree/main/src/ragapp/backend/services/"
```
