# viarotel-org/escrcpy architecture

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

- Interactive diagram: https://gitdiagram.com/viarotel-org/escrcpy
- Repository: https://github.com/viarotel-org/escrcpy

## Overview

##### Main Components
- Electron Main Process: Represented by files in the “electron” and “control/electron” directories (e.g., main.js, preload.js, and IPC modules). This forms the backbone of the desktop application.
- Renderer/UI Process: The “src” directory holds the Vue-based frontend (components, pages, layouts, plugins). Also note the “control” folder that provides some UI elements.
- IPC & Communication Channels: In “electron/ipc” and its subdirectories. These modules handle inter-process communication (IPC) between the main and renderer processes.
- Device & External Services Integration: Modules and helpers under “electron/exposes/adb”, “electron/exposes/scrcpy”, “electron/exposes/gnirehtet”, and similar directories abstract interactions with scrcpy, adb, and gnirehtet. Also incorporate native configurations and resources for cross-platform support in “electron/resources/extra/”.
- Configuration & Store: The “src/store” and “src/configs” directories manage application state and preferences, while “electron/helpers/store.js” and similar files may handle persistent configuration.

##### Relationships and Interactions
- Modular Device Managers: Show how the native modules (adb and scrcpy helpers) are invoked by the Electron main process to interact with Android devices.
- Plugin and Extension Layers: Within the renderer, plugins (like vue-screen, Element Plus integrations) and additional UI components are connected to core UI functionalities.

##### Architectural Patterns and Technologies
- Separation of Concerns: Clearly separate the Electron main process (back-end core, device operations) from the renderer (UI and user interaction), capturing the typical Electron “two-process” architecture.
- Modular Design & Extensibility: With distinct directories for “exposes”, “helpers”, “ipc” and “plugins”, the project embraces a modular pattern where each functionality (screen mirroring, reverse tethering, file management) is encapsulated.
- Technology Stack: Electron (for desktop application framework), Vue (for frontend/UI), Element Plus (UI library), along with integrations with scrcpy and gnirehtet for device control.

##### Essential Elements
- For each primary component (Electron main, Vue UI, device integration layers):
- Annotations for important external libraries (scrcpy, gnirehtet, adbkit, Element Plus, etc.) where they interact with the system.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Renderer/UI Process
    subgraph "Renderer/UI Process"
        UI_Vue["Vue Renderer/UI (src)"]:::frontend
        UI_Control["Control App (control/App.vue)"]:::frontend
    end

    %% IPC Bridge
    subgraph "IPC Bridge"
        IPC_Node["IPC Module (electron/ipc/index.js)"]:::ipc
        IPC_Events["IPC Events (control/electron/events)"]:::ipc
    end

    %% Electron Main Process
    subgraph "Electron Main Process"
        EM_Electron["Main Electron (electron/main.js)"]:::electron
        EM_Control["Control Electron (control/electron/main.js)"]:::electron
    end

    %% Device & External Services Integration
    subgraph "Device & External Services Integration"
        ADB["ADB Modules (electron/exposes/adb)"]:::integration
        scrcpy_Ex["scrcpy Exposes (electron/exposes/scrcpy)"]:::integration
        scrcpy_Cfg["scrcpy Config (electron/configs/scrcpy)"]:::integration
        gnirehtet_Ex["gnirehtet Exposes (electron/exposes/gnirehtet)"]:::integration
        gnirehtet_Cfg["gnirehtet Config (electron/configs/gnirehtet)"]:::integration
        Resources["Extra Resources (electron/resources/extra)"]:::integration
    end

    %% Configuration & Store
    subgraph "Configuration & Store"
        Vue_Store["Vue Store (src/store)"]:::config
        Vue_Config["Vue Configs (src/configs)"]:::config
        Persist_Config["Persistent Config Helper (electron/helpers/store.js)"]:::config
    end

    %% Connections: UI to IPC
    UI_Vue -->|"sends command"| IPC_Node
    UI_Control -->|"triggers event"| IPC_Node

    %% Connections: IPC to Electron Main
    IPC_Node -->|"relays IPC event"| EM_Electron
    IPC_Events -->|"handles specific events"| EM_Control

    %% Connections: Electron Main to Device Integrations
    EM_Electron -->|"invokes"| ADB
    EM_Electron -->|"invokes"| scrcpy_Ex
    EM_Control -->|"configures"| scrcpy_Cfg
    EM_Electron -->|"invokes"| gnirehtet_Ex
    EM_Control -->|"configures"| gnirehtet_Cfg
    EM_Electron -->|"utilizes"| Resources

    %% Connections: Configuration & Store integration
    UI_Vue ---|"reads/writes"| Vue_Store
    UI_Control ---|"reads/writes"| Vue_Config
    EM_Electron ---|"persists data"| Persist_Config

    %% Click Events for Renderer/UI Process
    click UI_Vue "https://github.com/viarotel-org/escrcpy/tree/main/src"
    click UI_Control "https://github.com/viarotel-org/escrcpy/blob/main/control/App.vue"

    %% Click Events for IPC Bridge
    click IPC_Node "https://github.com/viarotel-org/escrcpy/blob/main/electron/ipc/index.js"
    click IPC_Events "https://github.com/viarotel-org/escrcpy/tree/main/control/electron/events"

    %% Click Events for Electron Main Process
    click EM_Electron "https://github.com/viarotel-org/escrcpy/blob/main/electron/main.js"
    click EM_Control "https://github.com/viarotel-org/escrcpy/blob/main/control/electron/main.js"

    %% Click Events for Device & External Services Integration
    click ADB "https://github.com/viarotel-org/escrcpy/tree/main/electron/exposes/adb"
    click scrcpy_Ex "https://github.com/viarotel-org/escrcpy/tree/main/electron/exposes/scrcpy"
    click scrcpy_Cfg "https://github.com/viarotel-org/escrcpy/tree/main/electron/configs/scrcpy"
    click gnirehtet_Ex "https://github.com/viarotel-org/escrcpy/tree/main/electron/exposes/gnirehtet"
    click gnirehtet_Cfg "https://github.com/viarotel-org/escrcpy/tree/main/electron/configs/gnirehtet"
    click Resources "https://github.com/viarotel-org/escrcpy/tree/main/electron/resources/extra"

    %% Click Events for Configuration & Store
    click Vue_Store "https://github.com/viarotel-org/escrcpy/tree/main/src/store"
    click Vue_Config "https://github.com/viarotel-org/escrcpy/tree/main/src/configs"
    click Persist_Config "https://github.com/viarotel-org/escrcpy/blob/main/electron/helpers/store.js"

    %% Styles
    classDef frontend fill:#bbf,stroke:#333,stroke-width:2px;
    classDef electron fill:#f9d,stroke:#333,stroke-width:2px;
    classDef ipc fill:#dfd,stroke:#333,stroke-width:2px;
    classDef integration fill:#fdd,stroke:#333,stroke-width:2px;
    classDef config fill:#ffd,stroke:#333,stroke-width:2px;
```
