Skip to content

Layer Architecture

This page presents the paiOS architecture as a layered stack, similar to how Android documentation visualizes its system architecture.

graph TB
  subgraph Layer5["📱 Application Layer"]
      App1["First Party Apps"]
      App2["Third Party Apps"]
      App3["Intelligence Packs"]
  end

  subgraph Layer4["🔌 API Layer"]
      gRPC["gRPC API - UDS"]
      Proto["Protobuf - MIT"]
  end

  subgraph Layer3["🧠 Core Engine Layer"]
      RPC["rpc/"]
      Core["core/"]
      Orch["orchestrator/"]
  end

  subgraph Layer2["⚙️ HAL Layer"]
      AudioHAL["Audio"]
      NPUHAL["NPU"]
      GPUHAL["GPU"]
      HIDHAL["HID"]
      CameraHAL["Camera"]
      LEDHAL["LED"]
  end

  subgraph Layer1["💾 OS Layer"]
      Kernel["Linux Kernel"]
      Drivers["Device Drivers"]
      Systemd["systemd"]
      RAUC["RAUC"]
  end

  subgraph Layer0["🔧 Hardware Layer"]
      SoC["RK3588S2 - 6 TOPS NPU"]
      Mic["Microphone Array"]
      USB["USB-C"]
      Camera["Camera Module"]
      Battery["Battery"]
  end

  Layer5 --> Layer4
  Layer4 --> Layer3
  Layer3 --> Layer2
  Layer2 --> Layer1
  Layer1 --> Layer0

The physical components of the paiOS device.

ComponentDescriptionVersion
SoCRockchip RK3588S2 with 6 TOPS NPU + Mali-G610 GPUV1.0+
MicrophoneUSB mic (Dev) / 3-mic beamforming array (Pro)V1.0+
USB-CComposite device (HID + UAC + Mass Storage)V1.0+
CameraUVC camera module for Vision modelsV2.0+
BatteryIntegrated battery for standalone operationV2.0+

Custom Debian-based OS built with Debos.

ComponentTechnologyPurpose
KernelRadxa Vendor Kernel (via APT)Hardware support for RK3588S2
DriversNPU, GPU, USB Gadget, i2sHardware access
systemdService ManagerManages pai-daemon lifecycle
RAUCA/B Update SystemAtomic, reliable OTA updates

⚙️ Layer 2: Hardware Abstraction Layer (HAL)

Section titled “⚙️ Layer 2: Hardware Abstraction Layer (HAL)”

Abstracts hardware details from the core engine.

HAL ModuleTechnologyResponsibility
Audio HALcpalCross-platform audio capture, VAD
NPU HALrknn-sysRockchip NPU inference via bindgen
GPU HALOpenCLMali-G610 fallback inference
HID HALusb-gadgetUSB keyboard emulation
Camera HALV4L2Video capture (V2.0+)
LED HALGPIOStatus indicators

The “brain” of paiOS – pure Rust following Clean Architecture.

ModuleRoleResponsibility
rpc/Interface AdaptergRPC/UDS communication, Protobuf conversion
core/Domain LayerSystemController, state machine, business logic
orchestrator/Application LogicInferenceOrchestrator, NPU/GPU/CPU routing

Dependency Direction:

rpc/ → core/ ← orchestrator/ → hal/

The domain layer (core/) has no dependencies on other modules.


The interface between Engine and Apps.

ComponentLicenseDescription
gRPC APIMITUnix Domain Socket communication
ProtobufMITType-safe message definitions

User-facing apps and Intelligence Packs.

ComponentLicenseDescription
First Party AppsMITReference implementations in apps/
Third Party AppsVariesBuilt with pai-builder SDK
Intelligence PacksProprietaryEncrypted models + workflows for B2B

The same software stack runs on evolving hardware:

timeline
  title paiOS Product Evolution
  
  section V1.0 paiLink Dev
      Radxa Rock 5C : USB HID
      Whisper NPU : gRPC Core
      
  section V1.5 paiLink Pro
      CNC Case : Secure Boot
      Mic Array : Intelligence Packs
      
  section V2.0 Power Stick
      Custom PCB : Battery
      Camera : Vision Inference
      
  section V3.0 paiGo
      paiGo Form : Always-On AI
      Multi-Modal : Context Awareness

LayerTechnologyLicense
OS BuildDebosAGPL-3.0
OS UpdatesRAUCLGPL-2.1
Core EngineRust (2021)AGPL-3.0
Async RuntimeTokioMIT
IPCgRPC (Tonic + Prost)MIT
NPU Bindingsrknn-sys (bindgen)AGPL-3.0
AudiocpalApache-2.0
HIDusb-gadgetMIT
Client AppsFlutter (optional)BSD-3
API DefinitionsProtobufMIT
DocumentationStarlight (Astro)MIT