Skip to content

Architecture Overview

paiOS architecture documentation falls into three categories:

High-level visualizations of the system from different perspectives:

Detailed documentation for each domain crate, covering ports, adapters, feature flags, and data flow:

  • Domains Overview: Index of all domain crates
  • Common: Shared foundation (logging, config, permissions)
  • Core: Orchestrator, SessionManager, FlowRunner
  • Inference: AI backends, resource management, MCP client
  • Audio: Audio capture, playback, signal conditioning
  • Vision: Camera, frame processing, motion gating
  • API: API Gateway, protocol adapters, routing
  • Peripherals: HMI, buttons, LEDs, haptics

Topics that span multiple domains:

ADRs document the β€œwhy” behind key decisions. They capture context, alternatives considered, and consequences; not implementation details:

paiOS uses Hexagonal Architecture (Ports and Adapters). Rust traits map to Ports; feature-gated structs map to Adapters. Dependencies point inward; pai-engine/src/main.rs is the Composition Root.

Vendor Flexibility and Rapid Porting: While the Rockchip RK3588 is the initial deployment target, this architecture ensures the engine is completely vendor-agnostic. Hardware-specific SDKs are isolated in adapters, meaning the system can be rapidly ported to new SoCs (e.g., from NVIDIA, Qualcomm, or Apple) without rewriting any core business logic.

paiEngine is a flexible platform: The engine provides multiple APIs. gRPC over Unix Domain Sockets (UDS) is the primary IPC interface for applications/services running on the same hardware: comparable to Linux syscalls. For communicating with external clients on other machines, the engine provides gRPC over TCP/TLS. REST (Ollama/OpenAI compatibility) and MCP are also supported for specific use cases. For mobile/wearable form factors, a smartphone companion app can serve as a user interface for configuration and interaction; the engine itself is designed to be extended for any AI device.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
Driving β”‚ Domain β”‚ Driven
Adapters ──────► β”‚ (Ports = Rust Traits) β”‚ ──────► Adapters
(API, HMI) β”‚ (Pure business logic) β”‚ (Camera, NPU, Mic)
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Package by Feature: Each domain crate contains its own domain logic, ports (traits), and feature-gated adapters. See Workspace and Build for the full workspace structure.

Documentation TypePurposeExample
ADRsDocument decisions and their rationale”Why Hexagonal Architecture?”
Module docsDocument current state implementation”How inference manages resources”
Cross-cutting docsDocument shared concerns across modules”Feature flag conventions”