# maxwellos/web-scrcpy architecture

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

- Interactive diagram: https://gitdiagram.com/maxwellos/web-scrcpy
- Repository: https://github.com/maxwellos/web-scrcpy

## Overview

##### Main Components
- Frontend/UI Layer:
- This is primarily located within the “src” directory, with the top-level “App.vue”, various views (e.g., DeviceView.vue), and numerous Vue components under “src/components/Device” and “src/components/Scrcpy”.
- The UI layer manages user interaction (mouse/keyboard events), screen viewing (video container), device information, and control features (screenshot, screen recording, full-screen mode).

- Scrcpy Integration Layer:
- Found within “src/components/Scrcpy”, these modules (e.g., adb-client.ts, recorder.ts, scrcpy-state.ts) encapsulate the interfaces to the scrcpy functionality. They handle aspects like connecting to the Android device, managing video streams, processing input events, and maintaining state.
- “public/scrcpy-server-v2.6.1” which is the scrcpy server binary that the frontend communicates with to mirror the Android device’s screen.

- Configuration and Build Tools:
- The “package.json”, “vite.config.ts”, “tsconfig.json” files indicate the use of modern JavaScript toolchain practices.
- The “plugins” directory (with custom loaders) and GitHub Actions workflows present in “.github/workflows” manage automation and build/deployment, which are also important to capture in the overall system architecture.

##### Component Relationships/Interactions
- The User accesses the application via a browser, which loads the “index.html” from the project’s root along with other assets from the “public” directory.
- The Vue-based SPA (initiated from src/App.vue) renders the user interface, delegating functionality across various Vue components.
- Device-specific components (within “src/components/Device”) gather and display device data, initiate control commands, and interact with the scrcpy components.
- The scrcpy-related modules (inside “src/components/Scrcpy”) establish communications (potentially via WebSockets or similar protocols) between the browser-based UI and the scrcpy server binary provided in the public folder.
- The overall data flow is as follows: User input in the UI ==> processed by Vue components ==> forwarded to the scrcpy module ==> communicated to the scrcpy server/binary ==> executes corresponding commands on the connected Android device, with video/data feedback flowing back through the same chain.

##### Architectural Patterns
- Component-based Design:
- The use of Vue components (segmented under “Device” and “Scrcpy”) reflects a clear separation of concerns.
- Each component handles a specific aspect of the overall functionality (e.g., battery info, device logcat, file management, etc.).

- SPA with Asynchronous Data Flow:
- Asynchronous interactions between user commands and device actions, likely using promise-based or event-driven patterns.

- Integration of Native/External Tooling:
- The inclusion of the scrcpy server binary and integration scripts under “public” and “src/components/Scrcpy” shows a blend between web technologies and native device control.

##### Relevant Technologies and Frameworks
- Vue.js (for the SPA and component structure)
- Vite (as the build tool, as seen in vite.config.ts)
- TypeScript (as indicated by tsconfig.json and .ts files)
- GitHub Actions (for CI/CD workflows, visible in the .github directory)
- Custom plugins (binary-loader.js, md-loader.js)
- scrcpy (via the scrcpy-server binary and related integration modules)

## Diagram (Mermaid)

```mermaid
graph TD
    %% External User
    U["User (Browser)"]:::external

    %% Frontend UI Layer
    subgraph "Frontend UI Layer"
        A["App.vue (Vue SPA)"]:::ui
        DV["Device View (DeviceView.vue)"]:::ui
        AL["Abstract List (AbstractList.vue)"]:::ui
        DC["Device Components"]:::ui
    end

    %% Scrcpy Integration Layer
    subgraph "Scrcpy Integration Layer"
        SI["Scrcpy Components"]:::scrcpy
        SSB["Scrcpy Server Binary"]:::scrcpy
    end

    %% Build & Deployment Tools
    subgraph "Build & Deployment Tools"
        P["Package.json"]:::build
        VC["Vite Config (vite.config.ts)"]:::build
        TS["TSConfig (tsconfig.json)"]:::build
        TSN["TSConfig Node (tsconfig.node.json)"]:::build
        PL["Plugins"]:::build
        BL["Binary Loader Plugin (binary-loader.js)"]:::build
        MD["MD Loader Plugin (md-loader.js)"]:::build
        CI["CI/CD Workflows"]:::build
        DW["Deploy Workflow (deploy.yml)"]:::build
    end

    %% Connections: Data Flow
    U -->|"loads"| A
    A -->|"routes-to"| DV
    A -->|"routes-to"| AL
    DV -->|"renders"| DC
    AL -->|"renders"| DC
    DC -->|"sendsControl"| SI
    SI -->|"executes"| SSB
    SSB -->|"streamsBack"| SI
    SI -->|"updatesUI"| DC

    %% Support arrows from Build & Deployment Tools
    P ---|"builds"| A
    VC ---|"builds"| A
    TS ---|"builds"| A
    TSN ---|"builds"| A
    PL ---|"supports"| A
    PL ---|"supports"| SI
    BL ---|"loads"| PL
    MD ---|"loads"| PL
    CI ---|"automates"| A
    CI ---|"automates"| SI
    DW ---|"deploys"| A

    %% Click Events
    click A "https://github.com/maxwellos/web-scrcpy/blob/main/src/App.vue"
    click DV "https://github.com/maxwellos/web-scrcpy/blob/main/src/views/DeviceView.vue"
    click AL "https://github.com/maxwellos/web-scrcpy/blob/main/src/views/AbstractList.vue"
    click DC "https://github.com/maxwellos/web-scrcpy/tree/main/src/components/Device"
    click SI "https://github.com/maxwellos/web-scrcpy/tree/main/src/components/Scrcpy"
    click SSB "https://github.com/maxwellos/web-scrcpy/blob/main/public/scrcpy-server-v2.6.1"
    click P "https://github.com/maxwellos/web-scrcpy/blob/main/package.json"
    click VC "https://github.com/maxwellos/web-scrcpy/blob/main/vite.config.ts"
    click TS "https://github.com/maxwellos/web-scrcpy/blob/main/tsconfig.json"
    click TSN "https://github.com/maxwellos/web-scrcpy/blob/main/tsconfig.node.json"
    click PL "https://github.com/maxwellos/web-scrcpy/tree/main/plugins"
    click BL "https://github.com/maxwellos/web-scrcpy/blob/main/plugins/binary-loader.js"
    click MD "https://github.com/maxwellos/web-scrcpy/blob/main/plugins/md-loader.js"
    click CI "https://github.com/maxwellos/web-scrcpy/tree/main/.github/workflows"
    click DW "https://github.com/maxwellos/web-scrcpy/blob/main/.github/workflows/deploy.yml"

    %% Styles
    classDef external fill:#ff9,stroke:#333,stroke-width:2px;
    classDef ui fill:#f9f,stroke:#333,stroke-width:2px;
    classDef scrcpy fill:#cff,stroke:#333,stroke-width:2px;
    classDef build fill:#fcf,stroke:#333,stroke-width:2px;
```
