# av/harbor architecture

> Architecture diagram of the GitHub repository av/harbor, 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/av/harbor
- Repository: https://github.com/av/harbor

## Overview

##### Main Components Overview

a) User Interface Layer
- Harbor CLI (primary interface)
- Harbor App (companion GUI application)
- Web-based UIs (Open WebUI, ComfyUI, LibreChat, etc.)

b) Service Management Layer
- Docker Compose Orchestration
- Configuration Management
- Profile Management
- Cache Management

- Frontend Services (Blue)
- Backend Services (Green)
- Satellite Services (Orange)
- Utility Services (Purple)

##### Core Architectural Elements

a) Harbor Core Components:
**┌─ Harbor CLI ─────────────────┐**
- Service Management        │
- Configuration Management  │
- Cache Management         │
- Profile Management       │
- ┘

**┌─ Harbor App ────────────────┐**
- GUI Interface            │
- Service Control Panel    │
- Configuration Editor     │
- ┘

b) Service Architecture:
**┌─ Frontend Services ──┐    ┌─ Backend Services ──┐    ┌─ Satellite Services ┐**
- Open WebUI        │━━━▶│ - Ollama           │◀━━━│ - Harbor Bench     │
- ComfyUI          │    │ - llama.cpp        │    │ - Harbor Boost     │
- LibreChat        │    │ - vLLM            │    │ - SearXNG          │
- ┘    └───────────────────────┘    └───────────────────┘

##### Key Interactions to Highlight

a) Configuration Flow:
**User Input ──▶ Harbor CLI/App ──▶ Docker Compose ──▶ Service Configuration**
- ▲                    │
- ┘
- Configuration Feedback

b) Cache Sharing:
**┌─ Shared Cache ────────────┐**
- HuggingFace Models    │
- Ollama Models         │
- Service Data          │
- ┘
- ▲    ▲    ▲

- Service1 Service2 Service3

##### Integration Points

Connections between services with different line styles:

##### Special Features to Highlight

a) Service Management:
**┌─ Harbor Management ─────┐**
- Service Start/Stop   │
- Health Monitoring    │
- Log Management      │
- Configuration       │
- ┘

b) Profile System:
**┌─ Profile Management ────┐**
- Profile Selection    │
- Config Templates     │
- Environment Vars     │
- ┘

##### Implementation Details

Technical details such as:
- Docker container relationships
- Network configuration
- Volume mounts
- Environment variable flow

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interface Layer"
        CLI["Harbor CLI"]
        APP["Harbor App"]
        click CLI "https://github.com/av/harbor/blob/main/harbor.sh"
        click APP "https://github.com/av/harbor/tree/main/app/src/"
        
        subgraph "Web UIs"
            WEBUI["Open WebUI"]
            COMFY["ComfyUI"]
            LIBRE["LibreChat"]
            click WEBUI "https://github.com/av/harbor/tree/main/open-webui/"
            click COMFY "https://github.com/av/harbor/tree/main/comfyui/"
            click LIBRE "https://github.com/av/harbor/tree/main/librechat/"
        end
    end

    subgraph "Service Management Layer"
        DOCKER["Docker Compose"]
        CONFIG["Configuration Management"]
        PROFILE["Profile Management"]
        CACHE["Cache Management"]
        click DOCKER "https://github.com/av/harbor/blob/main/compose.yml"
        click CONFIG "https://github.com/av/harbor/tree/main/app/src/config/"
        click PROFILE "https://github.com/av/harbor/tree/main/profiles/"
    end

    subgraph "Service Categories"
        subgraph "Backend Services"
            OLLAMA["Ollama"]
            LLAMA["llama.cpp"]
            VLLM["vLLM"]
            TABBY["TabbyAPI"]
            click OLLAMA "https://github.com/av/harbor/tree/main/ollama/"
            click LLAMA "https://github.com/av/harbor/tree/main/llamacpp/"
            click VLLM "https://github.com/av/harbor/tree/main/vllm/"
            click TABBY "https://github.com/av/harbor/tree/main/tabbyapi/"
        end

        subgraph "Satellite Services"
            BENCH["Harbor Bench"]
            BOOST["Harbor Boost"]
            SEARX["SearXNG"]
            click BENCH "https://github.com/av/harbor/tree/main/bench/"
            click BOOST "https://github.com/av/harbor/tree/main/boost/"
            click SEARX "https://github.com/av/harbor/tree/main/searxng/"
        end
    end

    subgraph "App Components"
        APPMAIN["Main App"]
        SERVMGMT["Service Management"]
        CONFED["Configuration Editor"]
        PROFMGMT["Profile Management"]
        click APPMAIN "https://github.com/av/harbor/blob/main/app/src/App.tsx"
        click SERVMGMT "https://github.com/av/harbor/blob/main/app/src/home/ServiceList.tsx"
        click CONFED "https://github.com/av/harbor/blob/main/app/src/config/HarborConfigEditor.tsx"
        click PROFMGMT "https://github.com/av/harbor/blob/main/app/src/settings/ProfileSelector.tsx"
    end

    %% Connections
    CLI --> DOCKER
    APP --> DOCKER
    DOCKER --> CONFIG
    DOCKER --> PROFILE
    DOCKER --> CACHE

    %% Web UI connections
    WEBUI --> OLLAMA
    COMFY --> OLLAMA
    LIBRE --> OLLAMA

    %% Backend service connections
    OLLAMA --> CACHE
    LLAMA --> CACHE
    VLLM --> CACHE
    TABBY --> CACHE

    %% Satellite service connections
    BENCH -.-> OLLAMA
    BOOST -.-> OLLAMA
    SEARX -.-> OLLAMA

    %% App component connections
    APP --> APPMAIN
    APPMAIN --> SERVMGMT
    APPMAIN --> CONFED
    APPMAIN --> PROFMGMT

    %% Styling
    classDef frontend fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:2px
    classDef satellite fill:#FFB347,stroke:#333,stroke-width:2px
    classDef management fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef app fill:#E6E6FA,stroke:#333,stroke-width:2px

    class WEBUI,COMFY,LIBRE frontend
    class OLLAMA,LLAMA,VLLM,TABBY backend
    class BENCH,BOOST,SEARX satellite
    class DOCKER,CONFIG,PROFILE,CACHE management
    class APPMAIN,SERVMGMT,CONFED,PROFMGMT app

    %% Legend
    subgraph Legend
        F["Frontend Services"]:::frontend
        B["Backend Services"]:::backend
        S["Satellite Services"]:::satellite
        M["Management Services"]:::management
        A["App Components"]:::app
    end
```
