# xxnuo/open-coreui architecture

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

- Interactive diagram: https://gitdiagram.com/xxnuo/open-coreui
- Repository: https://github.com/xxnuo/open-coreui

## Overview

##### Main Components
- Desktop Client (Tauri)
- Bundles: SvelteKit frontend + Rust backend in one native executable
- Uses Tauri’s IPC (Rust ↔ WebView)
- Web Client (Browser)
- SvelteKit application served by the backend server
- Communicates via HTTP REST and WebSockets
- Backend Server (Rust)
- HTTP/REST API + Socket.IO endpoints (chat)
- Middleware chain for auth, rate‐limiting, security headers, code execution, auditing
- Service layer (business logic)
- Retrieval/vector layer (Chroma vector store)
- Cache manager
- Static file serving (web assets)
- Data & External Services
- Local storage: SQLite or file system (per env)
- Vector database: Chroma (embedded)
- AI providers: OpenAI (via routes/openai)
- Tool runtimes / code interpreter sandbox

##### Relationships & Data Flows
- User → Desktop UI (Tauri WebView)
↕ IPC commands/Callbacks → Rust backend
- User → Browser UI
↔ HTTP REST / WebSockets → Rust backend
- Rust backend
→ invokes Service layer methods → Data layer (DB, vector store)
→ calls External AI APIs (OpenAI) or sandbox runtimes
- Cache & Retrieval
↔ Vector store (Chroma)
- Static assets
← Rust backend (serves SvelteKit build in CLI mode; bundled in Tauri mode)

##### Architectural Patterns
- Layered architecture: HTTP layer → Middleware → Service → Data/External
- Modular code organization (routes, services, models, middleware, utils)
- IPC channel for desktop mode vs HTTP API for server mode
- Embedded vector DB (Chroma) for retrieval‐augmented generation

##### Technologies & Frameworks
- Frontend: SvelteKit, Tailwind CSS, Vite
- Desktop wrapper: Tauri
- Backend: Rust (Axum or Warp HTTP server, Socket.IO adapter)
- Storage: SQLite or file‐based, Chroma vector store
- External: OpenAI API, code sandbox executor
- Build/Deploy: Dockerfiles, Makefile, GitHub Actions CI

- Clear component labels (e.g., “SvelteKit Frontend”, “Tauri IPC”, “Rust HTTP Server”)
- Notes on configuration (env files) and build (Docker/Tauri) as peripheral annotations

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Interfaces Layer
    subgraph "User Interfaces" 
        direction TB
        DApp["Desktop Client\n(Tauri)"]:::ui
        WApp["Web Client\n(SvelteKit)"]:::ui
    end

    %% Backend Layer
    subgraph "Backend Server (Rust)" 
        direction TB
        HTTPAPI["Rust HTTP Server\n(Axum/Warp)"]:::backend
        SocketIO["Socket.IO\n(WebSocket)"]:::backend

        subgraph "Middleware Chain"
            direction TB
            authMW["Auth Middleware"]:::backend
            rateLimitMW["RateLimit Middleware"]:::backend
            secHdrsMW["SecurityHeaders Middleware"]:::backend
            codeInterpMW["CodeInterpreter Middleware"]:::backend
            auditMW["Audit Middleware"]:::backend
            reqIDMW["RequestID Middleware"]:::backend
        end

        subgraph "Service Layer"
            direction TB
            AuthService["Auth Service"]:::backend
            ChatService["Chat Service"]:::backend
            RagService["RAG Service"]:::backend
            SandboxExecutorService["Sandbox Executor\nService"]:::backend
            StaticFilesService["Static Files Service"]:::backend
        end

        CacheManager["Cache Manager"]:::backend
    end

    %% Data & External Services Layer
    subgraph "Data & External Services"
        direction TB
        SQLite["SQLite / File Storage"]:::data
        Chroma["Chroma Vector Store"]:::data
        OpenAI["OpenAI API"]:::external
        SandboxRuntime["Sandbox Runtime"]:::external
    end

    %% Connections
    DApp -->|"IPC commands / callbacks"| HTTPAPI
    WApp -->|"HTTP REST / WebSocket"| HTTPAPI
    HTTPAPI -->|requests| authMW
    authMW --> rateLimitMW
    rateLimitMW --> secHdrsMW
    secHdrsMW --> codeInterpMW
    codeInterpMW --> auditMW
    auditMW --> reqIDMW
    reqIDMW --> AuthService
    reqIDMW --> ChatService
    reqIDMW --> RagService
    reqIDMW --> SandboxExecutorService
    reqIDMW --> StaticFilesService

    AuthService --> SQLite
    ChatService --> SQLite
    ChatService --> Chroma
    RagService --> Chroma
    RagService --> OpenAI
    SandboxExecutorService --> SandboxRuntime
    StaticFilesService --> WApp

    CacheManager --> Chroma
    RagService <-->|caches embeddings| CacheManager

    SocketIO -->|"emit 'message' event"| ChatService
    ChatService --> SocketIO

    %% Click Events
    click DApp "https://github.com/xxnuo/open-coreui/blob/main/src-tauri/src/main.rs"
    click DApp "https://github.com/xxnuo/open-coreui/blob/main/src-tauri/src/lib.rs"
    click DApp "https://github.com/xxnuo/open-coreui/blob/main/src-tauri/tauri.conf.json"
    click DApp "https://github.com/xxnuo/open-coreui/blob/main/src-tauri/static/index.html"
    click WApp "https://github.com/xxnuo/open-coreui/tree/main/frontend/src/routes/"
    click WApp "https://github.com/xxnuo/open-coreui/tree/main/frontend/src/lib/components/"
    click WApp "https://github.com/xxnuo/open-coreui/tree/main/frontend/src/lib/apis/"
    click WApp "https://github.com/xxnuo/open-coreui/blob/main/frontend/package.json"
    click HTTPAPI "https://github.com/xxnuo/open-coreui/blob/main/backend/src/main.rs"
    click HTTPAPI "https://github.com/xxnuo/open-coreui/blob/main/backend/Cargo.toml"
    click HTTPAPI "https://github.com/xxnuo/open-coreui/tree/main/backend/Dockerfile"
    click authMW "https://github.com/xxnuo/open-coreui/blob/main/backend/src/middleware/auth.rs"
    click rateLimitMW "https://github.com/xxnuo/open-coreui/blob/main/backend/src/middleware/rate_limit.rs"
    click secHdrsMW "https://github.com/xxnuo/open-coreui/blob/main/backend/src/middleware/security_headers.rs"
    click codeInterpMW "https://github.com/xxnuo/open-coreui/blob/main/backend/src/middleware/code_interpreter.rs"
    click auditMW "https://github.com/xxnuo/open-coreui/blob/main/backend/src/middleware/audit.rs"
    click reqIDMW "https://github.com/xxnuo/open-coreui/blob/main/backend/src/middleware/request_id.rs"
    click AuthService "https://github.com/xxnuo/open-coreui/blob/main/backend/src/services/auth.rs"
    click ChatService "https://github.com/xxnuo/open-coreui/blob/main/backend/src/services/chat.rs"
    click RagService "https://github.com/xxnuo/open-coreui/blob/main/backend/src/services/rag.rs"
    click SandboxExecutorService "https://github.com/xxnuo/open-coreui/blob/main/backend/src/services/sandbox_executor.rs"
    click StaticFilesService "https://github.com/xxnuo/open-coreui/blob/main/backend/src/services/static_files.rs"
    click CacheManager "https://github.com/xxnuo/open-coreui/blob/main/backend/src/cache_manager.rs"
    click SQLite "https://github.com/xxnuo/open-coreui/blob/main/backend/src/db.rs"
    click SQLite "https://github.com/xxnuo/open-coreui/blob/main/backend/src/schema.sql"
    click Chroma "https://github.com/xxnuo/open-coreui/blob/main/backend/src/retrieval/chunking.rs"
    click Chroma "https://github.com/xxnuo/open-coreui/blob/main/backend/src/retrieval/embeddings.rs"
    click Chroma "https://github.com/xxnuo/open-coreui/blob/main/backend/src/retrieval/vector/chroma.rs"
    click Chroma "https://github.com/xxnuo/open-coreui/blob/main/backend/src/retrieval/vector/factory.rs"
    click OpenAI "https://github.com/xxnuo/open-coreui/blob/main/backend/src/routes/openai.rs"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef backend fill:#d4edda,stroke:#333,stroke-width:1px
    classDef data fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef external fill:#ffe5b4,stroke:#333,stroke-width:1px
```
