Architecture
Technical overview of HYPR’s internal architecture.System Overview
Components
hypr CLI
The command-line interface that users interact with. Written in Rust using clap for argument parsing. Key files:hypr-cli/src/main.rs- Command definitions and routinghypr-cli/src/client/mod.rs- gRPC client wrapperhypr-cli/src/commands/- Individual command implementations
/run/hypr/hypr.sock (Linux) or /tmp/hypr/hypr.sock (macOS).
hyprd Daemon
The background service that manages all VM operations. Runs as root for hardware access (KVM, networking, VFIO). Key files:hypr-daemon/src/main.rs- Daemon entry point, initializationhypr-daemon/src/api/server.rs- gRPC service implementationhypr-daemon/src/network_manager.rs- Network setup and managementhypr-daemon/src/orchestrator/- Stack orchestrationhypr-daemon/src/reconcile.rs- State reconciliation
- VM lifecycle management (create, start, stop, delete)
- Network setup (bridge, TAP devices, port forwarding)
- Image management (storage, lookup)
- Volume management
- State persistence (SQLite)
- Graceful shutdown and cleanup
State Manager
Persistent storage using SQLite. Stores VM state, images, stacks, networks, volumes, and configuration. Location:/var/lib/hypr/hypr.db
Tables:
vms- VM records with config, status, timestampsimages- Image metadata and pathsstacks- Compose stack definitionsnetworks- Custom network configurationsvolumes- Named volume metadata- Migrations handled automatically on startup
Network Manager
Handles all networking for VMs. See Networking for user documentation. Linux:- Creates bridge device
vbr0(default) plus custom bridges - Allocates TAP devices per VM
- IP allocation via built-in IPAM (10.88.0.0/16 default)
- Port forwarding via eBPF or userspace proxy
- DNS server for
.hyprdomain resolution
- Uses vmnet framework (via libkrun)
- IP allocation via DHCP (192.168.64.0/24)
- Port forwarding via userspace proxy
- DNS server for name resolution
hypr-core/src/network/mod.rs- Network modulehypr-core/src/network/bridge/- Bridge managementhypr-core/src/network/dns.rs- DNS serverhypr-core/src/network/ipam.rs- IP address managementhypr-core/src/network/defaults.rs- Platform-specific defaults
VMM Adapter
Abstract interface for hypervisor operations. Platform-specific implementations:| Adapter | Platform | Hypervisor |
|---|---|---|
CloudHypervisorAdapter | Linux | cloud-hypervisor |
LibkrunAdapter | macOS ARM64 | libkrun-efi |
LibkrunAdapter | macOS Intel | libkrun-efi |
hypr-core/src/adapters/mod.rs- Trait definitionhypr-core/src/adapters/cloudhypervisor.rs- Linux adapterhypr-core/src/adapters/krun.rs- macOS adapterhypr-core/src/adapters/libkrun_ffi.rs- libkrun FFI bindings
Builder
Builds images from Dockerfiles. Process:- Parse Dockerfile into AST (
parser.rs) - Build dependency graph (
graph.rs) - Check layer cache (
cache.rs) - Execute instructions in build VM (
executor.rs) - Generate squashfs and manifest (
manifest.rs)
hypr-core/src/builder/parser.rs- Dockerfile parserhypr-core/src/builder/executor.rs- Build executionhypr-core/src/builder/oci.rs- OCI layer handling
Registry Client
Pulls images from OCI registries. Key files:hypr-core/src/registry/mod.rs- Image puller
- Parse image reference (handle Docker Hub shorthand)
- Authenticate (anonymous or with credentials)
- Fetch manifest, select platform
- Download and extract layers
- Create squashfs from extracted rootfs
- Save manifest with entrypoint, env, ports
Kestrel Guest Agent
Minimal C program that runs as PID 1 inside VMs. Compiled statically (~500KB). Key files:guest/kestrel.c- Guest agent source
- Mount essential filesystems (/proc, /sys, /dev)
- Mount rootfs (squashfs + overlayfs)
- Parse runtime manifest from kernel cmdline
- Configure networking (IP, gateway, DNS)
- Execute user workload
- Handle exec sessions via vsock
- Reap zombie processes
- Implement restart policies
- Runtime mode: Normal VM operation
- Build mode: Isolated build environment (no network)
Data Flow
Running a VM
- User:
hypr run nginx -p 8080:80 - CLI parses args, calls
CreateVMRPC - Daemon checks for image, pulls if needed
- Network manager allocates IP and TAP device
- Adapter builds hypervisor command
- Hypervisor spawns VM with kernel + initramfs
- Kestrel mounts rootfs, configures network
- Kestrel executes entrypoint
- Port forwarding activated
Executing Commands
- User:
hypr exec vm123 -- ls -la - CLI calls exec RPC
- Daemon looks up VM’s vsock path
- CLI connects to vsock, sends exec request
- Kestrel spawns command, relays I/O
- Exit code returned to CLI
Deploying a Stack
- User:
hypr compose up - CLI reads compose file, calls
DeployStackRPC - Daemon parses compose file via converter
- Creates networks defined in compose
- Creates volumes defined in compose
- Pulls/builds required images
- Creates VMs in dependency order
- Returns stack status
gRPC API
The daemon exposes a gRPC API with 34+ endpoints: VM Operations:CreateVM,StartVM,StopVM,DeleteVMListVms,GetVM,RunVM(streaming)StreamVMMetrics,StreamLogs,Exec
ListImages,GetImage,DeleteImageGetImageHistory,PullImage(streaming),BuildImage(streaming)
DeployStack(streaming),DestroyStackListStacks,GetStack,StreamStackServiceLogs
CreateNetwork,DeleteNetwork,ListNetworks,GetNetwork
CreateVolume,DeleteVolume,ListVolumes,GetVolume,PruneVolumes
GetSystemStats,HealthGetSettings,UpdateSettingsSubscribeEvents(streaming)
Ports and Sockets
HYPR uses ports in the 41000-41999 range:| Port | Service |
|---|---|
| 41000 | gRPC API |
| 41001 | REST gateway |
| 41002 | Prometheus metrics |
| 41003 | DNS server |
| 41010 | Build HTTP proxy |
| 41011 | Build agent vsock |
File Layout
Observability
Logging
Structured logging viatracing crate. Control with RUST_LOG:
Metrics
Prometheus metrics exposed at:41002/metrics:
- VM counts by status
- Operation durations
- Network bytes
- Build statistics
Tracing
OpenTelemetry support for distributed tracing:Security Model
- Daemon runs as root for KVM/hardware access
- VMs are isolated via hardware virtualization
- Each VM has its own kernel, memory, network
- Build VMs have no network access (filesystem IPC only)
- Boot VGA protection prevents display GPU unbind
- Volumes use host filesystem permissions
Platform Differences
| Feature | Linux | macOS |
|---|---|---|
| Hypervisor | cloud-hypervisor | libkrun |
| Network | Bridge + TAP | vmnet |
| Default CIDR | 10.88.0.0/16 | 192.168.64.0/24 |
| Max VMs | ~65,000 | ~250 |
| GPU | VFIO passthrough | Metal (ARM64) |
| Filesystem sharing | virtiofs | virtio-fs |