Skip to content

Architecture

Crate Map

Orca is a Cargo workspace with 8 crates:

CrateTypePurpose
orca-corelibTypes, config parsing, Runtime trait, secrets, errors
orca-agentlibDocker + Wasm runtime implementations
orca-controllibAPI server (axum), reconciler, scheduler, Raft consensus
orca-proxylibReverse proxy + TLS + Wasm routing (pingora)
orca-ailibLLM backend, conversational alerts, GPU monitor
orca-clibinSingle orca binary (all commands)
orca-tuibinTerminal UI dashboard (ratatui)
orca-webbinWeb dashboard (Dioxus, stub)

Dependency Flow

core <-- agent <-- control <-- cli
  ^                   ^
  |                   |
  +--- proxy          +--- tui / web
  +--- ai

System Diagram

┌──────────────────────────────────────┐
│         CLI / TUI / Web UI           │
└───────────────┬──────────────────────┘
                │ REST / WebSocket
┌───────────────▼──────────────────────┐
│          Control Plane               │
│  ┌────────────────────────────────┐  │
│  │  API Server (axum)             │  │
│  │  Scheduler (bin-packing + GPU) │  │
│  │  Raft Consensus (openraft)     │  │
│  │  State Store (redb)            │  │
│  │  Health Checker + AI Monitor   │  │
│  └────────────────────────────────┘  │
└───────────────┬──────────────────────┘
                │ gRPC (mTLS)
     ┌──────────┼──────────┐
     ▼          ▼          ▼
┌─────────┐ ┌─────────┐ ┌─────────┐
│ Node 1  │ │ Node 2  │ │ Node 3  │
│ Docker  │ │ Docker  │ │ Docker  │
│ Wasm    │ │ Wasm    │ │ Wasm    │
│ Proxy   │ │ Proxy   │ │ Proxy   │
└─────────┘ └─────────┘ └─────────┘

Runtime Trait

The core abstraction. Every workload -- container or Wasm -- implements it:

rust
#[async_trait]
pub trait Runtime: Send + Sync + 'static {
    async fn create(&self, spec: &WorkloadSpec) -> Result<WorkloadHandle>;
    async fn start(&self, handle: &WorkloadHandle) -> Result<()>;
    async fn stop(&self, handle: &WorkloadHandle, timeout: Duration) -> Result<()>;
    async fn remove(&self, handle: &WorkloadHandle) -> Result<()>;
    async fn status(&self, handle: &WorkloadHandle) -> Result<WorkloadStatus>;
    async fn logs(&self, handle: &WorkloadHandle, opts: &LogOpts) -> Result<LogStream>;
    async fn exec(&self, handle: &WorkloadHandle, cmd: &[String]) -> Result<ExecResult>;
    async fn stats(&self, handle: &WorkloadHandle) -> Result<ResourceStats>;
}

Two implementations: ContainerRuntime (Docker via bollard) and WasmRuntime (wasmtime + WASI P2).

Key Dependencies

CratePurpose
openraftRaft consensus -- pure Rust, async
redbEmbedded KV store -- zero-config, ACID
axumHTTP API -- Tokio ecosystem
tonicgRPC -- control-plane to agent
bollardDocker API client
wasmtimeWasm runtime -- WASI P2
pingoraReverse proxy -- Cloudflare-proven
ratatuiTUI framework
clapCLI parsing
tracingStructured logging + OpenTelemetry

Design Principles

  1. Single binary -- one executable is agent, control plane, CLI, and proxy
  2. Config fits on one screen -- TOML, not YAML
  3. Dual runtime -- containers and Wasm are both first-class
  4. Batteries included -- proxy, TLS, secrets, metrics, git-push deploy
  5. No .unwrap() in library code -- proper error handling everywhere
  6. Max 250 lines per file -- enforced by convention

Released under the AGPL-3.0 License.