# xomyhoc/open-webui architecture

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

- Interactive diagram: https://gitdiagram.com/xomyhoc/open-webui
- Repository: https://github.com/xomyhoc/open-webui

## Overview

##### Project type and purpose
- This is a full-stack monolithic application (“Open WebUI”) combining a SvelteKit-based PWA frontend with a Python backend.
- Purpose: provide a self-hosted AI chat platform with Retrieval-Augmented Generation (RAG), plugin support, voice/video calls, image generation, RBAC, multi-model orchestration, and offline operation.

##### File structure
- Top-level:
- backend/ – Python service (FastAPI style) with routers, models (SQLAlchemy), migrations (Alembic), retrieval modules (vector stores & web scrapers), tasks, utils, storage provider.
- src/ – SvelteKit frontend (routes/, lib/components, lib/apis, stores, workers).
- cypress/ & test/ – end-to-end and unit tests.
- Dockerfile, docker-compose.yaml, kubernetes/ – containerization & K8s deployment.
- config: env files, Caddyfile, Makefile, hatch_build.py, pyproject.toml, package.json, Vite/Svelte/Tailwind configs.

##### README for additional insights
- It confirms a Docker/Kubernetes deploy, Python 3.11 backend (`open-webui serve` CLI), Ollama/OpenAI runners, vector DB for RAG, plugin & pipeline architecture, PWA offline support, RBAC, i18n.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Agent
    subgraph "User Agent"
        Browser["Browser (PWA)"]:::client
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        FEApp["SvelteKit App"]:::frontend
        SSR["API Gateway / SSR Endpoints"]:::frontend
    end

    %% Backend Service
    subgraph "Backend Service"
        Routers["FastAPI HTTP Routers"]:::backend
        WSGateway["WebSocket Gateway"]:::backend
        TaskQueue["Task Queue & Workers"]:::worker
        PluginEngine["Plugin/Pipeline Engine"]:::backend
    end

    %% Data Stores
    subgraph "Data Services"
        SQLDB["Relational DB (SQLAlchemy)"]:::datastore
        VectorDB["Vector Store Connectors"]:::datastore
        FileStore["File Storage (FS/S3)"]:::datastore
        Redis["Redis Cache/Locks"]:::datastore
    end

    %% External AI Services
    subgraph "External AI Services"
        Ollama["Ollama LLM Server"]:::external
        OpenAI["OpenAI APIs"]:::external
        WebSearch["Web Search Providers"]:::external
    end

    %% Infrastructure
    subgraph "Infrastructure"
        Docker["Docker / Compose"]:::infra
        K8s["Kubernetes"]:::infra
        Caddy["Ingress (Caddy)"]:::infra
    end

    %% Connections
    Browser -->|HTTP/WS| SSR
    SSR -->|"HTTP API"| Routers
    SSR -->|"WS Upgrade"| WSGateway
    Routers -->|"CRUD"| SQLDB
    Routers -->|"Index/Search"| VectorDB
    Routers -->|"Upload/Download"| FileStore
    Routers -->|"Dispatch Tasks"| TaskQueue
    Routers -->|"Invoke"| PluginEngine
    WSGateway -->|"Real-Time"| Routers
    TaskQueue -->|"Run Jobs"| TaskQueue
    TaskQueue -->|"LLM/Image Gen"| Ollama
    TaskQueue -->|"LLM/Image Gen"| OpenAI
    Routers -->|"Auth/RBAC"| Redis
    PluginEngine -->|"Search/Fetch"| VectorDB
    PluginEngine -->|"HTTP Calls"| WebSearch

    %% Infrastructure Connections
    SSR --> Docker
    Routers --> Docker
    TaskQueue --> Docker
    Docker --> K8s
    K8s --> Caddy
    Caddy --> SSR
    Caddy --> Routers

    %% Click Events
    click FEApp "https://github.com/xomyhoc/open-webui/tree/main/src/"
    click SSR "https://github.com/xomyhoc/open-webui/tree/main/src/routes/"
    click Routers "https://github.com/xomyhoc/open-webui/tree/main/backend/open_webui/routers/"
    click WSGateway "https://github.com/xomyhoc/open-webui/tree/main/backend/open_webui/socket/"
    click TaskQueue "https://github.com/xomyhoc/open-webui/blob/main/backend/open_webui/tasks.py"
    click SQLDB "https://github.com/xomyhoc/open-webui/tree/main/backend/open_webui/models/"
    click VectorDB "https://github.com/xomyhoc/open-webui/tree/main/backend/open_webui/retrieval/vector/dbs/"
    click FileStore "https://github.com/xomyhoc/open-webui/blob/main/backend/open_webui/storage/provider.py"
    click PluginEngine "https://github.com/xomyhoc/open-webui/blob/main/backend/open_webui/functions.py"
    click PluginEngine "https://github.com/xomyhoc/open-webui/blob/main/backend/open_webui/routers/pipelines.py"
    click PluginEngine "https://github.com/xomyhoc/open-webui/blob/main/backend/open_webui/utils/plugin.py"
    click Ollama "https://github.com/xomyhoc/open-webui/blob/main/backend/open_webui/routers/ollama.py"
    click OpenAI "https://github.com/xomyhoc/open-webui/blob/main/backend/open_webui/routers/openai.py"
    click Ollama "https://github.com/xomyhoc/open-webui/blob/main/backend/open_webui/config.py"
    click Docker "https://github.com/xomyhoc/open-webui/tree/main/Dockerfile"
    click Docker "https://github.com/xomyhoc/open-webui/blob/main/docker-compose.yaml"
    click K8s "https://github.com/xomyhoc/open-webui/tree/main/kubernetes/"

    %% Styles
    classDef client fill:#CCF,stroke:#333,stroke-width:1px
    classDef frontend fill:#CFF,stroke:#333,stroke-width:1px
    classDef backend fill:#FCF,stroke:#333,stroke-width:1px
    classDef datastore fill:#FFC,stroke:#333,stroke-width:1px
    classDef external fill:#CFC,stroke:#333,stroke-width:1px
    classDef infra fill:#FCC,stroke:#333,stroke-width:1px
    classDef worker fill:#FC8,stroke:#333,stroke-width:1px
```
