# mahammed-gaber/pixmirror architecture

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

- Interactive diagram: https://gitdiagram.com/mahammed-gaber/pixmirror
- Repository: https://github.com/mahammed-gaber/pixmirror

## Overview

PixMirror is a Windows desktop app for mirroring and controlling Android phones over USB. The main workflow detects ADB devices, lets the user select a phone and mirroring options, then starts a scrcpy session; a separate toolbar provides controls, screenshots, and recording. Settings, device diagnostics, performance presets, screen-off control, and localization are supporting capabilities. The frontend-to-backend command boundary is documented by Tauri command registration, but many command implementations were not sampled, so those links are shown as unverified.

Main entry points: [`src/pages/connect/ConnectPage.tsx`](https://github.com/mahammed-gaber/pixmirror/blob/main/src/pages/connect/ConnectPage.tsx) (Connect screen), [`src/pages/toolbar/ToolbarPage.tsx`](https://github.com/mahammed-gaber/pixmirror/blob/main/src/pages/toolbar/ToolbarPage.tsx) (Toolbar screen), [`src-tauri/src/mirror/service.rs`](https://github.com/mahammed-gaber/pixmirror/blob/main/src-tauri/src/mirror/service.rs) (Mirror service), [`src/features/mirroring/hooks/useMirrorSession.ts`](https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/mirroring/hooks/useMirrorSession.ts) (Session lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_connect["Connect and devices"]
  node_app["App routing<br/>[App.tsx]"]
  node_connectpage["Connect screen<br/>[ConnectPage.tsx]"]
  node_deviceui["Device discovery UI<br/>[ConnectGuide.tsx]"]
  node_devicehooks["Device polling<br/>[useDevices.ts]"]
  node_deviceapi["Device API<br/>[api.ts]"]
  node_stats["Live device stats<br/>[useDeviceStats.ts]"]
end

subgraph group_mirror["Mirroring session"]
  node_prefs["Mirror preferences<br/>[useDevicePrefs.ts]"]
  node_preset["Performance presets<br/>[PresetPicker.tsx]"]
  node_session["Session lifecycle"]
  node_mirrorapi["Mirroring API<br/>[api.ts]"]
end

subgraph group_controls["Capture and controls"]
  node_toolbarpage["Toolbar screen<br/>[ToolbarPage.tsx]"]
  node_toolbar["Mirror toolbar<br/>[MirrorToolbar.tsx]"]
  node_capturehooks["Capture actions<br/>[useRecording.ts]"]
  node_captureapi["Capture API<br/>[api.ts]"]
  node_settings["Save directory settings<br/>[SettingsDialog.tsx]"]
end

subgraph group_backend["Rust backend"]
  node_rustentry["Tauri command registry<br/>[lib.rs]"]
  node_devicesbackend["ADB device commands<br/>[commands.rs]"]
  node_mirrorservice["Mirror service<br/>[service.rs]"]
  node_scrcpy["scrcpy process<br/>[scrcpy.rs]"]
  node_settingsstore[("Settings persistence<br/>[store.rs]")]
  node_adb["ADB device bridge<br/>[adb.rs]"]
end

node_user(("User"))

node_user -->|"selects phone"| node_connectpage
node_connectpage -->|"lists devices"| node_devicehooks
node_devicehooks -->|"requests list"| node_deviceapi
node_connectpage -->|"polls stats"| node_stats
node_stats -->|"requests stats"| node_deviceapi
node_connectpage -->|"loads preferences"| node_prefs
node_connectpage -->|"chooses preset"| node_preset
node_connectpage -->|"starts session"| node_session
node_app -->|"tracks status"| node_session
node_session -->|"starts and polls"| node_mirrorapi
node_app -->|"shows when idle"| node_connectpage
node_app -->|"shows when active"| node_toolbarpage
node_toolbarpage -->|"renders controls"| node_toolbar
node_toolbarpage -->|"controls recording"| node_capturehooks
node_capturehooks -->|"invokes capture"| node_captureapi
node_toolbarpage -->|"stops session"| node_session
node_connectpage -->|"opens settings"| node_settings
node_rustentry -->|"registers commands"| node_devicesbackend
node_rustentry -->|"registers commands"| node_mirrorservice
node_mirrorservice -->|"uses process"| node_scrcpy
node_mirrorservice -->|"reads settings"| node_settingsstore
node_devicesbackend -.->|"uses ADB"| node_adb
node_deviceapi -.->|"calls device commands"| node_devicesbackend
node_mirrorapi -.->|"calls mirror commands"| node_mirrorservice
node_captureapi -.->|"calls capture commands"| node_rustentry

click node_app "https://github.com/mahammed-gaber/pixmirror/blob/main/src/app/App.tsx"
click node_connectpage "https://github.com/mahammed-gaber/pixmirror/blob/main/src/pages/connect/ConnectPage.tsx"
click node_deviceui "https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/devices/components/ConnectGuide.tsx"
click node_devicehooks "https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/devices/hooks/useDevices.ts"
click node_deviceapi "https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/devices/api.ts"
click node_stats "https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/devices/hooks/useDeviceStats.ts"
click node_prefs "https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/mirroring/hooks/useDevicePrefs.ts"
click node_preset "https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/mirroring/components/PresetPicker.tsx"
click node_session "https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/mirroring/hooks/useMirrorSession.ts"
click node_mirrorapi "https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/mirroring/api.ts"
click node_toolbarpage "https://github.com/mahammed-gaber/pixmirror/blob/main/src/pages/toolbar/ToolbarPage.tsx"
click node_toolbar "https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/toolbar/components/MirrorToolbar.tsx"
click node_capturehooks "https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/capture/hooks/useRecording.ts"
click node_captureapi "https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/capture/api.ts"
click node_settings "https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/settings/components/SettingsDialog.tsx"
click node_rustentry "https://github.com/mahammed-gaber/pixmirror/blob/main/src-tauri/src/lib.rs"
click node_devicesbackend "https://github.com/mahammed-gaber/pixmirror/blob/main/src-tauri/src/devices/commands.rs"
click node_mirrorservice "https://github.com/mahammed-gaber/pixmirror/blob/main/src-tauri/src/mirror/service.rs"
click node_scrcpy "https://github.com/mahammed-gaber/pixmirror/blob/main/src-tauri/src/mirror/scrcpy.rs"
click node_settingsstore "https://github.com/mahammed-gaber/pixmirror/blob/main/src-tauri/src/settings/store.rs"
click node_adb "https://github.com/mahammed-gaber/pixmirror/blob/main/src-tauri/src/shared/adb.rs"

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_app,node_connectpage,node_deviceui,node_devicehooks,node_deviceapi,node_stats,node_user toneBlue
class node_prefs,node_preset,node_session,node_mirrorapi toneAmber
class node_toolbarpage,node_toolbar,node_capturehooks,node_captureapi,node_settings toneMint
class node_rustentry,node_devicesbackend,node_mirrorservice,node_scrcpy,node_settingsstore,node_adb toneRose
```

## Components

### Connect and devices

- [App routing](https://github.com/mahammed-gaber/pixmirror/blob/main/src/app/App.tsx): `src/app/App.tsx`
- [Connect screen](https://github.com/mahammed-gaber/pixmirror/blob/main/src/pages/connect/ConnectPage.tsx): `src/pages/connect/ConnectPage.tsx`
- [Device discovery UI](https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/devices/components/ConnectGuide.tsx): `src/features/devices/components/ConnectGuide.tsx`
- [Device polling](https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/devices/hooks/useDevices.ts): `src/features/devices/hooks/useDevices.ts`
- [Device API](https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/devices/api.ts): `src/features/devices/api.ts`
- [Live device stats](https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/devices/hooks/useDeviceStats.ts): `src/features/devices/hooks/useDeviceStats.ts`

### Mirroring session

- [Mirror preferences](https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/mirroring/hooks/useDevicePrefs.ts): `src/features/mirroring/hooks/useDevicePrefs.ts`
- [Performance presets](https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/mirroring/components/PresetPicker.tsx): `src/features/mirroring/components/PresetPicker.tsx`
- [Session lifecycle](https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/mirroring/hooks/useMirrorSession.ts): `src/features/mirroring/hooks/useMirrorSession.ts`
- [Mirroring API](https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/mirroring/api.ts): `src/features/mirroring/api.ts`

### Capture and controls

- [Toolbar screen](https://github.com/mahammed-gaber/pixmirror/blob/main/src/pages/toolbar/ToolbarPage.tsx): `src/pages/toolbar/ToolbarPage.tsx`
- [Mirror toolbar](https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/toolbar/components/MirrorToolbar.tsx): `src/features/toolbar/components/MirrorToolbar.tsx`
- [Capture actions](https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/capture/hooks/useRecording.ts): `src/features/capture/hooks/useRecording.ts`
- [Capture API](https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/capture/api.ts): `src/features/capture/api.ts`
- [Save directory settings](https://github.com/mahammed-gaber/pixmirror/blob/main/src/features/settings/components/SettingsDialog.tsx): `src/features/settings/components/SettingsDialog.tsx`

### Rust backend

- [Tauri command registry](https://github.com/mahammed-gaber/pixmirror/blob/main/src-tauri/src/lib.rs): `src-tauri/src/lib.rs`
- [ADB device commands](https://github.com/mahammed-gaber/pixmirror/blob/main/src-tauri/src/devices/commands.rs): `src-tauri/src/devices/commands.rs`
- [Mirror service](https://github.com/mahammed-gaber/pixmirror/blob/main/src-tauri/src/mirror/service.rs): `src-tauri/src/mirror/service.rs`
- [scrcpy process](https://github.com/mahammed-gaber/pixmirror/blob/main/src-tauri/src/mirror/scrcpy.rs): `src-tauri/src/mirror/scrcpy.rs`
- [Settings persistence](https://github.com/mahammed-gaber/pixmirror/blob/main/src-tauri/src/settings/store.rs): `src-tauri/src/settings/store.rs`
- [ADB device bridge](https://github.com/mahammed-gaber/pixmirror/blob/main/src-tauri/src/shared/adb.rs): `src-tauri/src/shared/adb.rs`

### Other components

- **User**

## Connections

- User → Connect screen: selects phone (evidence: `README.md`)
- Connect screen → Device polling: lists devices (evidence: `src/pages/connect/ConnectPage.tsx`)
- Device polling → Device API: requests list (evidence: `src/features/devices/hooks/useDevices.ts`)
- Connect screen → Live device stats: polls stats (evidence: `src/pages/connect/ConnectPage.tsx`)
- Live device stats → Device API: requests stats (evidence: `src/features/devices/hooks/useDeviceStats.ts`)
- Connect screen → Mirror preferences: loads preferences (evidence: `src/pages/connect/ConnectPage.tsx`)
- Connect screen → Performance presets: chooses preset (evidence: `src/pages/connect/ConnectPage.tsx`)
- Connect screen → Session lifecycle: starts session (evidence: `src/pages/connect/ConnectPage.tsx`)
- App routing → Session lifecycle: tracks status (evidence: `src/app/App.tsx`)
- Session lifecycle → Mirroring API: starts and polls (evidence: `src/features/mirroring/hooks/useMirrorSession.ts`)
- App routing → Connect screen: shows when idle (evidence: `src/app/App.tsx`)
- App routing → Toolbar screen: shows when active (evidence: `src/app/App.tsx`)
- Toolbar screen → Mirror toolbar: renders controls (evidence: `src/pages/toolbar/ToolbarPage.tsx`)
- Toolbar screen → Capture actions: controls recording (evidence: `src/pages/toolbar/ToolbarPage.tsx`)
- Capture actions → Capture API: invokes capture (evidence: `src/features/capture/hooks/useRecording.ts`)
- Toolbar screen → Session lifecycle: stops session (evidence: `src/pages/toolbar/ToolbarPage.tsx`)
- Connect screen → Save directory settings: opens settings (evidence: `src/pages/connect/ConnectPage.tsx`)
- Tauri command registry → ADB device commands: registers commands (evidence: `src-tauri/src/lib.rs`)
- Tauri command registry → Mirror service: registers commands (evidence: `src-tauri/src/lib.rs`)
- Mirror service → scrcpy process: uses process (evidence: `src-tauri/src/mirror/service.rs`)
- Mirror service → Settings persistence: reads settings (evidence: `src-tauri/src/mirror/service.rs`)
- ADB device commands → ADB device bridge: uses ADB
- Device API → ADB device commands: calls device commands
- Mirroring API → Mirror service: calls mirror commands
- Capture API → Tauri command registry: calls capture commands
