# akichase/scrcpy-mask architecture

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

- Interactive diagram: https://gitdiagram.com/akichase/scrcpy-mask
- Repository: https://github.com/akichase/scrcpy-mask

## Overview

##### Project type and purpose
- This is a cross-platform desktop control client built with Tauri (Rust) on the backend and Vue 3/Vite on the frontend.
- Its sole purpose is to implement the Scrcpy control protocol (no built-in video mirroring) and allow millisecond-level mouse/keyboard mapping to Android devices (physical or emulator), optionally using an external LAN mirroring service like ScreenStream.

##### File structure
- Top-level:
- package.json, vite.config.ts, tsconfig.json → front-end build & dev config
- public/index.html, src/… → Vue 3 single-file components + TypeScript code for UI, routing, state, styles
- src-tauri/ → Tauri Rust backend + resource files
- src-tauri/Cargo.toml, build.rs → Rust project definition and custom build steps
- src-tauri/src/*.rs → core Rust modules:
— adb.rs: ADB device discovery & connection
— client.rs, socket.rs, share.rs, control_msg.rs, scrcpy_mask_cmd.rs: Scrcpy control protocol implementation & IPC
— main.rs & lib.rs: tauri app initialization, command registration
- publish.js, .github/workflows/publish.yml → CI/CD & release automation

##### Key README insights
- Emphasis on millisecond-level input control via Tauri command bindings.
- Supports both wired (ADB) and wireless ADB over TCP.
- Optional integration with ScreenStream for real-time video overlay.
- External control API exposed via WebSocket.
- Configuration import/export of key mappings and macros.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Application"
        direction TB
        FM1["public/index.html"]:::frontend
        FM2["src/main.ts"]:::frontend
        FM3["src/App.vue"]:::frontend
        FM4["src/router.ts"]:::frontend
        FM5["vite.config.ts"]:::frontend

        subgraph "UI Modules"
            direction TB
            U1["Device.vue"]:::frontend
            U2["Mask.vue"]:::frontend
            U3["ScreenStream.vue"]:::frontend
            U4["KeyBoard.vue"]:::frontend
            U5["KeyCommon.vue"]:::frontend
            U6["KeyFire.vue"]:::frontend
            U7["KeyInfo.vue"]:::frontend
            U8["KeyObservation.vue"]:::frontend
            U9["KeySetting.vue"]:::frontend
            U10["KeySight.vue"]:::frontend
            U11["KeySkill.vue"]:::frontend
            U12["KeySteeringWheel.vue"]:::frontend
            U13["KeySwipe.vue"]:::frontend
            U14["About.vue"]:::frontend
            U15["Basic.vue"]:::frontend
            U16["Data.vue"]:::frontend
            U17["Mask.vue (Settings)"]:::frontend
            U18["Setting.vue"]:::frontend
            U19["Header.vue"]:::frontend
            U20["Sidebar.vue"]:::frontend
        end

        subgraph "State & Config"
            direction TB
            S1["src/store/global.ts"]:::frontend
            S2["src/store/keyboard.ts"]:::frontend
            S3["src/storeLoader.ts"]:::frontend
            S4["src/i18n/index.ts"]:::frontend
            S5["en-US.json"]:::frontend
            S6["zh-CN.json"]:::frontend
            S7["tsconfig.json"]:::frontend
            S8["tsconfig.node.json"]:::frontend
            S9["key-mapping config"]:::frontend
        end

        subgraph "IPC & Commands"
            direction TB
            C1["invoke.ts"]:::frontend
            C2["KeyToCodeMap.ts"]:::frontend
            C3["UIEventsCode.ts"]:::frontend
            C4["android.ts"]:::frontend
            C5["controlMsg.ts"]:::frontend
            C6["scrcpyMaskCmd.ts"]:::frontend
            C7["websocket.ts"]:::frontend
            C8["hotkey.ts"]:::frontend
        end
    end

    %% Tauri IPC Layer
    subgraph "Tauri IPC Layer"
        direction TB
        IPC1["Tauri invoke"]:::backend
        IPC2["WebSocket client ↔ server"]:::backend
    end

    %% Rust Backend
    subgraph "Rust Backend"
        direction TB
        subgraph "Project & Build"
            direction TB
            R1["Cargo.toml"]:::backend
            R2["build.rs"]:::backend
            R3["tauri.conf.json"]:::backend
        end
        subgraph "Core Modules"
            direction TB
            R4["adb.rs"]:::backend
            R5["client.rs"]:::backend
            R6["control_msg.rs"]:::backend
            R7["scrcpy_mask_cmd.rs"]:::backend
            R8["share.rs"]:::backend
            R9["socket.rs"]:::backend
        end
        subgraph "Resource Embedding"
            direction TB
            R10["binary.rs"]:::backend
            R11["resource.rs"]:::backend
            R12["default-key-config.json"]:::backend
            R13["capabilities/default.json"]:::backend
            R14["scrcpy-mask-server-v2.4"]:::backend
        end
        subgraph "App Initialization"
            direction TB
            R15["main.rs"]:::backend
            R16["lib.rs"]:::backend
        end
    end

    %% External Systems
    subgraph "External Systems"
        direction TB
        E1["Android Device/Emulator"]:::external
        E2["ScreenStream Server"]:::external
    end

    %% Data Flows
    U1 -->|UI Event| IPC1
    U2 -->|UI Event| IPC1
    C1 -->|invoke| IPC1
    IPC1 -->|calls| R15
    R15 --> R4
    R4 -->|ADB TCP| E1
    R5 --> R4
    R6 --> R5
    R7 --> R6
    R8 --> R5
    R9 --> R4
    R15 --> R10
    R11 --> R12
    R11 --> R13
    R11 --> R14
    IPC2 <-->|"WebSocket"| C7
    C7 <-->|"WebSocket"| R15
    U3 --> E2
    E2 --> U2

    %% Click events
    click FM1 "https://github.com/akichase/scrcpy-mask/blob/master/public/index.html"
    click FM2 "https://github.com/akichase/scrcpy-mask/blob/master/src/main.ts"
    click FM3 "https://github.com/akichase/scrcpy-mask/blob/master/src/App.vue"
    click FM4 "https://github.com/akichase/scrcpy-mask/blob/master/src/router.ts"
    click FM5 "https://github.com/akichase/scrcpy-mask/blob/master/vite.config.ts"
    click U1 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/Device.vue"
    click U2 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/Mask.vue"
    click U3 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/ScreenStream.vue"
    click U4 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/keyboard/KeyBoard.vue"
    click U5 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/keyboard/KeyCommon.vue"
    click U6 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/keyboard/KeyFire.vue"
    click U7 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/keyboard/KeyInfo.vue"
    click U8 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/keyboard/KeyObservation.vue"
    click U9 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/keyboard/KeySetting.vue"
    click U10 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/keyboard/KeySight.vue"
    click U11 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/keyboard/KeySkill.vue"
    click U12 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/keyboard/KeySteeringWheel.vue"
    click U13 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/keyboard/KeySwipe.vue"
    click U14 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/setting/About.vue"
    click U15 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/setting/Basic.vue"
    click U16 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/setting/Data.vue"
    click U17 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/setting/Mask.vue"
    click U18 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/setting/Setting.vue"
    click U19 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/Header.vue"
    click U20 "https://github.com/akichase/scrcpy-mask/blob/master/src/components/Sidebar.vue"
    click S1 "https://github.com/akichase/scrcpy-mask/blob/master/src/store/global.ts"
    click S2 "https://github.com/akichase/scrcpy-mask/blob/master/src/store/keyboard.ts"
    click S3 "https://github.com/akichase/scrcpy-mask/blob/master/src/storeLoader.ts"
    click S4 "https://github.com/akichase/scrcpy-mask/blob/master/src/i18n/index.ts"
    click S5 "https://github.com/akichase/scrcpy-mask/blob/master/src/i18n/en-US.json"
    click S6 "https://github.com/akichase/scrcpy-mask/blob/master/src/i18n/zh-CN.json"
    click S7 "https://github.com/akichase/scrcpy-mask/blob/master/tsconfig.json"
    click S8 "https://github.com/akichase/scrcpy-mask/blob/master/tsconfig.node.json"
    click C1 "https://github.com/akichase/scrcpy-mask/blob/master/invoke.ts"
    click C2 "https://github.com/akichase/scrcpy-mask/blob/master/src/frontcommand/KeyToCodeMap.ts"
    click C3 "https://github.com/akichase/scrcpy-mask/blob/master/src/frontcommand/UIEventsCode.ts"
    click C4 "https://github.com/akichase/scrcpy-mask/blob/master/src/frontcommand/android.ts"
    click C5 "https://github.com/akichase/scrcpy-mask/blob/master/src/frontcommand/controlMsg.ts"
    click C6 "https://github.com/akichase/scrcpy-mask/blob/master/src/frontcommand/scrcpyMaskCmd.ts"
    click C7 "https://github.com/akichase/scrcpy-mask/blob/master/src/websocket.ts"
    click C8 "https://github.com/akichase/scrcpy-mask/blob/master/src/hotkey.ts"
    click R1 "https://github.com/akichase/scrcpy-mask/blob/master/src-tauri/Cargo.toml"
    click R2 "https://github.com/akichase/scrcpy-mask/blob/master/src-tauri/build.rs"
    click R3 "https://github.com/akichase/scrcpy-mask/blob/master/src-tauri/tauri.conf.json"
    click R4 "https://github.com/akichase/scrcpy-mask/blob/master/src-tauri/src/adb.rs"
    click R5 "https://github.com/akichase/scrcpy-mask/blob/master/src-tauri/src/client.rs"
    click R6 "https://github.com/akichase/scrcpy-mask/blob/master/src-tauri/src/control_msg.rs"
    click R7 "https://github.com/akichase/scrcpy-mask/blob/master/src-tauri/src/scrcpy_mask_cmd.rs"
    click R8 "https://github.com/akichase/scrcpy-mask/blob/master/src-tauri/src/share.rs"
    click R9 "https://github.com/akichase/scrcpy-mask/blob/master/src-tauri/src/socket.rs"
    click R10 "https://github.com/akichase/scrcpy-mask/blob/master/src-tauri/src/binary.rs"
    click R11 "https://github.com/akichase/scrcpy-mask/blob/master/src-tauri/src/resource.rs"
    click R12 "https://github.com/akichase/scrcpy-mask/blob/master/src-tauri/resource/default-key-config.json"
    click R13 "https://github.com/akichase/scrcpy-mask/blob/master/src-tauri/capabilities/default.json"
    click R14 "https://github.com/akichase/scrcpy-mask/blob/master/src-tauri/resource/scrcpy-mask-server-v2.4"
    click R15 "https://github.com/akichase/scrcpy-mask/blob/master/src-tauri/src/main.rs"
    click R16 "https://github.com/akichase/scrcpy-mask/blob/master/src-tauri/src/lib.rs"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef data fill:#FFFACD,stroke:#333,stroke-width:1px
```
