Architecture
Monarch uses a hub-and-spoke topology centered on Monarch.panel. Managed hosts never expose control ports to the network; every management channel is multiplexed over an outbound WebSocket initiated by monarch-daemon.
Browser ──HTTPS/WSS──▶ Monarch.panel (Nuxt 4 SPA + Nitro + SQLite, :4382)
├── /api/* REST API (sessions, nodes, VMs, logs, settings)
├── /ws/live 2s telemetry, 5s VM lists, node status events
├── /ws/stream Relayed PTY, VNC, serial, journal, uploads
└── /api/mobile/* QR-paired phone API (cert-pinned)
▲
│ Outbound WSS /ws/daemon
│ (ECDSA P-256 challenge auth + SHA-256 TLS pin)
│
monarch-daemon (.NET 10 root agent on each host)
├── Libvirt / QEMU / KVM (virsh, virt-install, loopbacked VNC)
├── Storage & Cache (lsblk, lvs, zfs, smartctl, cache-health.json)
├── Network & Proxy (ip, wg, Caddyfile, acme.sh, firewalld/ufw)
└── Host (systemctl, journalctl, docker/podman, pacman/apt/dnf/zypper)
Daemon wire protocol (/ws/daemon)
Tunnel.cs in Monarch.daemon and server/routes/ws/daemon.ts / hub.ts / rpc.ts in Monarch.panel share a single multiplexed WebSocket per node:
- Handshake:
hello→auth(signed challengecontrolcenter-daemon-auth:v2:<nonce>:<machineId>) →ready. - Text frames (JSON):
req/res: Request/response RPC calls across allowlisted modules (libvirt.*,storage.*,lvmcache.*,caddy.*,certs.*,containers.*,firewall.*,services.*,accounts.*,updates.*,monarch.*,clyocloud.*).open/opened/close: Lifecycle for bidirectional streams, plus control frames such asresize,finish, andprogress.- Periodic pushes:
telemetryevery 2 seconds,vmsevery 5 seconds,hostinfo, andping/pong.
- Binary frames: A 4-byte big-endian stream ID followed by raw payload bytes. Stream IDs below
0x80000000are panel-initiated (pty,exec,serial,vnc,journal.follow,ctr.logs.follow,ctr.pull,updates.apply,vol.upload,vol.download,certs.acme); IDs starting at0x80000000are daemon-initiated (logfileshipping).
Data persistence & retention
- Panel state (
node:sqlite): Nodes, ECDSA public keys, hashed join tokens, mobile device records, alert rules, audit logs, and time-series metrics. Live metrics arrive every 2 seconds; minute-resolution telemetry history is kept for 90 days (network interfaces and VMs for 30 days). - Host state:
/etc/monarch-daemon/daemon.jsonanddaemon.key(0600) for node identity and panel pin./var/lib/monarch/cache-health.jsonupdated every 10 minutes bymonarch-cache-guard./etc/clyocloud/clyocloud.envandsecret.envwhen ClyoCloud is enabled on Monarch OS.