# aibeto/chiriscene architecture

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

- Interactive diagram: https://gitdiagram.com/aibeto/chiriscene
- Repository: https://github.com/aibeto/chiriscene

## Overview

ChiRi is an Android root daemon for CPU monitoring and adaptive scheduling, with a browser-based configuration and status UI. The principal workflow is: kernel events and device state are monitored, foreground and frame conditions are detected, then the daemon selects a scheduling policy and applies CPU-frequency or thread adjustments. Its CLG governor and FAS frame-aware engine are distinct control paths; FAS is described as not enabled in the README. The UI also exposes app, battery, log, advanced, and lab views. Wiring details are based on the README and sampled excerpts; unsampled subsystem connections are omitted where uncertain.

Main entry points: [`src/monitor/mod.rs`](https://github.com/aibeto/chiriscene/blob/main/src/monitor/mod.rs) (Monitor Coordinator), [`yumi-ebpf/src/main.rs`](https://github.com/aibeto/chiriscene/blob/main/yumi-ebpf/src/main.rs) (eBPF Probes), [`src/chiri/mod.rs`](https://github.com/aibeto/chiriscene/blob/main/src/chiri/mod.rs) (Event Loop), [`src/chiri/scheduler.rs`](https://github.com/aibeto/chiriscene/blob/main/src/chiri/scheduler.rs) (Mode Scheduler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Daemon Runtime"]
  node_daemon["ChiRi Daemon<br/>[main.rs]"]
  node_events["Event Loop<br/>[mod.rs]"]
  node_config["Runtime Config<br/>[config.rs]"]
end

subgraph group_monitoring["Monitoring"]
  node_monitor["Monitor Coordinator<br/>[mod.rs]"]
  node_cpu["CPU Load Monitor<br/>[cpu_monitor.rs]"]
  node_frame["Frame Monitor<br/>[fps_monitor.rs]"]
  node_detect["App And Screen Detection<br/>[app_detect.rs]"]
  node_telemetry["System Telemetry<br/>[telemetry.rs]"]
  node_ebpf["eBPF Probes<br/>[main.rs]"]
end

subgraph group_control["Scheduling Control"]
  node_scheduler["Mode Scheduler<br/>[scheduler.rs]"]
  node_governor["CLG Governor<br/>[governor.rs]"]
  node_fasmanager["FAS Manager<br/>[fas_manager.rs]"]
  node_fasengine["FAS Controller<br/>[controller.rs]"]
  node_framepipe["Frame Policy<br/>[frame_pipeline.rs]"]
  node_policy["Frequency Policies"]
end

subgraph group_interface["Web Interface"]
  node_webui["Web UI<br/>[App.svelte]"]
  node_views["Management Views"]
  node_appdata["App Data<br/>[apps.ts]"]
  node_kernelapi["Kernel Shell Bridge<br/>[shell.ts]"]
end

subgraph group_system["Android System"]
  node_android["Android Services"]
  node_kernel["Linux Kernel"]
  node_sysfs[("CPU Frequency Controls")]
end

node_owner(("Device Owner"))

node_owner -->|"manages"| node_webui
node_daemon -->|"starts"| node_monitor
node_daemon -->|"starts"| node_events
node_monitor -->|"loads probes"| node_ebpf
node_ebpf -->|"reports load"| node_cpu
node_ebpf -->|"reports frames"| node_frame
node_android -->|"provides state"| node_detect
node_monitor -->|"starts detection"| node_detect
node_monitor -->|"starts collection"| node_telemetry
node_monitor -->|"sends events"| node_events
node_events -->|"selects modes"| node_scheduler
node_config -->|"configures"| node_events
node_scheduler -->|"controls CLG"| node_governor
node_scheduler -->|"controls FAS"| node_fasmanager
node_fasmanager -->|"manages instance"| node_fasengine
node_fasengine -->|"processes frames"| node_framepipe
node_fasengine -->|"sets frequencies"| node_policy
node_policy -->|"writes limits"| node_sysfs
node_governor -->|"adapts frequencies"| node_kernel
node_kernel -->|"emits events"| node_ebpf
node_webui -->|"routes views"| node_views
node_views -->|"uses app data"| node_appdata
node_appdata -->|"queries packages"| node_kernelapi
node_kernelapi -->|"runs shell"| node_android
node_webui -.->|"reads status"| node_daemon

click node_daemon "https://github.com/aibeto/chiriscene/blob/main/src/main.rs"
click node_events "https://github.com/aibeto/chiriscene/blob/main/src/chiri/mod.rs"
click node_config "https://github.com/aibeto/chiriscene/blob/main/src/chiri/config.rs"
click node_monitor "https://github.com/aibeto/chiriscene/blob/main/src/monitor/mod.rs"
click node_cpu "https://github.com/aibeto/chiriscene/blob/main/src/monitor/cpu_monitor.rs"
click node_frame "https://github.com/aibeto/chiriscene/blob/main/src/monitor/fps_monitor.rs"
click node_detect "https://github.com/aibeto/chiriscene/blob/main/src/monitor/app_detect.rs"
click node_telemetry "https://github.com/aibeto/chiriscene/blob/main/src/monitor/telemetry.rs"
click node_ebpf "https://github.com/aibeto/chiriscene/blob/main/yumi-ebpf/src/main.rs"
click node_scheduler "https://github.com/aibeto/chiriscene/blob/main/src/chiri/scheduler.rs"
click node_governor "https://github.com/aibeto/chiriscene/blob/main/src/chiri/governor.rs"
click node_fasmanager "https://github.com/aibeto/chiriscene/blob/main/src/chiri/fas_manager.rs"
click node_fasengine "https://github.com/aibeto/chiriscene/blob/main/src/scheduler/fas/controller.rs"
click node_framepipe "https://github.com/aibeto/chiriscene/blob/main/src/scheduler/fas/frame_pipeline.rs"
click node_policy "https://github.com/aibeto/chiriscene/blob/main/src/scheduler/fas/policy_controller.rs"
click node_webui "https://github.com/aibeto/chiriscene/blob/main/webui/src/App.svelte"
click node_views "https://github.com/aibeto/chiriscene/blob/main/webui/src/views/OverviewView.svelte"
click node_appdata "https://github.com/aibeto/chiriscene/blob/main/webui/src/data/apps.ts"
click node_kernelapi "https://github.com/aibeto/chiriscene/blob/main/webui/src/kernel/shell.ts"

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_daemon,node_events,node_config toneBlue
class node_monitor,node_cpu,node_frame,node_detect,node_telemetry,node_ebpf toneAmber
class node_scheduler,node_governor,node_fasmanager,node_fasengine,node_framepipe,node_policy toneMint
class node_webui,node_views,node_appdata,node_kernelapi toneRose
class node_android,node_kernel,node_sysfs,node_owner toneIndigo
```

## Components

### Daemon Runtime

- [ChiRi Daemon](https://github.com/aibeto/chiriscene/blob/main/src/main.rs): `src/main.rs`
- [Event Loop](https://github.com/aibeto/chiriscene/blob/main/src/chiri/mod.rs): `src/chiri/mod.rs`
- [Runtime Config](https://github.com/aibeto/chiriscene/blob/main/src/chiri/config.rs): `src/chiri/config.rs`

### Monitoring

- [Monitor Coordinator](https://github.com/aibeto/chiriscene/blob/main/src/monitor/mod.rs): `src/monitor/mod.rs`
- [CPU Load Monitor](https://github.com/aibeto/chiriscene/blob/main/src/monitor/cpu_monitor.rs): `src/monitor/cpu_monitor.rs`
- [Frame Monitor](https://github.com/aibeto/chiriscene/blob/main/src/monitor/fps_monitor.rs): `src/monitor/fps_monitor.rs`
- [App And Screen Detection](https://github.com/aibeto/chiriscene/blob/main/src/monitor/app_detect.rs): `src/monitor/app_detect.rs`
- [System Telemetry](https://github.com/aibeto/chiriscene/blob/main/src/monitor/telemetry.rs): `src/monitor/telemetry.rs`
- [eBPF Probes](https://github.com/aibeto/chiriscene/blob/main/yumi-ebpf/src/main.rs): `yumi-ebpf/src/main.rs`

### Scheduling Control

- [Mode Scheduler](https://github.com/aibeto/chiriscene/blob/main/src/chiri/scheduler.rs): `src/chiri/scheduler.rs`
- [CLG Governor](https://github.com/aibeto/chiriscene/blob/main/src/chiri/governor.rs): `src/chiri/governor.rs`
- [FAS Manager](https://github.com/aibeto/chiriscene/blob/main/src/chiri/fas_manager.rs): `src/chiri/fas_manager.rs`
- [FAS Controller](https://github.com/aibeto/chiriscene/blob/main/src/scheduler/fas/controller.rs): `src/scheduler/fas/controller.rs`
- [Frame Policy](https://github.com/aibeto/chiriscene/blob/main/src/scheduler/fas/frame_pipeline.rs): `src/scheduler/fas/frame_pipeline.rs`
- [Frequency Policies](https://github.com/aibeto/chiriscene/blob/main/src/scheduler/fas/policy_controller.rs): `src/scheduler/fas/policy_controller.rs`

### Web Interface

- [Web UI](https://github.com/aibeto/chiriscene/blob/main/webui/src/App.svelte): `webui/src/App.svelte`
- [Management Views](https://github.com/aibeto/chiriscene/blob/main/webui/src/views/OverviewView.svelte): `webui/src/views/OverviewView.svelte`
- [App Data](https://github.com/aibeto/chiriscene/blob/main/webui/src/data/apps.ts): `webui/src/data/apps.ts`
- [Kernel Shell Bridge](https://github.com/aibeto/chiriscene/blob/main/webui/src/kernel/shell.ts): `webui/src/kernel/shell.ts`

### Android System

- **Android Services**
- **Linux Kernel**
- **CPU Frequency Controls**

### Other components

- **Device Owner**

## Connections

- Device Owner → Web UI: manages
- ChiRi Daemon → Monitor Coordinator: starts
- ChiRi Daemon → Event Loop: starts
- Monitor Coordinator → eBPF Probes: loads probes
- eBPF Probes → CPU Load Monitor: reports load
- eBPF Probes → Frame Monitor: reports frames
- Android Services → App And Screen Detection: provides state
- Monitor Coordinator → App And Screen Detection: starts detection
- Monitor Coordinator → System Telemetry: starts collection
- Monitor Coordinator → Event Loop: sends events
- Event Loop → Mode Scheduler: selects modes
- Runtime Config → Event Loop: configures
- Mode Scheduler → CLG Governor: controls CLG
- Mode Scheduler → FAS Manager: controls FAS
- FAS Manager → FAS Controller: manages instance
- FAS Controller → Frame Policy: processes frames
- FAS Controller → Frequency Policies: sets frequencies
- Frequency Policies → CPU Frequency Controls: writes limits
- CLG Governor → Linux Kernel: adapts frequencies
- Linux Kernel → eBPF Probes: emits events
- Web UI → Management Views: routes views
- Management Views → App Data: uses app data
- App Data → Kernel Shell Bridge: queries packages
- Kernel Shell Bridge → Android Services: runs shell
- Web UI → ChiRi Daemon: reads status
