# zyren-lab/kswitch architecture

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

- Interactive diagram: https://gitdiagram.com/zyren-lab/kswitch
- Repository: https://github.com/zyren-lab/kswitch

## Overview

KSwitch is a desktop Android backup and restore application. A user connects an Android device over ADB, scans and selects device content, then backs it up to a local folder with a manifest; restore reads a backup and sends selected content back to the device. The graph includes the UI, discovery and categorization, transfer and manifest handling, and ADB access. Some connections reflect the SOURCE INDEX or README because those source excerpts are incomplete; unsampled implementation details are not inferred.

Main entry points: [`src/main/kotlin/ScreenContent.kt`](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/ScreenContent.kt) (Workflow coordinator), [`src/main/kotlin/AdbClient.kt`](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/AdbClient.kt) (ADB command client), [`src/main/kotlin/ui/BackupTab.kt`](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/ui/BackupTab.kt) (Backup tab), [`src/main/kotlin/ui/RestoreTab.kt`](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/ui/RestoreTab.kt) (Restore tab)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop interface"]
  node_main["App entry<br/>[Main.kt]"]
  node_main_screen["Main screen<br/>[MainScreen.kt]"]
  node_screen_content["Workflow coordinator<br/>[ScreenContent.kt]"]
  node_backup_tab["Backup tab<br/>[BackupTab.kt]"]
  node_restore_tab["Restore tab<br/>[RestoreTab.kt]"]
  node_app_dialog["App selection"]
  node_dashboard["Dashboard<br/>[Dashboard.kt]"]
  node_magic_card["Dashboard card<br/>[MagicCard.kt]"]
end

subgraph group_discovery["Device discovery"]
  node_file_scanner["Media scanner<br/>[FileScanner.kt]"]
  node_app_engine["App discovery<br/>[AppEngine.kt]"]
  node_category_manager["Category catalog<br/>[CategoryManager.kt]"]
  node_data_engine["Contacts and calls<br/>[DataEngine.kt]"]
end

subgraph group_transfer["Backup and restore"]
  node_backup_engine["File transfer<br/>[BackupEngine.kt]"]
  node_manifest_manager["Backup manifest<br/>[ManifestManager.kt]"]
  node_backup_folder["Local backup folder"]
end

subgraph group_device["Device access"]
  node_adb_client["ADB command client<br/>[AdbClient.kt]"]
end

node_user(("Desktop user"))
node_android(("Android device"))

node_user -->|"opens"| node_main
node_main -->|"launches"| node_main_screen
node_main_screen -->|"renders"| node_screen_content
node_user -.->|"selects backup"| node_backup_tab
node_user -.->|"selects restore"| node_restore_tab
node_screen_content -->|"renders"| node_backup_tab
node_screen_content -->|"renders"| node_restore_tab
node_backup_tab -->|"opens"| node_app_dialog
node_backup_tab -->|"formats counts"| node_category_manager
node_dashboard -->|"renders"| node_magic_card
node_screen_content -->|"scans files"| node_file_scanner
node_screen_content -->|"scans apps"| node_app_engine
node_screen_content -->|"builds categories"| node_category_manager
node_screen_content -.->|"backs up data"| node_data_engine
node_screen_content -->|"transfers files"| node_backup_engine
node_screen_content -->|"writes manifest"| node_manifest_manager
node_restore_tab -->|"reads manifest"| node_manifest_manager
node_screen_content -->|"runs device commands"| node_adb_client
node_file_scanner -->|"queries media"| node_adb_client
node_app_engine -->|"queries and transfers apps"| node_adb_client
node_data_engine -->|"queries device data"| node_adb_client
node_backup_engine -->|"pulls and pushes files"| node_adb_client
node_adb_client -->|"executes ADB"| node_android
node_backup_engine -->|"writes files"| node_backup_folder
node_manifest_manager -->|"records backup"| node_backup_folder
node_restore_tab -->|"scans backup"| node_backup_folder

click node_main "https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/Main.kt"
click node_main_screen "https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/MainScreen.kt"
click node_screen_content "https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/ScreenContent.kt"
click node_backup_tab "https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/ui/BackupTab.kt"
click node_restore_tab "https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/ui/RestoreTab.kt"
click node_app_dialog "https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/ui/components/AppSelectionDialog.kt"
click node_dashboard "https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/ui/components/Dashboard.kt"
click node_magic_card "https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/ui/components/MagicCard.kt"
click node_file_scanner "https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/FileScanner.kt"
click node_app_engine "https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/AppEngine.kt"
click node_category_manager "https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/CategoryManager.kt"
click node_data_engine "https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/DataEngine.kt"
click node_backup_engine "https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/BackupEngine.kt"
click node_manifest_manager "https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/ManifestManager.kt"
click node_adb_client "https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/AdbClient.kt"

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_main_screen,node_screen_content,node_backup_tab,node_restore_tab,node_app_dialog,node_dashboard,node_magic_card,node_user toneBlue
class node_file_scanner,node_app_engine,node_category_manager,node_data_engine toneAmber
class node_backup_engine,node_manifest_manager,node_backup_folder toneMint
class node_adb_client toneRose
class node_android toneIndigo
```

## Components

### Desktop interface

- [App entry](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/Main.kt): `src/main/kotlin/Main.kt`
- [Main screen](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/MainScreen.kt): `src/main/kotlin/MainScreen.kt`
- [Workflow coordinator](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/ScreenContent.kt): `src/main/kotlin/ScreenContent.kt`
- [Backup tab](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/ui/BackupTab.kt): `src/main/kotlin/ui/BackupTab.kt`
- [Restore tab](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/ui/RestoreTab.kt): `src/main/kotlin/ui/RestoreTab.kt`
- [App selection](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/ui/components/AppSelectionDialog.kt): `src/main/kotlin/ui/components/AppSelectionDialog.kt`
- [Dashboard](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/ui/components/Dashboard.kt): `src/main/kotlin/ui/components/Dashboard.kt`
- [Dashboard card](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/ui/components/MagicCard.kt): `src/main/kotlin/ui/components/MagicCard.kt`

### Device discovery

- [Media scanner](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/FileScanner.kt): `src/main/kotlin/FileScanner.kt`
- [App discovery](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/AppEngine.kt): `src/main/kotlin/AppEngine.kt`
- [Category catalog](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/CategoryManager.kt): `src/main/kotlin/CategoryManager.kt`
- [Contacts and calls](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/DataEngine.kt): `src/main/kotlin/DataEngine.kt`

### Backup and restore

- [File transfer](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/BackupEngine.kt): `src/main/kotlin/BackupEngine.kt`
- [Backup manifest](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/ManifestManager.kt): `src/main/kotlin/ManifestManager.kt`
- **Local backup folder**

### Device access

- [ADB command client](https://github.com/zyren-lab/kswitch/blob/main/src/main/kotlin/AdbClient.kt): `src/main/kotlin/AdbClient.kt`

### Other components

- **Desktop user**
- **Android device**

## Connections

- Desktop user → App entry: opens (evidence: `README.md`)
- App entry → Main screen: launches (evidence: `src/main/kotlin/Main.kt`)
- Main screen → Workflow coordinator: renders (evidence: `src/main/kotlin/MainScreen.kt`)
- Desktop user → Backup tab: selects backup
- Desktop user → Restore tab: selects restore
- Workflow coordinator → Backup tab: renders (evidence: `src/main/kotlin/ScreenContent.kt`)
- Workflow coordinator → Restore tab: renders (evidence: `src/main/kotlin/ScreenContent.kt`)
- Backup tab → App selection: opens (evidence: `src/main/kotlin/ui/BackupTab.kt`)
- Backup tab → Category catalog: formats counts (evidence: `src/main/kotlin/ui/BackupTab.kt`)
- Dashboard → Dashboard card: renders (evidence: `src/main/kotlin/ui/components/Dashboard.kt`)
- Workflow coordinator → Media scanner: scans files (evidence: `src/main/kotlin/ScreenContent.kt`)
- Workflow coordinator → App discovery: scans apps (evidence: `src/main/kotlin/ScreenContent.kt`)
- Workflow coordinator → Category catalog: builds categories (evidence: `src/main/kotlin/ScreenContent.kt`)
- Workflow coordinator → Contacts and calls: backs up data (evidence: `src/main/kotlin/ScreenContent.kt`)
- Workflow coordinator → File transfer: transfers files (evidence: `src/main/kotlin/ScreenContent.kt`)
- Workflow coordinator → Backup manifest: writes manifest (evidence: `src/main/kotlin/ScreenContent.kt`)
- Restore tab → Backup manifest: reads manifest (evidence: `src/main/kotlin/ui/RestoreTab.kt`)
- Workflow coordinator → ADB command client: runs device commands (evidence: `src/main/kotlin/ScreenContent.kt`)
- Media scanner → ADB command client: queries media (evidence: `src/main/kotlin/FileScanner.kt`)
- App discovery → ADB command client: queries and transfers apps (evidence: `src/main/kotlin/AppEngine.kt`)
- Contacts and calls → ADB command client: queries device data (evidence: `src/main/kotlin/DataEngine.kt`)
- File transfer → ADB command client: pulls and pushes files (evidence: `src/main/kotlin/BackupEngine.kt`)
- ADB command client → Android device: executes ADB (evidence: `README.md`)
- File transfer → Local backup folder: writes files (evidence: `src/main/kotlin/BackupEngine.kt`)
- Backup manifest → Local backup folder: records backup (evidence: `README.md`)
- Restore tab → Local backup folder: scans backup (evidence: `src/main/kotlin/ui/RestoreTab.kt`)
