Architecture
Overview
Krust uses a two-layer architecture — a Rust core handles all Kubernetes operations, while Swift/SwiftUI provides the native macOS UI. This separation keeps data processing fast and memory-efficient while delivering a first-class desktop experience.
Rust Core (krust-core)
Built with the kube-rs crate, the Rust core handles all K8s API communication, watch streams, data processing, log buffering, and metrics caching. It compiles as a dynamic library (.dylib) that the Swift app loads at runtime.
UniFFI Bridge
Mozilla's UniFFI generates Swift bindings from Rust. The bridge provides type-safe FFI with automatic memory management. All Kubernetes data types are defined as UniFFI Records, ensuring safe, zero-overhead interop between the two languages.
Swift UI Layer
The UI layer combines multiple frameworks for optimal performance:
- SwiftUI for modern, declarative UI components
- NSTableView (AppKit) for the high-performance pod list, rendering only visible rows
- STTextView for the YAML editor with syntax highlighting
- SwiftTerm for the terminal emulator with full TTY support
Data Flow
Data flows through a unidirectional pipeline: K8s API → Rust watcher → RwLock store → UniFFI → Swift ViewModel → SwiftUI view. List views use zero-copy snapshots from the Rust store, ensuring minimal memory overhead even with thousands of resources.
Key Dependencies
- kube 3.0.1 — Kubernetes client library for Rust
- k8s-openapi 0.27 — Kubernetes API type definitions
- jiff — Timestamp handling (replaced chrono)
- serde — Serialization and deserialization
- SwiftTerm — Terminal emulator for Swift
- STTextView — High-performance text editor for Swift