# volantvm/volant architecture

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

- Interactive diagram: https://gitdiagram.com/volantvm/volant
- Repository: https://github.com/volantvm/volant

## Overview

##### Project Type & Purpose
- Volant is a **microVM orchestration engine** written in Go.
- It comprises a **control plane** (`volantd`), a **CLI** (`volar` + helpers), an **in-guest agent/init** (`kestrel`), a **dataplane daemon** (`driftd`), and a **plugin builder** (`fledge`).
- It orchestrates real VM isolation (cloud hypervisor, VFIO, cloud-init), network (Linux bridge + eBPF), and plugin artifacts (initramfs/rootfs).

##### Top-Level Components
a. **volar (CLI)**
- Commands: `volar vms`, `volar plugins`, `volar deployments`.
- Uses the OpenAPI/REST API exposed by `volantd`.
- Contains sub-packages for standard CLI behavior and `openapi-export`.
b. **volantd (Control Plane)**
- REST & MCP APIs (OpenAPI spec in `internal/server/httpapi`).
- SQLite registry (`internal/server/db/sqlite`).
- IPAM (192.168.127.0/24).
- Orchestrator modules (`internal/server/orchestrator`): cloudhypervisor launcher, cloud-init builder, network bridge setup, runtime config, events.
- Device manager (VFIO).
- Event bus for internal pub/sub.
- Drift client (`internal/server/driftclient`) to communicate with dataplane daemon.
- Plugin registry & loader (`internal/server/plugins`).
c. **driftd (Dataplane Daemon)**
- Written in Go + C BPF code (`internal/drift/bpf`).
- Exposes an HTTP API (`internal/drift/httpapi`) for flow-level policy, filestore, memory tracking.
- Manages L4 load balancing, vsock proxy, etc.
d. **kestrel (In-Guest Agent / PID1)**
- Lives inside each microVM.
- Sets up the guest environment, proxies vsock to host dataplane, acts as `volant.boot` agent.
e. **fledge (Plugin Builder)**
- **Self-contained Docker drop-in replacement**.
- Uses the Go LLB (low-level build) library to convert OCI images or static binaries into bootable initramfs or rootfs **without** `dockerd`, `containerd`, or `runc`.
- Outputs signed plugin artifacts (kernels + initramfs/rootfs) ready for `volantd` to consume.

##### Data Stores & Artifacts
- **SQLite** for the control-plane registry.
- **Filesystem**:
- `/var/lib/volant/plugins` (artifacts uploaded).
- `kernel/bzImage` shipped with the repo.
- **Manifest Schema** (JSON/TOML) describing each plugin.

##### Interactions & Data Flow
1. **Plugin Build Path** (offline / CI):
- Developer runs **fledge** → pulls OCI image / binary → uses LLB engine → emits initramfs or rootfs + manifest → publishes to artifact store.
2. **Plugin Registration**:
- `volar plugins install --manifest <URL>` → calls `volantd API` → stores artifact metadata and blobs.
3. **VM Lifecycle**:
- `volar vms create` → calls `volantd` → orchestrator:
- Allocates IP from IPAM.
- Configures Linux bridge (`vbr0`).
- Launches Cloud Hypervisor with kernel/initramfs.
- Passes vsock and VFIO device configs.
- Cloud Hypervisor boots VM → `kestrel` runs as PID1.
- `kestrel` sets up cloud-init, mounts rootfs, starts workload.
- Workload vsock traffic proxied via `kestrel` to **driftd** on host → dataplane policies applied.
4. **Runtime Ops**:
- `volar` / external UI ↔ `volantd` API ↔ orchestrator.
- `volantd` ↔ `driftd` for network dataplane.
- Internally, `volantd` uses eventbus to trigger plugin hooks, metrics, cloud-init progress.

##### Architectural Patterns & Principles
- **Modularity**: separate binaries for CLI, control plane, agent, dataplane, builder.
- **Microservices-style**: control plane exposes HTTP API, dataplane daemon runs separately.
- **Layering**: CLI ←→ Control Plane ←→ Orchestrator + Dataplane ←→ Hypervisor ←→ Guest Agent.
- **Plugin-first**: all VM behaviors come from signed manifests/artifacts.
- **Bring-Your-Own-Container-Engine**: replaced by **fledge** using LLB.

##### Putting It All Together
1. Inside:
- **Linux bridge (vbr0)** connecting to VMs.
- **Cloud Hypervisor** instances spinning up microVMs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    classDef control fill:#D6E9FF,stroke:#333,stroke-width:1px
    classDef cli fill:#D5F5E3,stroke:#333,stroke-width:1px
    classDef builder fill:#D5F5E3,stroke:#333,stroke-width:1px
    classDef datapl fill:#FFE5B4,stroke:#333,stroke-width:1px
    classDef agent fill:#EEEEEE,stroke:#333,stroke-width:1px
    classDef database fill:#E3E4FA,stroke:#333,stroke-width:1px

    subgraph "Host Machine"
        direction TB
        volar["volar (CLI)"]:::cli
        volantd["volantd (Control Plane)"]:::control
        sqliteDB["SQLite Registry"]:::database
        linuxBridge["Linux Bridge\nvbr0"]:::control
        cloudHypervisor["Cloud Hypervisor"]:::control
        driftd["driftd (Dataplane Daemon)"]:::datapl

        volar -->|"HTTP/REST API"| volantd
        volantd -->|"Registers metadata"| sqliteDB
        volantd -->|"gRPC/MCP"| cloudHypervisor
        cloudHypervisor -->|"Attach to"| linuxBridge
        volantd -->|"HTTP API"| driftd

        subgraph "VMs"
            direction TB
            VM["MicroVM"]:::agent
            kestrel["kestrel (PID1)"]:::agent
            VM --> kestrel
            kestrel -->|"vsock"| driftd
        end

    end

    subgraph "Offline/CI Build"
        direction TB
        fledge["fledge (Plugin Builder)"]:::builder
        artifactStore["Artifact Store\n/var/lib/volant/plugins"]:::database
        fledge -->|"LLB build"| artifactStore
        artifactStore -->|"Artifacts metadata"| volantd
    end

    click volar "https://github.com/volantvm/volant/blob/main/cmd/volar/main.go"
    click internalCLI "https://github.com/volantvm/volant/tree/main/internal/cli"
    click cliClient "https://github.com/volantvm/volant/blob/main/internal/cli/client/client.go"
    click openapiutil "https://github.com/volantvm/volant/blob/main/internal/cli/openapiutil/openapi.go"
    click standardCLI "https://github.com/volantvm/volant/tree/main/internal/cli/standard/"
    click volantd "https://github.com/volantvm/volant/blob/main/cmd/volantd/main.go"
    click app "https://github.com/volantvm/volant/blob/main/internal/server/app/app.go"
    click config "https://github.com/volantvm/volant/blob/main/internal/server/config/config.go"
    click sqliteDB "https://github.com/volantvm/volant/tree/main/internal/server/db/sqlite"
    click types "https://github.com/volantvm/volant/blob/main/internal/server/db/types.go"
    click vfio "https://github.com/volantvm/volant/blob/main/internal/server/devicemanager/vfio_manager.go"
    click driftClient "https://github.com/volantvm/volant/blob/main/internal/server/driftclient/client.go"
    click eventbusDir "https://github.com/volantvm/volant/tree/main/internal/server/eventbus"
    click httpapiDir "https://github.com/volantvm/volant/tree/main/internal/server/httpapi"
    click orchestratorDir "https://github.com/volantvm/volant/tree/main/internal/server/orchestrator"
    click cloudLauncher "https://github.com/volantvm/volant/blob/main/internal/server/orchestrator/cloudhypervisor/launcher.go"
    click cloudInitBuilder "https://github.com/volantvm/volant/blob/main/internal/server/orchestrator/cloudinit/builder.go"
    click networkBridge "https://github.com/volantvm/volant/blob/main/internal/server/orchestrator/network/bridge.go"
    click networkDir "https://github.com/volantvm/volant/blob/main/internal/server/orchestrator/network/network.go"
    click runtimeConfig "https://github.com/volantvm/volant/blob/main/internal/server/orchestrator/runtime/runtime.go"
    click pluginsDir "https://github.com/volantvm/volant/tree/main/internal/server/plugins"
    click driftd "https://github.com/volantvm/volant/blob/main/cmd/driftd/main.go"
    click driftApp "https://github.com/volantvm/volant/blob/main/internal/drift/app/app.go"
    click bpfCode "https://github.com/volantvm/volant/blob/main/internal/drift/bpf/drift_l4.c"
    click driftHttpApi "https://github.com/volantvm/volant/blob/main/internal/drift/httpapi/httpapi.go"
    click driftRoutes "https://github.com/volantvm/volant/tree/main/internal/drift/routes"
    click dataplaneManager "https://github.com/volantvm/volant/blob/main/internal/drift/dataplane/manager_linux.go"
    click vsockProxy "https://github.com/volantvm/volant/blob/main/internal/drift/vsockproxy/manager_linux.go"
    click driftController "https://github.com/volantvm/volant/blob/main/internal/drift/controller/controller.go"
    click driftConfig "https://github.com/volantvm/volant/blob/main/internal/drift/config/config.go"
    click kestrel "https://github.com/volantvm/volant/blob/main/cmd/kestrel/main.go"
    click agentApp "https://github.com/volantvm/volant/blob/main/internal/agent/app/app.go"
    click pid1 "https://github.com/volantvm/volant/blob/main/internal/agent/app/pid1.go"
    click pid1Stub "https://github.com/volantvm/volant/blob/main/internal/agent/app/pid1_stub.go"
    click pluginSpec "https://github.com/volantvm/volant/blob/main/internal/pluginspec/spec.go"
    click bakeSh "https://github.com/volantvm/volant/blob/main/build/bake.sh"
    click initC "https://github.com/volantvm/volant/blob/main/build/init.c"
    click systemdService "https://github.com/volantvm/volant/blob/main/build/systemd/driftd.service"
    click initramfs "https://github.com/volantvm/volant/blob/main/build/volant-initramfs.cpio.gz"
    click kernelImage "https://github.com/volantvm/volant/tree/main/kernel/bzImage"
```
