# loft-sh/devpod architecture

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

- Interactive diagram: https://gitdiagram.com/loft-sh/devpod
- Repository: https://github.com/loft-sh/devpod

## Overview

##### Main Components

a. Client Layer:
- Desktop Application (Tauri-based)
- CLI Interface
- IDE Integrations (VSCode, JetBrains Suite)

b. Core Components:
- Workspace Manager
- Provider Manager
- Configuration Manager
- Tunnel Manager
- Credential Sync System

c. Provider Layer:
- Docker Provider
- Kubernetes Provider
- Cloud VM Providers
- Custom Providers

##### Key Relationships to Highlight

a. Control Flow:
- User Interface → Core Components
- Core Components → Provider Layer
- Provider Layer → Development Environments

b. Data Flow:
- Configuration Files ↔ Configuration Manager
- Credentials ↔ Credential Sync System
- Container Specs ↔ Workspace Manager

##### Architectural Patterns

- Plugin Architecture (for providers)
- Event-driven Architecture (for workspace status updates)
- Client-only Architecture (no server component)

**┌─ DevPod Client Layer ─────────────────────┐**
- ┌─────────┐ ┌──────────┐ ┌──────────────┐ │
- Desktop  │ │CLI       │ │IDE           │ │
- App      │ │Interface │ │Integrations  │ │
- ┘ └──────────┘ └──────────────┘ │
- ┬───────────────────────┘
- ↓
**┌─ Core Services Layer ──────────────────────┐**
- ┌─────────┐ ┌──────────┐ ┌──────────────┐ │
- Workspace│ │Provider  │ │Configuration │ │
- Manager  │ │Manager   │ │Manager       │ │
- ┘ └──────────┘ └──────────────┘ │
- ┌─────────┐ ┌──────────┐                  │
- Tunnel   │ │Credential│                  │
- Manager  │ │Sync      │                  │
- ┘ └──────────┘                  │
- ┬───────────────────────┘
- ↓
**┌─ Provider Layer ───────────────────────────┐**
- ┌─────────┐ ┌──────────┐ ┌──────────────┐ │
- Docker   │ │Kubernetes│ │Cloud VM      │ │
- Provider │ │Provider  │ │Providers     │ │
- ┘ └──────────┘ └──────────────┘ │
- ┬───────────────────────┘
- ↓
**┌─ Development Environments ─────────────────┐**
- ┌─────────┐ ┌──────────┐ ┌──────────────┐ │
- Local    │ │Remote    │ │Cloud         │ │
- Container│ │Machine   │ │Instance      │ │
- ┘ └──────────┘ └──────────────┘ │
- ┘

##### Additional Elements

Annotations for:
- DevContainer.json flow
- Credential synchronization paths
- Auto-shutdown mechanisms
- Prebuild pipeline
- SSH tunneling

##### Important Details

- Client-only nature of the tool
- Provider extensibility
- IDE integration points
- Container standardization
- Resource management flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style definitions
    classDef client fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef provider fill:#e67e22,stroke:#d35400,color:white
    classDef environment fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Client Layer
    subgraph ClientLayer["Client Layer"]
        Desktop["Desktop App"]
        CLI["CLI Interface"]
        IDE["IDE Integrations"]
    end

    %% Core Services Layer
    subgraph CoreLayer["Core Services Layer"]
        WM["Workspace Manager"]
        PM["Provider Manager"]
        CM["Configuration Manager"]
        TM["Tunnel Manager"]
        CS["Credential Sync"]
        
        subgraph CoreServices["Core Services"]
            BS["Build System"]
            SSH["SSH Management"]
            ContainerMgmt["Container Management"]
        end
    end

    %% Provider Layer
    subgraph ProviderLayer["Provider Layer"]
        Docker["Docker Provider"]
        K8s["Kubernetes Provider"]
        Cloud["Cloud VM Providers"]
        Custom["Custom Providers"]
    end

    %% Development Environments
    subgraph EnvLayer["Development Environments"]
        Local["Local Container"]
        Remote["Remote Machine"]
        CloudInst["Cloud Instance"]
    end

    %% Relationships
    Desktop --> WM
    CLI --> WM
    IDE --> WM
    
    WM --> PM
    PM --> Docker
    PM --> K8s
    PM --> Cloud
    PM --> Custom
    
    Docker --> Local
    K8s --> Remote
    Cloud --> CloudInst
    Custom --> Remote

    %% Apply styles
    class Desktop,CLI,IDE client
    class WM,PM,CM,TM,CS,BS,SSH,ContainerMgmt core
    class Docker,K8s,Cloud,Custom provider
    class Local,Remote,CloudInst environment

    %% Click events
    click Desktop "https://github.com/loft-sh/devpod/tree/main/desktop/src-tauri"
    click CLI "https://github.com/loft-sh/devpod/tree/main/cmd"
    click IDE "https://github.com/loft-sh/devpod/tree/main/pkg/ide"
    click WM "https://github.com/loft-sh/devpod/tree/main/pkg/workspace"
    click PM "https://github.com/loft-sh/devpod/tree/main/pkg/provider"
    click CM "https://github.com/loft-sh/devpod/tree/main/pkg/config"
    click TM "https://github.com/loft-sh/devpod/tree/main/pkg/tunnel"
    click CS "https://github.com/loft-sh/devpod/tree/main/pkg/credentials"
    click BS "https://github.com/loft-sh/devpod/tree/main/pkg/devcontainer/build"
    click SSH "https://github.com/loft-sh/devpod/tree/main/pkg/ssh"
    click ContainerMgmt "https://github.com/loft-sh/devpod/tree/main/pkg/devcontainer"
    click Docker "https://github.com/loft-sh/devpod/tree/main/providers/docker"
    click K8s "https://github.com/loft-sh/devpod/tree/main/pkg/driver/docker"
    click Custom "https://github.com/loft-sh/devpod/tree/main/pkg/driver/custom"

    %% Legend
    subgraph Legend
        Client["Client Component"]:::client
        CoreComp["Core Component"]:::core
        ProviderComp["Provider Component"]:::provider
        EnvComp["Environment"]:::environment
    end
```
