# slaker19/webkvm architecture

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

- Interactive diagram: https://gitdiagram.com/slaker19/webkvm
- Repository: https://github.com/slaker19/webkvm

## Overview

WebKVM is a web-based Linux virtualization manager for KVM/QEMU VMs and Incus containers. Users authenticate in the SPA, navigate management pages, and issue API requests to the Go server, which exposes compute, storage, image, and cluster operations. Live status and telemetry arrive through SSE. The README also identifies terminal access, backups, firewall, networking, and HA clustering as major capabilities. Connections below are limited to excerpted calls and explicit README statements; many backend feature paths are present in the tree but their wiring was not sampled.

Main entry points: [`backend/internal/api`](https://github.com/slaker19/webkvm/tree/main/backend/internal/api) (REST handlers), [`frontend/src/App.svelte`](https://github.com/slaker19/webkvm/blob/main/frontend/src/App.svelte) (Management SPA), [`frontend/src/lib/stores/auth.svelte.js`](https://github.com/slaker19/webkvm/blob/main/frontend/src/lib/stores/auth.svelte.js) (Session and API), [`backend/internal/compute/backend.go`](https://github.com/slaker19/webkvm/blob/main/backend/internal/compute/backend.go) (Compute abstraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Web interface"]
  node_spa["Management SPA<br/>[App.svelte]"]
  node_router["Hash router<br/>[router.svelte.js]"]
  node_session["Session and API<br/>[auth.svelte.js]"]
  node_live["Live event store<br/>[events.svelte.js]"]
  node_storageui["Storage views<br/>[Storage.svelte]"]
  node_storage_tabs["Storage tabs"]
  node_vmui["VM management<br/>[VmList.svelte]"]
  node_console["Web terminal<br/>[HostConsole.svelte]"]
end

subgraph group_server["API server"]
  node_server_main["HTTP server<br/>[main.go]"]
  node_api["REST handlers"]
  node_authn["Authentication"]
  node_eventhub["Event hub<br/>[hub.go]"]
end

subgraph group_compute["Compute and cluster"]
  node_compute_api["VM and container API<br/>[vms.go]"]
  node_compute_backend["Compute abstraction<br/>[backend.go]"]
  node_libvirt["KVM operations<br/>[domain.go]"]
  node_incus["Incus operations<br/>[incus.go]"]
  node_ha["HA orchestration<br/>[control_plane.go]"]
end

subgraph group_resources["Storage and images"]
  node_storage_api["Storage API<br/>[storage_pools.go]"]
  node_storage_libvirt["KVM storage<br/>[storage.go]"]
  node_incus_storage["Incus storage<br/>[incus_storage.go]"]
  node_backup["Backup services<br/>[runner.go]"]
  node_images["Image deployments<br/>[image_hub.go]"]
end

subgraph group_platform["Host services"]
  node_firewall["Firewall<br/>[host.go]"]
  node_networking["Host networking<br/>[networks.go]"]
  node_terminal_api["Console API<br/>[console.go]"]
end

node_operator(("Operator"))
node_incus_service["Incus service"]
node_libvirt_service["Libvirt service"]

node_operator -->|"uses"| node_spa
node_spa -->|"routes via"| node_router
node_spa -->|"bootstraps"| node_session
node_spa -->|"reads events"| node_live
node_spa -->|"HTTPS / REST"| node_server_main
node_storageui -->|"renders"| node_storage_tabs
node_storage_tabs -.->|"requests data"| node_session
node_vmui -.->|"requests data"| node_session
node_console -.->|"opens console"| node_session
node_server_main -.->|"serves"| node_api
node_api -.->|"authorizes"| node_authn
node_api -.->|"publishes events"| node_eventhub
node_api -.->|"routes VM calls"| node_compute_api
node_compute_api -.->|"dispatches compute"| node_compute_backend
node_compute_backend -.->|"runs KVM"| node_libvirt
node_compute_backend -.->|"runs containers"| node_incus
node_ha -.->|"coordinates cluster"| node_incus
node_api -.->|"routes storage"| node_storage_api
node_storage_api -.->|"manages volumes"| node_storage_libvirt
node_storage_api -.->|"manages storage"| node_incus_storage
node_api -.->|"runs backups"| node_backup
node_api -.->|"serves image hub"| node_images
node_api -.->|"configures rules"| node_firewall
node_api -.->|"manages networks"| node_networking
node_api -.->|"serves console"| node_terminal_api
node_libvirt -.->|"controls"| node_libvirt_service
node_incus -.->|"controls"| node_incus_service

click node_spa "https://github.com/slaker19/webkvm/blob/main/frontend/src/App.svelte"
click node_router "https://github.com/slaker19/webkvm/blob/main/frontend/src/lib/router.svelte.js"
click node_session "https://github.com/slaker19/webkvm/blob/main/frontend/src/lib/stores/auth.svelte.js"
click node_live "https://github.com/slaker19/webkvm/blob/main/frontend/src/lib/stores/events.svelte.js"
click node_storageui "https://github.com/slaker19/webkvm/blob/main/frontend/src/routes/Storage.svelte"
click node_storage_tabs "https://github.com/slaker19/webkvm/tree/main/frontend/src/lib/components/storage"
click node_vmui "https://github.com/slaker19/webkvm/blob/main/frontend/src/routes/VmList.svelte"
click node_console "https://github.com/slaker19/webkvm/blob/main/frontend/src/routes/HostConsole.svelte"
click node_server_main "https://github.com/slaker19/webkvm/blob/main/backend/cmd/server/main.go"
click node_api "https://github.com/slaker19/webkvm/tree/main/backend/internal/api"
click node_authn "https://github.com/slaker19/webkvm/tree/main/backend/internal/auth"
click node_eventhub "https://github.com/slaker19/webkvm/blob/main/backend/internal/events/hub.go"
click node_compute_api "https://github.com/slaker19/webkvm/blob/main/backend/internal/api/vms.go"
click node_compute_backend "https://github.com/slaker19/webkvm/blob/main/backend/internal/compute/backend.go"
click node_libvirt "https://github.com/slaker19/webkvm/blob/main/backend/internal/libvirt/domain.go"
click node_incus "https://github.com/slaker19/webkvm/blob/main/backend/internal/compute/incus/incus.go"
click node_ha "https://github.com/slaker19/webkvm/blob/main/backend/internal/ha/control_plane.go"
click node_storage_api "https://github.com/slaker19/webkvm/blob/main/backend/internal/api/storage_pools.go"
click node_storage_libvirt "https://github.com/slaker19/webkvm/blob/main/backend/internal/libvirt/storage.go"
click node_incus_storage "https://github.com/slaker19/webkvm/blob/main/backend/internal/compute/incus/incus_storage.go"
click node_backup "https://github.com/slaker19/webkvm/blob/main/backend/internal/backupstore/runner.go"
click node_images "https://github.com/slaker19/webkvm/blob/main/backend/internal/api/image_hub.go"
click node_firewall "https://github.com/slaker19/webkvm/blob/main/backend/internal/firewall/host.go"
click node_networking "https://github.com/slaker19/webkvm/blob/main/backend/internal/api/networks.go"
click node_terminal_api "https://github.com/slaker19/webkvm/blob/main/backend/internal/api/console.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_spa,node_router,node_session,node_live,node_storageui,node_storage_tabs,node_vmui,node_console toneBlue
class node_server_main,node_api,node_authn,node_eventhub toneAmber
class node_compute_api,node_compute_backend,node_libvirt,node_incus,node_ha toneMint
class node_storage_api,node_storage_libvirt,node_incus_storage,node_backup,node_images toneRose
class node_firewall,node_networking,node_terminal_api,node_operator,node_incus_service,node_libvirt_service toneIndigo
```

## Components

### Web interface

- [Management SPA](https://github.com/slaker19/webkvm/blob/main/frontend/src/App.svelte): `frontend/src/App.svelte`
- [Hash router](https://github.com/slaker19/webkvm/blob/main/frontend/src/lib/router.svelte.js): `frontend/src/lib/router.svelte.js`
- [Session and API](https://github.com/slaker19/webkvm/blob/main/frontend/src/lib/stores/auth.svelte.js): `frontend/src/lib/stores/auth.svelte.js`
- [Live event store](https://github.com/slaker19/webkvm/blob/main/frontend/src/lib/stores/events.svelte.js): `frontend/src/lib/stores/events.svelte.js`
- [Storage views](https://github.com/slaker19/webkvm/blob/main/frontend/src/routes/Storage.svelte): `frontend/src/routes/Storage.svelte`
- [Storage tabs](https://github.com/slaker19/webkvm/tree/main/frontend/src/lib/components/storage): `frontend/src/lib/components/storage`
- [VM management](https://github.com/slaker19/webkvm/blob/main/frontend/src/routes/VmList.svelte): `frontend/src/routes/VmList.svelte`
- [Web terminal](https://github.com/slaker19/webkvm/blob/main/frontend/src/routes/HostConsole.svelte): `frontend/src/routes/HostConsole.svelte`

### API server

- [HTTP server](https://github.com/slaker19/webkvm/blob/main/backend/cmd/server/main.go): `backend/cmd/server/main.go`
- [REST handlers](https://github.com/slaker19/webkvm/tree/main/backend/internal/api): `backend/internal/api`
- [Authentication](https://github.com/slaker19/webkvm/tree/main/backend/internal/auth): `backend/internal/auth`
- [Event hub](https://github.com/slaker19/webkvm/blob/main/backend/internal/events/hub.go): `backend/internal/events/hub.go`

### Compute and cluster

- [VM and container API](https://github.com/slaker19/webkvm/blob/main/backend/internal/api/vms.go): `backend/internal/api/vms.go`
- [Compute abstraction](https://github.com/slaker19/webkvm/blob/main/backend/internal/compute/backend.go): `backend/internal/compute/backend.go`
- [KVM operations](https://github.com/slaker19/webkvm/blob/main/backend/internal/libvirt/domain.go): `backend/internal/libvirt/domain.go`
- [Incus operations](https://github.com/slaker19/webkvm/blob/main/backend/internal/compute/incus/incus.go): `backend/internal/compute/incus/incus.go`
- [HA orchestration](https://github.com/slaker19/webkvm/blob/main/backend/internal/ha/control_plane.go): `backend/internal/ha/control_plane.go`

### Storage and images

- [Storage API](https://github.com/slaker19/webkvm/blob/main/backend/internal/api/storage_pools.go): `backend/internal/api/storage_pools.go`
- [KVM storage](https://github.com/slaker19/webkvm/blob/main/backend/internal/libvirt/storage.go): `backend/internal/libvirt/storage.go`
- [Incus storage](https://github.com/slaker19/webkvm/blob/main/backend/internal/compute/incus/incus_storage.go): `backend/internal/compute/incus/incus_storage.go`
- [Backup services](https://github.com/slaker19/webkvm/blob/main/backend/internal/backupstore/runner.go): `backend/internal/backupstore/runner.go`
- [Image deployments](https://github.com/slaker19/webkvm/blob/main/backend/internal/api/image_hub.go): `backend/internal/api/image_hub.go`

### Host services

- [Firewall](https://github.com/slaker19/webkvm/blob/main/backend/internal/firewall/host.go): `backend/internal/firewall/host.go`
- [Host networking](https://github.com/slaker19/webkvm/blob/main/backend/internal/api/networks.go): `backend/internal/api/networks.go`
- [Console API](https://github.com/slaker19/webkvm/blob/main/backend/internal/api/console.go): `backend/internal/api/console.go`

### Other components

- **Operator**
- **Incus service**
- **Libvirt service**

## Connections

- Operator → Management SPA: uses (evidence: `README.md`)
- Management SPA → Hash router: routes via (evidence: `frontend/src/App.svelte`)
- Management SPA → Session and API: bootstraps (evidence: `frontend/src/App.svelte`)
- Management SPA → Live event store: reads events (evidence: `frontend/src/App.svelte`)
- Management SPA → HTTP server: HTTPS / REST (evidence: `README.md`)
- Storage views → Storage tabs: renders (evidence: `frontend/src/routes/Storage.svelte`)
- Storage tabs → Session and API: requests data
- VM management → Session and API: requests data
- Web terminal → Session and API: opens console
- HTTP server → REST handlers: serves
- REST handlers → Authentication: authorizes
- REST handlers → Event hub: publishes events
- REST handlers → VM and container API: routes VM calls
- VM and container API → Compute abstraction: dispatches compute
- Compute abstraction → KVM operations: runs KVM
- Compute abstraction → Incus operations: runs containers
- HA orchestration → Incus operations: coordinates cluster
- REST handlers → Storage API: routes storage
- Storage API → KVM storage: manages volumes
- Storage API → Incus storage: manages storage
- REST handlers → Backup services: runs backups
- REST handlers → Image deployments: serves image hub
- REST handlers → Firewall: configures rules
- REST handlers → Host networking: manages networks
- REST handlers → Console API: serves console
- KVM operations → Libvirt service: controls
- Incus operations → Incus service: controls
