# kurohigee07/wraithos architecture

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

- Interactive diagram: https://gitdiagram.com/kurohigee07/wraithos
- Repository: https://github.com/kurohigee07/wraithos

## Overview

WraithOS is a Wasm-plugin host distributed as a secure appliance Linux. The main workflow is an operator or API client uploads a module, the tenant-aware API validates policy and quota, the registry loads it, and Wasmtime executes it in a capability-limited sandbox; results and audit/telemetry are exposed through the host API. Separate appliance stages provide boot, encrypted data, TPM sealing, and RAUC update/rollback. Source excerpts show the runtime call path; appliance relationships are based on README descriptions, not inspected implementation excerpts.

Main entry points: [`orchestrator/src/http_api.rs`](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/http_api.rs) (Module HTTP API), [`orchestrator/src/wasm/module.rs`](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/wasm/module.rs) (Wasm Execution), [`orchestrator/src/telemetry.rs`](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/telemetry.rs) (Health / Metrics), [`orchestrator/src/context.rs`](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/context.rs) (Shared Runtime Context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Host API"]
  node_host["Orchestrator Host<br/>[main.rs]"]
  node_http["Module HTTP API<br/>[http_api.rs]"]
  node_build["Build API<br/>[build_api.rs]"]
  node_wizard["Provisioning Wizard<br/>[wizard.rs]"]
end

subgraph group_exec["Plugin Runtime"]
  node_registry["Module Registry<br/>[module_registry.rs]"]
  node_wasm["Wasm Execution<br/>[module.rs]"]
  node_wasm_engine["Wasmtime Engine<br/>[mod.rs]"]
  node_host_state["Wasm Host State<br/>[state.rs]"]
  node_host_functions["Host Functions<br/>[host_impls.rs]"]
  node_context["Shared Runtime Context<br/>[context.rs]"]
  node_events["Event Bus<br/>[events.rs]"]
  node_rhai["Rhai Event Worker<br/>[rhai_worker.rs]"]
end

subgraph group_policy["Tenant Controls"]
  node_capabilities["Capability Policy<br/>[capabilities.rs]"]
  node_tenants["Tenant Auth / Limits<br/>[tenant.rs]"]
  node_quotas["Module Quotas<br/>[quota.rs]"]
end

subgraph group_ops["Operations"]
  node_config["Runtime Configuration<br/>[config.rs]"]
  node_audit[("Audit Log<br/>[audit.rs]")]
  node_telemetry["Health / Metrics<br/>[telemetry.rs]"]
  node_ui["Dashboard UI<br/>[ui.rs]"]
  node_websocket["WebSocket API<br/>[ws.rs]"]
  node_database[("SQLite State<br/>[context.rs]")]
end

subgraph group_appliance["Appliance Security"]
  node_appliance["Buildroot Appliance"]
  node_boot["Verified Boot"]
  node_encrypted_data[("Encrypted Data")]
  node_tpm["TPM Sealing"]
  node_rauc["RAUC A/B Updates"]
end

node_operator(("Operator / Client"))

node_operator -->|"starts"| node_host
node_operator -->|"uploads / executes"| node_http
node_http -->|"looks up / loads"| node_registry
node_http -->|"checks tenant limits"| node_tenants
node_http -->|"builds quota state"| node_quotas
node_http -->|"validates capabilities"| node_capabilities
node_registry -->|"loads module"| node_wasm
node_http -->|"executes module"| node_wasm
node_wasm -->|"instantiates component"| node_wasm_engine
node_wasm -->|"creates store state"| node_host_state
node_wasm -->|"applies policy"| node_capabilities
node_wasm -->|"acquires permits"| node_quotas
node_host_state -->|"holds shared context"| node_context
node_wasm_engine -->|"registers imports"| node_host_functions
node_host_functions -->|"emits events"| node_events
node_rhai -->|"consumes / emits"| node_events
node_rhai -->|"checks event rights"| node_capabilities
node_context -->|"writes audit entries"| node_audit
node_context -->|"initializes SQLite"| node_database
node_telemetry -->|"mounts routes"| node_http
node_telemetry -->|"mounts routes"| node_ui
node_telemetry -->|"mounts routes"| node_websocket
node_telemetry -->|"mounts routes"| node_wizard
node_telemetry -.->|"optionally mounts"| node_build
node_config -->|"configures"| node_context
node_operator -->|"provisions appliance"| node_wizard
node_appliance -->|"packages boot chain"| node_boot
node_boot -->|"boots with"| node_encrypted_data
node_tpm -->|"seals data key"| node_encrypted_data
node_rauc -->|"updates A/B slots"| node_appliance

click node_host "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/main.rs"
click node_http "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/http_api.rs"
click node_build "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/build_api.rs"
click node_wizard "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/wizard.rs"
click node_registry "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/module_registry.rs"
click node_wasm "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/wasm/module.rs"
click node_wasm_engine "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/wasm/mod.rs"
click node_host_state "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/wasm/state.rs"
click node_host_functions "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/wasm/host_impls.rs"
click node_capabilities "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/capabilities.rs"
click node_tenants "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/tenant.rs"
click node_quotas "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/quota.rs"
click node_context "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/context.rs"
click node_config "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/config.rs"
click node_events "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/events.rs"
click node_rhai "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/rhai_worker.rs"
click node_audit "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/audit.rs"
click node_telemetry "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/telemetry.rs"
click node_ui "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/ui.rs"
click node_websocket "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/ws.rs"
click node_database "https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/context.rs"
click node_appliance "https://github.com/kurohigee07/wraithos/tree/main/deploy/wraithos"
click node_boot "https://github.com/kurohigee07/wraithos/tree/main/deploy/wraithos"
click node_encrypted_data "https://github.com/kurohigee07/wraithos/tree/main/deploy/wraithos"
click node_tpm "https://github.com/kurohigee07/wraithos/tree/main/deploy/wraithos"
click node_rauc "https://github.com/kurohigee07/wraithos/tree/main/deploy/wraithos"

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_host,node_http,node_build,node_wizard,node_operator toneBlue
class node_registry,node_wasm,node_wasm_engine,node_host_state,node_host_functions,node_context,node_events,node_rhai toneAmber
class node_capabilities,node_tenants,node_quotas toneMint
class node_config,node_audit,node_telemetry,node_ui,node_websocket,node_database toneRose
class node_appliance,node_boot,node_encrypted_data,node_tpm,node_rauc toneIndigo
```

## Components

### Host API

- [Orchestrator Host](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/main.rs): `orchestrator/src/main.rs`
- [Module HTTP API](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/http_api.rs): `orchestrator/src/http_api.rs`
- [Build API](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/build_api.rs): `orchestrator/src/build_api.rs`
- [Provisioning Wizard](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/wizard.rs): `orchestrator/src/wizard.rs`

### Plugin Runtime

- [Module Registry](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/module_registry.rs): `orchestrator/src/module_registry.rs`
- [Wasm Execution](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/wasm/module.rs): `orchestrator/src/wasm/module.rs`
- [Wasmtime Engine](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/wasm/mod.rs): `orchestrator/src/wasm/mod.rs`
- [Wasm Host State](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/wasm/state.rs): `orchestrator/src/wasm/state.rs`
- [Host Functions](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/wasm/host_impls.rs): `orchestrator/src/wasm/host_impls.rs`
- [Shared Runtime Context](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/context.rs): `orchestrator/src/context.rs`
- [Event Bus](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/events.rs): `orchestrator/src/events.rs`
- [Rhai Event Worker](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/rhai_worker.rs): `orchestrator/src/rhai_worker.rs`

### Tenant Controls

- [Capability Policy](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/capabilities.rs): `orchestrator/src/capabilities.rs`
- [Tenant Auth / Limits](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/tenant.rs): `orchestrator/src/tenant.rs`
- [Module Quotas](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/quota.rs): `orchestrator/src/quota.rs`

### Operations

- [Runtime Configuration](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/config.rs): `orchestrator/src/config.rs`
- [Audit Log](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/audit.rs): `orchestrator/src/audit.rs`
- [Health / Metrics](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/telemetry.rs): `orchestrator/src/telemetry.rs`
- [Dashboard UI](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/ui.rs): `orchestrator/src/ui.rs`
- [WebSocket API](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/ws.rs): `orchestrator/src/ws.rs`
- [SQLite State](https://github.com/kurohigee07/wraithos/blob/main/orchestrator/src/context.rs): `orchestrator/src/context.rs`

### Appliance Security

- [Buildroot Appliance](https://github.com/kurohigee07/wraithos/tree/main/deploy/wraithos): `deploy/wraithos`
- [Verified Boot](https://github.com/kurohigee07/wraithos/tree/main/deploy/wraithos): `deploy/wraithos`
- [Encrypted Data](https://github.com/kurohigee07/wraithos/tree/main/deploy/wraithos): `deploy/wraithos`
- [TPM Sealing](https://github.com/kurohigee07/wraithos/tree/main/deploy/wraithos): `deploy/wraithos`
- [RAUC A/B Updates](https://github.com/kurohigee07/wraithos/tree/main/deploy/wraithos): `deploy/wraithos`

### Other components

- **Operator / Client**

## Connections

- Operator / Client → Orchestrator Host: starts (evidence: `README.md`)
- Operator / Client → Module HTTP API: uploads / executes (evidence: `README.md`)
- Module HTTP API → Module Registry: looks up / loads (evidence: `orchestrator/src/http_api.rs`)
- Module HTTP API → Tenant Auth / Limits: checks tenant limits (evidence: `orchestrator/src/http_api.rs`)
- Module HTTP API → Module Quotas: builds quota state (evidence: `orchestrator/src/http_api.rs`)
- Module HTTP API → Capability Policy: validates capabilities (evidence: `orchestrator/src/http_api.rs`)
- Module Registry → Wasm Execution: loads module (evidence: `orchestrator/src/module_registry.rs`)
- Module HTTP API → Wasm Execution: executes module (evidence: `orchestrator/src/http_api.rs`)
- Wasm Execution → Wasmtime Engine: instantiates component (evidence: `orchestrator/src/wasm/module.rs`)
- Wasm Execution → Wasm Host State: creates store state (evidence: `orchestrator/src/wasm/module.rs`)
- Wasm Execution → Capability Policy: applies policy (evidence: `orchestrator/src/wasm/module.rs`)
- Wasm Execution → Module Quotas: acquires permits (evidence: `orchestrator/src/wasm/module.rs`)
- Wasm Host State → Shared Runtime Context: holds shared context (evidence: `orchestrator/src/wasm/state.rs`)
- Wasmtime Engine → Host Functions: registers imports (evidence: `orchestrator/src/wasm/mod.rs`)
- Host Functions → Event Bus: emits events (evidence: `orchestrator/src/wasm/host_impls.rs`)
- Rhai Event Worker → Event Bus: consumes / emits (evidence: `orchestrator/src/rhai_worker.rs`)
- Rhai Event Worker → Capability Policy: checks event rights (evidence: `orchestrator/src/rhai_worker.rs`)
- Shared Runtime Context → Audit Log: writes audit entries (evidence: `orchestrator/src/context.rs`)
- Shared Runtime Context → SQLite State: initializes SQLite (evidence: `orchestrator/src/context.rs`)
- Health / Metrics → Module HTTP API: mounts routes (evidence: `orchestrator/src/telemetry.rs`)
- Health / Metrics → Dashboard UI: mounts routes (evidence: `orchestrator/src/telemetry.rs`)
- Health / Metrics → WebSocket API: mounts routes (evidence: `orchestrator/src/telemetry.rs`)
- Health / Metrics → Provisioning Wizard: mounts routes (evidence: `orchestrator/src/telemetry.rs`)
- Health / Metrics → Build API: optionally mounts (evidence: `orchestrator/src/telemetry.rs`)
- Runtime Configuration → Shared Runtime Context: configures (evidence: `orchestrator/src/config.rs`)
- Operator / Client → Provisioning Wizard: provisions appliance (evidence: `README.md`)
- Buildroot Appliance → Verified Boot: packages boot chain (evidence: `README.md`)
- Verified Boot → Encrypted Data: boots with (evidence: `README.md`)
- TPM Sealing → Encrypted Data: seals data key (evidence: `README.md`)
- RAUC A/B Updates → Buildroot Appliance: updates A/B slots (evidence: `README.md`)
