# mohamed-kilany/watchdog architecture

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

- Interactive diagram: https://gitdiagram.com/mohamed-kilany/watchdog
- Repository: https://github.com/mohamed-kilany/watchdog

## Overview

watchdog remotely operates an Android Camera2 device and delivers live frames and recordings to a host for browser viewing, capture, and analysis. The main workflow is host provisioning over ADB, camera capture and streaming from the app, then host-side presentation and media analysis. The README documents the product-level connections; sampled source and the SOURCE INDEX support selected internal links. Several host capabilities are named in the README but their implementations were not sampled, so those nodes use exact crate directories and their internal wiring is omitted.

Main entry points: [`android/app/src/main/kotlin/app/watchdog/remote/CaptureService.kt`](https://github.com/mohamed-kilany/watchdog/blob/master/android/app/src/main/kotlin/app/watchdog/remote/CaptureService.kt) (Capture service), [`crates/host/src/main.rs`](https://github.com/mohamed-kilany/watchdog/blob/master/crates/host/src/main.rs) (Host CLI), [`ui/src/app.ts`](https://github.com/mohamed-kilany/watchdog/blob/master/ui/src/app.ts) (Web app shell), [`android/app/src/main/kotlin/app/watchdog/remote/pipeline/FramePipeline.kt`](https://github.com/mohamed-kilany/watchdog/blob/master/android/app/src/main/kotlin/app/watchdog/remote/pipeline/FramePipeline.kt) (Frame pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host runtime"]
  node_host_cli["Host CLI<br/>[main.rs]"]
  node_provision["Device provisioning<br/>[provision.rs]"]
  node_adb["Native ADB<br/>[manager.rs]"]
  node_device_session["Device session<br/>[session.rs]"]
  node_ui_server["Web UI server<br/>[lib.rs]"]
end

subgraph group_device["Android device"]
  node_remote_app["Capture service<br/>[CaptureService.kt]"]
  node_camera["Camera controls"]
  node_frame_pipeline["Frame pipeline<br/>[FramePipeline.kt]"]
  node_wire_protocol["Wire protocol<br/>[JsonMessages.kt]"]
  node_device_logs["Device logging<br/>[DeviceLog.kt]"]
end

subgraph group_browser["Web interface"]
  node_web_app["Web app shell<br/>[app.ts]"]
  node_control_panel["Camera controls UI"]
  node_presets["Control presets<br/>[presets.ts]"]
end

subgraph group_services["Analysis and services"]
  node_integration_api["Integration API"]
  node_mcp_server["MCP server"]
  node_media_library[("Media library")]
  node_analyzers["Media analyzers"]
  node_scheduler["Scheduler"]
end

node_operator(("Operator"))
node_browser_user(("Browser user"))

node_operator -->|"runs commands"| node_host_cli
node_host_cli -.->|"provisions device"| node_provision
node_provision -->|"installs and forwards"| node_adb
node_adb -.->|"connects device"| node_device_session
node_device_session -->|"launches app"| node_remote_app
node_remote_app -->|"controls camera"| node_camera
node_remote_app -->|"starts pipeline"| node_frame_pipeline
node_camera -.->|"produces frames"| node_frame_pipeline
node_remote_app -->|"parses commands"| node_wire_protocol
node_remote_app -->|"streams logs"| node_device_logs
node_frame_pipeline -->|"streams live frames"| node_ui_server
node_remote_app -->|"pushes recordings"| node_media_library
node_host_cli -->|"serves web UI"| node_ui_server
node_host_cli -->|"serves API"| node_integration_api
node_host_cli -->|"serves MCP"| node_mcp_server
node_browser_user -->|"uses interface"| node_web_app
node_web_app -->|"probes host"| node_ui_server
node_web_app -->|"updates panels"| node_control_panel
node_web_app -->|"loads presets"| node_presets
node_media_library -.->|"provides media"| node_analyzers
node_scheduler -.->|"schedules analysis"| node_analyzers

click node_host_cli "https://github.com/mohamed-kilany/watchdog/blob/master/crates/host/src/main.rs"
click node_provision "https://github.com/mohamed-kilany/watchdog/blob/master/crates/device/src/provision.rs"
click node_adb "https://github.com/mohamed-kilany/watchdog/blob/master/crates/adb/src/manager.rs"
click node_device_session "https://github.com/mohamed-kilany/watchdog/blob/master/crates/device/src/session.rs"
click node_remote_app "https://github.com/mohamed-kilany/watchdog/blob/master/android/app/src/main/kotlin/app/watchdog/remote/CaptureService.kt"
click node_camera "https://github.com/mohamed-kilany/watchdog/blob/master/android/app/src/main/kotlin/app/watchdog/remote/camera/Camera2Controller.kt"
click node_frame_pipeline "https://github.com/mohamed-kilany/watchdog/blob/master/android/app/src/main/kotlin/app/watchdog/remote/pipeline/FramePipeline.kt"
click node_wire_protocol "https://github.com/mohamed-kilany/watchdog/blob/master/android/app/src/main/kotlin/app/watchdog/remote/protocol/JsonMessages.kt"
click node_device_logs "https://github.com/mohamed-kilany/watchdog/blob/master/android/app/src/main/kotlin/app/watchdog/remote/log/DeviceLog.kt"
click node_ui_server "https://github.com/mohamed-kilany/watchdog/blob/master/crates/ui-server/src/lib.rs"
click node_integration_api "https://github.com/mohamed-kilany/watchdog/tree/master/crates/api"
click node_mcp_server "https://github.com/mohamed-kilany/watchdog/tree/master/crates/mcp"
click node_web_app "https://github.com/mohamed-kilany/watchdog/blob/master/ui/src/app.ts"
click node_control_panel "https://github.com/mohamed-kilany/watchdog/blob/master/ui/src/components/wd-control-panel.ts"
click node_presets "https://github.com/mohamed-kilany/watchdog/blob/master/ui/src/presets.ts"
click node_media_library "https://github.com/mohamed-kilany/watchdog/tree/master/crates/media"
click node_analyzers "https://github.com/mohamed-kilany/watchdog/tree/master/crates/analyzers"
click node_scheduler "https://github.com/mohamed-kilany/watchdog/tree/master/crates/scheduler"

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_host_cli,node_provision,node_adb,node_device_session,node_ui_server,node_browser_user toneBlue
class node_remote_app,node_camera,node_frame_pipeline,node_wire_protocol,node_device_logs toneAmber
class node_web_app,node_control_panel,node_presets toneMint
class node_integration_api,node_mcp_server,node_media_library,node_analyzers,node_scheduler toneRose
class node_operator toneIndigo
```

## Components

### Host runtime

- [Host CLI](https://github.com/mohamed-kilany/watchdog/blob/master/crates/host/src/main.rs): `crates/host/src/main.rs`
- [Device provisioning](https://github.com/mohamed-kilany/watchdog/blob/master/crates/device/src/provision.rs): `crates/device/src/provision.rs`
- [Native ADB](https://github.com/mohamed-kilany/watchdog/blob/master/crates/adb/src/manager.rs): `crates/adb/src/manager.rs`
- [Device session](https://github.com/mohamed-kilany/watchdog/blob/master/crates/device/src/session.rs): `crates/device/src/session.rs`
- [Web UI server](https://github.com/mohamed-kilany/watchdog/blob/master/crates/ui-server/src/lib.rs): `crates/ui-server/src/lib.rs`

### Android device

- [Capture service](https://github.com/mohamed-kilany/watchdog/blob/master/android/app/src/main/kotlin/app/watchdog/remote/CaptureService.kt): `android/app/src/main/kotlin/app/watchdog/remote/CaptureService.kt`
- [Camera controls](https://github.com/mohamed-kilany/watchdog/blob/master/android/app/src/main/kotlin/app/watchdog/remote/camera/Camera2Controller.kt): `android/app/src/main/kotlin/app/watchdog/remote/camera/Camera2Controller.kt`
- [Frame pipeline](https://github.com/mohamed-kilany/watchdog/blob/master/android/app/src/main/kotlin/app/watchdog/remote/pipeline/FramePipeline.kt): `android/app/src/main/kotlin/app/watchdog/remote/pipeline/FramePipeline.kt`
- [Wire protocol](https://github.com/mohamed-kilany/watchdog/blob/master/android/app/src/main/kotlin/app/watchdog/remote/protocol/JsonMessages.kt): `android/app/src/main/kotlin/app/watchdog/remote/protocol/JsonMessages.kt`
- [Device logging](https://github.com/mohamed-kilany/watchdog/blob/master/android/app/src/main/kotlin/app/watchdog/remote/log/DeviceLog.kt): `android/app/src/main/kotlin/app/watchdog/remote/log/DeviceLog.kt`

### Web interface

- [Web app shell](https://github.com/mohamed-kilany/watchdog/blob/master/ui/src/app.ts): `ui/src/app.ts`
- [Camera controls UI](https://github.com/mohamed-kilany/watchdog/blob/master/ui/src/components/wd-control-panel.ts): `ui/src/components/wd-control-panel.ts`
- [Control presets](https://github.com/mohamed-kilany/watchdog/blob/master/ui/src/presets.ts): `ui/src/presets.ts`

### Analysis and services

- [Integration API](https://github.com/mohamed-kilany/watchdog/tree/master/crates/api): `crates/api`
- [MCP server](https://github.com/mohamed-kilany/watchdog/tree/master/crates/mcp): `crates/mcp`
- [Media library](https://github.com/mohamed-kilany/watchdog/tree/master/crates/media): `crates/media`
- [Media analyzers](https://github.com/mohamed-kilany/watchdog/tree/master/crates/analyzers): `crates/analyzers`
- [Scheduler](https://github.com/mohamed-kilany/watchdog/tree/master/crates/scheduler): `crates/scheduler`

### Other components

- **Operator**
- **Browser user**

## Connections

- Operator → Host CLI: runs commands (evidence: `README.md`)
- Host CLI → Device provisioning: provisions device
- Device provisioning → Native ADB: installs and forwards (evidence: `README.md`)
- Native ADB → Device session: connects device
- Device session → Capture service: launches app (evidence: `README.md`)
- Capture service → Camera controls: controls camera (evidence: `android/app/src/main/kotlin/app/watchdog/remote/CaptureService.kt`)
- Capture service → Frame pipeline: starts pipeline (evidence: `android/app/src/main/kotlin/app/watchdog/remote/CaptureService.kt`)
- Camera controls → Frame pipeline: produces frames
- Capture service → Wire protocol: parses commands (evidence: `android/app/src/main/kotlin/app/watchdog/remote/CaptureService.kt`)
- Capture service → Device logging: streams logs (evidence: `android/app/src/main/kotlin/app/watchdog/remote/log/DeviceLog.kt`)
- Frame pipeline → Web UI server: streams live frames (evidence: `README.md`)
- Capture service → Media library: pushes recordings (evidence: `README.md`)
- Host CLI → Web UI server: serves web UI (evidence: `README.md`)
- Host CLI → Integration API: serves API (evidence: `README.md`)
- Host CLI → MCP server: serves MCP (evidence: `README.md`)
- Browser user → Web app shell: uses interface (evidence: `README.md`)
- Web app shell → Web UI server: probes host (evidence: `ui/src/app.ts`)
- Web app shell → Camera controls UI: updates panels (evidence: `ui/src/app.ts`)
- Web app shell → Control presets: loads presets (evidence: `ui/src/app.ts`)
- Media library → Media analyzers: provides media
- Scheduler → Media analyzers: schedules analysis
