# thedjchi/shizuku architecture

> Architecture diagram of the GitHub repository thedjchi/shizuku, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thedjchi/shizuku
- Repository: https://github.com/thedjchi/shizuku

## Overview

##### Project type and purpose
- This is an Android multi-module, open-source system tool (not a typical web or full-stack app). Its goal is to let ordinary Android apps call protected system APIs by proxying their Binder IPC through a privileged “Shizuku Server” process that runs under root or ADB credentials.

##### File-structure analysis
- Top-level Gradle modules:
- api – definitions of the public API for client apps (Binder wrapper interfaces)
- common – shared utilities and manifest stubs used by other modules
- manager – the Android UI app where users install/configure Shizuku, handle pairing, view status, and launch server via ADB or root
- server – the standalone service (with Java/Kotlin and JNI/C++ code) that runs as root/ADB, implements a Binder endpoint, forwards transactions to the system server, and returns results
- shell – an optional module offering a shell-based launcher and integration for scripts
- starter – a tiny broadcast-receiver / service module to auto-start Shizuku on boot or on demand
- Each module has its own AndroidManifest, build.gradle, source folders, and—for server—native JNI code under jni/.

##### Key insights from README
- Shizuku works by launching a root/ADB process (the server) that registers a Binder service.
- Client apps use `moe.shizuku.*` API to bind to that service.
- The server uses `transactRemote()` to forward calls into the Android system server (e.g., PackageManagerService).
- There is pairing logic (ADB pairing tutorial) and permission checks for hidden APIs.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client-side modules
    subgraph "Client-Side"
        direction TB
        API["API Library Module"]:::client
        Common["Common Utilities Module"]:::util
        ClientApp["Client App"]:::client
        ManagerApp["Shizuku Manager App"]:::client
    end

    %% Service-side modules
    subgraph "Service-Side"
        direction TB
        StarterMod["Starter Module"]:::bootstrap
        ServerProc["Shizuku Server Process"]:::service
        ShellMod["Shell Module"]:::client
    end

    %% System layer
    subgraph "Android System"
        direction TB
        SystemServer["Android System Server"]:::system
    end

    %% Bootstrap launcher
    ADB["ADB Daemon / Root Shell"]:::bootstrap

    %% Flows
    ManagerApp -->|"startService() / Intent"| StarterMod
    ADB -->|"root/ADB exec"| ServerProc
    StarterMod -->|"root/ADB exec"| ServerProc

    ServerProc -->|"Binder service register"| ShizukuService["ShizukuService"]:::service
    ClientApp -->|"bindService() / Binder IPC"| ShizukuService
    ManagerApp -->|"bindService() / Binder IPC"| ShizukuService

    ClientApp -->|"transactRemote() / Binder IPC"| ServerProc
    ServerProc -->|"Binder IPC"| SystemServer
    SystemServer -->|"result"| ServerProc
    ServerProc -->|"result"| ClientApp

    ManagerApp -->|"monitor status"| ServerProc

    API --> ClientApp
    Common --> API
    Common --> ManagerApp

    ShellMod -->|"CLI launch"| ServerProc

    %% Click events
    click API "https://github.com/thedjchi/shizuku/tree/master/api/"
    click Common "https://github.com/thedjchi/shizuku/tree/master/common/"
    click ManagerApp "https://github.com/thedjchi/shizuku/tree/master/manager/"
    click ManagerApp "https://github.com/thedjchi/shizuku/blob/master/manager/src/main/java/moe/shizuku/manager/MainActivity.kt"
    click ManagerApp "https://github.com/thedjchi/shizuku/blob/master/manager/src/main/java/moe/shizuku/manager/ShizukuApplication.kt"
    click ManagerApp "https://github.com/thedjchi/shizuku/blob/master/manager/src/main/java/moe/shizuku/manager/adb/AdbPairingClient.kt"
    click ManagerApp "https://github.com/thedjchi/shizuku/blob/master/manager/src/main/java/moe/shizuku/manager/receiver/BootCompleteReceiver.kt"
    click ServerProc "https://github.com/thedjchi/shizuku/tree/master/server/"
    click ServerProc "https://github.com/thedjchi/shizuku/blob/master/server/src/main/java/rikka/shizuku/server/ShizukuService.java"
    click ServerProc "https://github.com/thedjchi/shizuku/blob/master/server/src/main/java/rikka/shizuku/server/BinderSender.java"
    click ShellMod "https://github.com/thedjchi/shizuku/tree/master/shell/"
    click StarterMod "https://github.com/thedjchi/shizuku/tree/master/starter/"
    click StarterMod "https://github.com/thedjchi/shizuku/blob/master/starter/src/main/java/moe/shizuku/starter/ServiceStarter.java"

    %% Styles
    classDef client fill:#cce5ff,stroke:#3399ff,color:#000
    classDef service fill:#d4edda,stroke:#28a745,color:#000
    classDef system fill:#e2e3e5,stroke:#6c757d,color:#000
    classDef bootstrap fill:#ffe5cc,stroke:#ff9933,color:#000
    classDef util fill:#f0f0f0,stroke:#bbbbbb,color:#333
```
