# asish231/droidhelper architecture

> Architecture diagram of the GitHub repository asish231/droidhelper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/asish231/droidhelper
- Repository: https://github.com/asish231/droidhelper

## Overview

1. **Repository shape**
   - This is a very small Go CLI project, not a multi-service system.
   - Most architecture lives in a single entrypoint, `main.go`, with supporting launch/package files and prebuilt binaries in `dist/`.

2. **Core role of the app**
   - `DroidHelper` is a wrapper/orchestrator around two external Android tools: `adb` and `scrcpy`.
   - It does not implement mirroring itself; it coordinates discovery, pairing, connection, and final launch.

3. **Primary boundary: in-process CLI vs external executables**
   - The Go program is the control plane.
   - `adb` handles device discovery, pairing, and connection state.
   - `scrcpy` handles screen/audio mirroring and device control.
   - This boundary is the key architectural diagram line.

4. **Interactive user flow**
   - The app is a guided terminal experience.
   - The user chooses connection mode and audio mode, then the program translates those choices into the correct external commands.
   - There is no GUI layer in the current repository.

5. **Dependency/bootstrap subsystem**
   - At startup the helper checks whether `adb` and `scrcpy` are installed.
   - If tools are missing, it prompts the user to install them.
   - The README indicates this bootstrap is currently macOS-first and expects Homebrew for installation.

6. **USB connection path**
   - In USB mode, the app starts the ADB server and inspects `adb devices -l`.
   - It selects a connected device automatically when possible, or asks the user to choose among multiple devices.
   - The selected device serial becomes the target for the final `scrcpy` invocation.

7. **Wireless debugging path**
   - In wireless mode, the app guides the user through Android Wireless Debugging / pairing-code workflow.
   - It uses `adb mdns services` to discover connect endpoints, `adb pair` for pairing, and `adb connect` for attaching to the device over the network.
   - It also performs lightweight reachability checks with `ping` and `nc -vz` before attempting connection.

8. **Audio-mode selection as a launch-time policy**
   - Audio is treated as a user-selected launch policy, not a separate subsystem.
   - The app supports no audio, normal output audio, and voice-call mode.
   - These map to different `scrcpy` flags, and voice-call mode is explicitly device/Android-version dependent.

9. **Command assembly and execution**
   - After device selection and audio choice, the helper assembles the final `scrcpy` command.
   - The command includes the target serial/endpoint plus the chosen audio flags.
   - This is the final handoff from Go into the external mirroring engine.

10. **Platform and packaging**
   - The repository ships compiled binaries in `dist/` for macOS arm64 and Windows amd64/arm64.
   - A macOS `run-droidhelper.command` script provides a double-click entry path and falls back to `go run .` if needed.
   - Even though Windows binaries exist, the operational story is still centered on macOS.

11. **Runtime/tooling implications**
   - The app depends on the local operating system having access to `adb`, `scrcpy`, and shell utilities.
   - That means the architecture is strongly host-dependent and thin by design: local CLI orchestration plus external tools.

12. **Diagram takeaway**
   - The clean architecture diagram should show:
     - User → Go CLI orchestrator
     - Go CLI orchestrator → `adb` / `scrcpy` / shell utilities
     - `adb` ↔ Android device over USB or Wi‑Fi
     - `scrcpy` ↔ Android device for mirroring/control
   - The repository itself mainly contains the orchestrator and packaging around those external dependencies.

Main entry points: [`main.go`](https://github.com/asish231/droidhelper/blob/main/main.go) (Wireless flow), [`run-droidhelper.command`](https://github.com/asish231/droidhelper/blob/main/run-droidhelper.command) (macOS launcher), [`dist`](https://github.com/asish231/droidhelper/tree/main/dist) (Prebuilt binaries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_repo["Go CLI"]
  node_main["DroidHelper CLI<br/>orchestrator<br/>[main.go]"]
  node_bootstrap["Bootstrap checks<br/>startup<br/>[main.go]"]
  node_mode_select["Mode picker<br/>interaction<br/>[main.go]"]
  node_usb_flow["USB flow<br/>connection flow<br/>[main.go]"]
  node_wireless_flow["Wireless flow<br/>connection flow<br/>[main.go]"]
  node_reachability["Reachability checks<br/>network probe<br/>[main.go]"]
  node_audio_policy["Audio policy<br/>launch policy<br/>[main.go]"]
  node_command_build["Command assembly<br/>launcher<br/>[main.go]"]
  node_runner["Launch handoff<br/>exec<br/>[main.go]"]
end

subgraph group_external["External tools"]
  node_adb["adb<br/>android tool"]
  node_scrcpy["scrcpy<br/>mirroring tool"]
  node_shell["Shell utils<br/>host tools"]
  node_device(("Android device<br/>endpoint"))
end

subgraph group_packaging["Packaging"]
  node_launcher_script["macOS launcher<br/>entry script"]
  node_binaries[("Prebuilt binaries<br/>release artifacts")]
end

node_user(("User<br/>actor"))

node_user -->|"starts"| node_main
node_launcher_script -->|"invokes"| node_main
node_binaries -.->|"ships"| node_main
node_main -->|"checks tools"| node_bootstrap
node_bootstrap -->|"requires"| node_adb
node_bootstrap -->|"requires"| node_scrcpy
node_bootstrap -->|"continues"| node_mode_select
node_mode_select -->|"USB"| node_usb_flow
node_mode_select -->|"wireless"| node_wireless_flow
node_usb_flow -->|"uses"| node_adb
node_usb_flow -->|"selects"| node_device
node_wireless_flow -->|"probes"| node_shell
node_wireless_flow -->|"pairs/connects"| node_adb
node_wireless_flow -->|"attaches"| node_device
node_wireless_flow -.->|"includes"| node_reachability
node_usb_flow -->|"passes choice"| node_audio_policy
node_wireless_flow -->|"passes choice"| node_audio_policy
node_audio_policy -->|"configures"| node_command_build
node_device -->|"targets"| node_command_build
node_command_build -->|"prepares"| node_scrcpy
node_runner -->|"executes"| node_scrcpy
node_adb -->|"connects to"| node_device
node_scrcpy -->|"mirrors/control"| node_device

click node_main "https://github.com/asish231/droidhelper/blob/main/main.go"
click node_bootstrap "https://github.com/asish231/droidhelper/blob/main/main.go"
click node_mode_select "https://github.com/asish231/droidhelper/blob/main/main.go"
click node_usb_flow "https://github.com/asish231/droidhelper/blob/main/main.go"
click node_wireless_flow "https://github.com/asish231/droidhelper/blob/main/main.go"
click node_reachability "https://github.com/asish231/droidhelper/blob/main/main.go"
click node_audio_policy "https://github.com/asish231/droidhelper/blob/main/main.go"
click node_command_build "https://github.com/asish231/droidhelper/blob/main/main.go"
click node_runner "https://github.com/asish231/droidhelper/blob/main/main.go"
click node_launcher_script "https://github.com/asish231/droidhelper/blob/main/run-droidhelper.command"
click node_binaries "https://github.com/asish231/droidhelper/tree/main/dist"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_bootstrap,node_mode_select,node_usb_flow,node_wireless_flow,node_reachability,node_audio_policy,node_command_build,node_runner toneBlue
class node_adb,node_scrcpy,node_shell,node_device toneAmber
class node_launcher_script,node_binaries toneMint
class node_user toneNeutral
```

## Components

### Go CLI

In-repo control plane and launch logic.

- [DroidHelper CLI](https://github.com/asish231/droidhelper/blob/main/main.go): orchestrator · Single Go entrypoint that coordinates startup, prompting, device selection, and final launch. · `main.go`
- [Bootstrap checks](https://github.com/asish231/droidhelper/blob/main/main.go): startup · Verifies adb and scrcpy are available and prompts for installation when missing. · `main.go`
- [Mode picker](https://github.com/asish231/droidhelper/blob/main/main.go): interaction · Guided terminal choice between USB and wireless connection flows. · `main.go`
- [USB flow](https://github.com/asish231/droidhelper/blob/main/main.go): connection flow · Starts the adb server, inspects connected devices, and selects a target serial. · `main.go`
- [Wireless flow](https://github.com/asish231/droidhelper/blob/main/main.go): connection flow · Guides pairing-code and wireless debugging setup before connecting over the network. · `main.go`
- [Reachability checks](https://github.com/asish231/droidhelper/blob/main/main.go): network probe · Uses ping and nc -vz to confirm device reachability before adb connect. · `main.go`
- [Audio policy](https://github.com/asish231/droidhelper/blob/main/main.go): launch policy · Chooses no-audio, normal audio, or voice-call audio flags for scrcpy. · `main.go`
- [Command assembly](https://github.com/asish231/droidhelper/blob/main/main.go): launcher · Builds the final scrcpy invocation with target device and selected flags. · `main.go`
- [Launch handoff](https://github.com/asish231/droidhelper/blob/main/main.go): exec · Executes the assembled external command and transfers control to scrcpy. · `main.go`

### External tools

Host-installed executables and device-side endpoints.

- **adb**: android tool · Handles discovery, pairing, connection state, and server management.
- **scrcpy**: mirroring tool · Provides device mirroring, audio routing, and control once launched.
- **Shell utils**: host tools · Uses ping and nc for lightweight network checks during wireless setup.
- **Android device**: endpoint · USB or Wi-Fi target reached by adb and mirrored by scrcpy.

### Packaging

Prebuilt artifacts and launch entrypoints.

- [macOS launcher](https://github.com/asish231/droidhelper/blob/main/run-droidhelper.command): entry script · Double-click entrypoint that runs the helper or falls back to go run . · `run-droidhelper.command`
- [Prebuilt binaries](https://github.com/asish231/droidhelper/tree/main/dist): release artifacts · Packaged macOS and Windows builds shipped in dist/. · `dist`

### Other components

- **User**: actor · Runs the guided terminal flow and chooses connection and audio options.

## Connections

- User → DroidHelper CLI: starts · User begins the terminal workflow.
- macOS launcher → DroidHelper CLI: invokes · The macOS script launches the helper.
- Prebuilt binaries → DroidHelper CLI: ships · Release artifacts package the same orchestrator.
- DroidHelper CLI → Bootstrap checks: checks tools · Startup verifies host dependencies.
- Bootstrap checks → adb: requires · adb must be installed locally.
- Bootstrap checks → scrcpy: requires · scrcpy must be installed locally.
- Bootstrap checks → Mode picker: continues · After bootstrap, the guided flow begins.
- Mode picker → USB flow: USB · User chooses USB connection.
- Mode picker → Wireless flow: wireless · User chooses wireless debugging.
- USB flow → adb: uses · Starts the adb server and queries devices.
- USB flow → Android device: selects · Chooses a connected device serial.
- Wireless flow → Shell utils: probes · Checks local reachability before connecting.
- Wireless flow → adb: pairs/connects · Uses mdns, pair, and connect flows.
- Wireless flow → Android device: attaches · Connects to the device over the network.
- Wireless flow → Reachability checks: includes · Network checks are part of wireless setup.
- USB flow → Audio policy: passes choice · Connection outcome feeds launch policy selection.
- Wireless flow → Audio policy: passes choice · Connection outcome feeds launch policy selection.
- Audio policy → Command assembly: configures · Audio mode becomes scrcpy flags.
- Android device → Command assembly: targets · Selected serial or endpoint is embedded in the final command.
- Command assembly → scrcpy: prepares · Assembles the final mirroring invocation.
- Launch handoff → scrcpy: executes · Hand off from Go into the external mirroring engine.
- adb → Android device: connects to · adb discovers, pairs, and connects to the Android device.
- scrcpy → Android device: mirrors/control · scrcpy streams and controls the device session.
