# yume-chan/ya-webadb architecture

> Architecture diagram of the GitHub repository yume-chan/ya-webadb, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yume-chan/ya-webadb
- Repository: https://github.com/yume-chan/ya-webadb

## Overview

##### Main Components

a. Core ADB Implementation Layer
- Authentication & Crypto (from libraries/adb/src/daemon)
- Command Processing (from libraries/adb/src/commands)
- Device Management (from libraries/adb/src/device-observer)
- Transport Layer (from libraries/adb/src/daemon/transport)

b. Platform-Specific Adapters (Top Layer)
- WebUSB Adapter (libraries/adb-daemon-webusb)
- Node.js TCP Adapter (libraries/adb-server-node-tcp)
- Web Credentials Handler (libraries/adb-credential-web)

c. Feature Modules (Right Side)
- Scrcpy Implementation (libraries/scrcpy)
- Android Binary Commands (libraries/android-bin)
- AOA Support (libraries/aoa)

d. Utility Layers (Left Side)
- Stream Handling (libraries/stream-extra)
- Event System (libraries/event)
- Struct Processing (libraries/struct)
- PCM Player (libraries/pcm-player)

##### Connection Flow

- User Interface → Platform Adapters
- Platform Adapters → ADB Core
- ADB Core → Feature Modules
- Utility Layers ↔ All Components

##### Specific Implementation Details

- Scrcpy Decoders:
- TinyH264 Decoder
- WebCodecs Decoder
- Command Types:
- Shell Commands
- File Transfer
- Device Control
- Authentication Methods
- Stream Processing

##### Cross-Platform Support

A section showing supported platforms:
- Chromium Browsers
- Node.js
- Electron
- Chrome for Android

##### External Interfaces

External connection points:
- USB Device Connections
- TCP/IP Connections
- WebUSB API
- Android Debug Bridge Protocol

##### Version Support

A small section showing supported ADB protocol versions and compatibility layers.

Key Considerations:

##### Maintain Clear Hierarchy
- Layered architecture from platform-specific to core implementation
- Modular nature of the system

##### Interfaces
- Communication points between modules
- Clear boundaries between platform-specific and platform-agnostic code

##### Important Details
- Protocol versions
- Key features
- Support matrix

##### Keep it Readable
- Use consistent spacing and alignment
- Clear labels
- Related components together

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Platform
        WebUSB["WebUSB Adapter"]
        NodeTCP["Node.js TCP Adapter"]
        WebCred["Web Credentials Handler"]
    end

    subgraph Core["ADB Core Implementation"]
        Auth["Authentication & Crypto"]
        CmdProc["Command Processing"]
        DevMgmt["Device Management"]
        Transport["Transport Layer"]
    end

    subgraph Features
        Scrcpy["Scrcpy Implementation"]
        AndroidBin["Android Binary Commands"]
        AOA["AOA Support"]
    end

    subgraph Utilities
        Stream["Stream Handling"]
        Event["Event System"]
        Struct["Struct Processing"]
        PCM["PCM Player"]
    end

    subgraph Decoders
        TinyH264["TinyH264 Decoder"]
        WebCodecs["WebCodecs Decoder"]
    end

    %% Platform to Core connections
    WebUSB --> Auth
    NodeTCP --> Auth
    WebCred --> Auth

    %% Core internal connections
    Auth --> Transport
    Transport --> CmdProc
    CmdProc --> DevMgmt

    %% Core to Features connections
    DevMgmt --> Scrcpy
    DevMgmt --> AndroidBin
    DevMgmt --> AOA

    %% Decoder connections
    Scrcpy --> TinyH264
    Scrcpy --> WebCodecs

    %% Utility connections
    Stream --> Transport
    Event --> DevMgmt
    Struct --> CmdProc
    PCM --> Scrcpy

    %% Click events for component mapping
    click Auth "https://github.com/yume-chan/ya-webadb/tree/main/libraries/adb/src/daemon/"
    click CmdProc "https://github.com/yume-chan/ya-webadb/tree/main/libraries/adb/src/commands/"
    click DevMgmt "https://github.com/yume-chan/ya-webadb/blob/main/libraries/adb/src/device-observer.ts"
    click Transport "https://github.com/yume-chan/ya-webadb/blob/main/libraries/adb/src/daemon/transport.ts"
    click WebUSB "https://github.com/yume-chan/ya-webadb/tree/main/libraries/adb-daemon-webusb/"
    click NodeTCP "https://github.com/yume-chan/ya-webadb/tree/main/libraries/adb-server-node-tcp/"
    click WebCred "https://github.com/yume-chan/ya-webadb/tree/main/libraries/adb-credential-web/"
    click Scrcpy "https://github.com/yume-chan/ya-webadb/tree/main/libraries/scrcpy/"
    click AndroidBin "https://github.com/yume-chan/ya-webadb/tree/main/libraries/android-bin/"
    click AOA "https://github.com/yume-chan/ya-webadb/tree/main/libraries/aoa/"
    click Stream "https://github.com/yume-chan/ya-webadb/tree/main/libraries/stream-extra/"
    click Event "https://github.com/yume-chan/ya-webadb/tree/main/libraries/event/"
    click Struct "https://github.com/yume-chan/ya-webadb/tree/main/libraries/struct/"
    click PCM "https://github.com/yume-chan/ya-webadb/tree/main/libraries/pcm-player/"
    click TinyH264 "https://github.com/yume-chan/ya-webadb/tree/main/libraries/scrcpy-decoder-tinyh264/"
    click WebCodecs "https://github.com/yume-chan/ya-webadb/tree/main/libraries/scrcpy-decoder-webcodecs/"

    classDef platform fill:#90EE90
    classDef core fill:#87CEEB
    classDef feature fill:#FFA500
    classDef utility fill:#D3D3D3
    classDef decoder fill:#FFB6C1

    class WebUSB,NodeTCP,WebCred platform
    class Auth,CmdProc,DevMgmt,Transport core
    class Scrcpy,AndroidBin,AOA feature
    class Stream,Event,Struct,PCM utility
    class TinyH264,WebCodecs decoder
```
