# tirthsaraiya29/tether architecture

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

- Interactive diagram: https://gitdiagram.com/tirthsaraiya29/tether
- Repository: https://github.com/tirthsaraiya29/tether

## Overview

Tether is a local-first Android companion and Windows workstation trust/security system. A user pairs the phone with the desktop, establishes cryptographic device identity, then uses the phone to maintain trust, unlock or lock the workstation, and invoke remote controls. The Android LAN service and Windows communication service carry the control workflow; the Windows service also coordinates pairing, sessions, and capability dispatch. Separate branches cover emergency panic/revocation, session-bound desktop functions, and desktop status/configuration. Several links are supported only by README documentation or the source index; unsampled capability internals are represented at directory level.

Main entry points: [`apps/android-companion/app/src/main/java/com/tether/phone/TetherLanService.kt`](https://github.com/tirthsaraiya29/tether/blob/main/apps/android-companion/app/src/main/java/com/tether/phone/TetherLanService.kt) (LAN Service), [`services/communication-service/Tether.CommunicationService/Program.cs`](https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Program.cs) (Communication Service), [`services/event-bus/Tether.EventBus/IEventBus.cs`](https://github.com/tirthsaraiya29/tether/blob/main/services/event-bus/Tether.EventBus/IEventBus.cs) (Event Bus), [`apps/android-companion/app/src/main/java/com/tether/phone/ui/screens/MainScreens.kt`](https://github.com/tirthsaraiya29/tether/blob/main/apps/android-companion/app/src/main/java/com/tether/phone/ui/screens/MainScreens.kt) (Companion UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_android["Android Companion"]
  node_android_app["Companion UI<br/>[MainScreens.kt]"]
  node_android_security["Phone Identity"]
end

subgraph group_connectivity["Pairing and Transport"]
  node_lan_service["LAN Service"]
  node_discovery["Device Discovery"]
  node_phone_pairing["Phone Pairing"]
  node_secure_session["TLS Session<br/>[TetherSession.cs]"]
end

subgraph group_windows["Windows Services"]
  node_win_service["Communication Service<br/>[Program.cs]"]
  node_pairing_manager["Pairing Manager<br/>[PairingManager.cs]"]
  node_win_identity["Windows Identity<br/>[WindowsIdentity.cs]"]
  node_device_manager["Device Registry<br/>[DeviceManager.cs]"]
  node_session_manager["Session Manager<br/>[SessionManager.cs]"]
  node_desktop_ui["Desktop UI<br/>[MainWindow.xaml.cs]"]
end

subgraph group_capabilities["Remote Capabilities"]
  node_capability_manager["Capability Dispatch"]
  node_session_helper["Session Helper"]
  node_input_forwarder["Remote Input<br/>[InputForwarder.cs]"]
  node_file_transfer["File Transfer"]
end

subgraph group_trust["Trust and Recovery"]
  node_trust_store[("Trust Store<br/>[TrustStore.cs]")]
  node_event_bus["Event Bus<br/>[IEventBus.cs]"]
  node_trust_engine["Trust State"]
  node_panic_engine["Panic Lock<br/>[PanicManager.cs]"]
  node_enforcement["Enforcement"]
  node_recovery["Recovery<br/>[RecoveryManager.cs]"]
end

node_phone_user(("Phone User"))

node_phone_user -->|"uses"| node_android_app
node_android_app -.->|"controls"| node_lan_service
node_lan_service -->|"uses identity"| node_android_security
node_lan_service -->|"discovers peers"| node_discovery
node_lan_service -->|"coordinates pairing"| node_phone_pairing
node_lan_service -->|"exchanges LAN control"| node_win_service
node_win_service -->|"registers"| node_pairing_manager
node_pairing_manager -->|"uses identity"| node_win_identity
node_pairing_manager -->|"promotes paired device"| node_device_manager
node_device_manager -->|"persists trust"| node_trust_store
node_win_service -->|"registers"| node_session_manager
node_session_manager -->|"tracks sessions"| node_secure_session
node_secure_session -->|"marks connected"| node_device_manager
node_win_service -->|"dispatches capabilities"| node_capability_manager
node_capability_manager -.->|"executes session actions"| node_session_helper
node_secure_session -.->|"forwards input"| node_input_forwarder
node_session_manager -->|"registers transfer server"| node_file_transfer
node_desktop_ui -->|"manages service"| node_win_service
node_win_service -->|"publishes events"| node_event_bus
node_trust_engine -->|"subscribes and publishes"| node_event_bus
node_panic_engine -->|"publishes panic events"| node_event_bus
node_enforcement -->|"subscribes"| node_event_bus
node_recovery -->|"subscribes"| node_event_bus
node_lan_service -.->|"requests emergency lock"| node_panic_engine
node_android_app -->|"invokes remote capabilities"| node_capability_manager

click node_android_app "https://github.com/tirthsaraiya29/tether/blob/main/apps/android-companion/app/src/main/java/com/tether/phone/ui/screens/MainScreens.kt"
click node_android_security "https://github.com/tirthsaraiya29/tether/blob/main/apps/android-companion/app/src/main/java/com/tether/phone/ProductionSecurityEngine.kt"
click node_lan_service "https://github.com/tirthsaraiya29/tether/blob/main/apps/android-companion/app/src/main/java/com/tether/phone/TetherLanService.kt"
click node_discovery "https://github.com/tirthsaraiya29/tether/blob/main/apps/android-companion/app/src/main/java/com/tether/phone/TetherDiscoveryManager.kt"
click node_phone_pairing "https://github.com/tirthsaraiya29/tether/blob/main/apps/android-companion/app/src/main/java/com/tether/phone/TetherPairingManager.kt"
click node_win_service "https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Program.cs"
click node_pairing_manager "https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Pairing/PairingManager.cs"
click node_win_identity "https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Security/WindowsIdentity.cs"
click node_device_manager "https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Devices/DeviceManager.cs"
click node_trust_store "https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Trust/TrustStore.cs"
click node_session_manager "https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Sessions/SessionManager.cs"
click node_secure_session "https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Transport/TetherSession.cs"
click node_capability_manager "https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Capabilities/CapabilityManager.cs"
click node_session_helper "https://github.com/tirthsaraiya29/tether/tree/main/services/communication-service/Tether.SessionHelper"
click node_input_forwarder "https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Transport/InputForwarder.cs"
click node_file_transfer "https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/FileTransfer/FileTransferServer.cs"
click node_desktop_ui "https://github.com/tirthsaraiya29/tether/blob/main/apps/desktop-ui/Tether.DesktopUI/MainWindow.xaml.cs"
click node_event_bus "https://github.com/tirthsaraiya29/tether/blob/main/services/event-bus/Tether.EventBus/IEventBus.cs"
click node_trust_engine "https://github.com/tirthsaraiya29/tether/blob/main/services/trust-engine/Tether.TrustEngine/TrustStateManager.cs"
click node_panic_engine "https://github.com/tirthsaraiya29/tether/blob/main/services/panic-engine/Tether.PanicEngine/PanicManager.cs"
click node_enforcement "https://github.com/tirthsaraiya29/tether/blob/main/services/enforcement-engine/Tether.EnforcementEngine/EnforcementManager.cs"
click node_recovery "https://github.com/tirthsaraiya29/tether/blob/main/services/recovery-engine/Tether.RecoveryEngine/RecoveryManager.cs"

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_android_app,node_android_security,node_phone_user toneBlue
class node_lan_service,node_discovery,node_phone_pairing,node_secure_session toneAmber
class node_win_service,node_pairing_manager,node_win_identity,node_device_manager,node_session_manager,node_desktop_ui toneMint
class node_capability_manager,node_session_helper,node_input_forwarder,node_file_transfer toneRose
class node_trust_store,node_event_bus,node_trust_engine,node_panic_engine,node_enforcement,node_recovery toneIndigo
```

## Components

### Android Companion

- [Companion UI](https://github.com/tirthsaraiya29/tether/blob/main/apps/android-companion/app/src/main/java/com/tether/phone/ui/screens/MainScreens.kt): `apps/android-companion/app/src/main/java/com/tether/phone/ui/screens/MainScreens.kt`
- [Phone Identity](https://github.com/tirthsaraiya29/tether/blob/main/apps/android-companion/app/src/main/java/com/tether/phone/ProductionSecurityEngine.kt): `apps/android-companion/app/src/main/java/com/tether/phone/ProductionSecurityEngine.kt`

### Pairing and Transport

- [LAN Service](https://github.com/tirthsaraiya29/tether/blob/main/apps/android-companion/app/src/main/java/com/tether/phone/TetherLanService.kt): `apps/android-companion/app/src/main/java/com/tether/phone/TetherLanService.kt`
- [Device Discovery](https://github.com/tirthsaraiya29/tether/blob/main/apps/android-companion/app/src/main/java/com/tether/phone/TetherDiscoveryManager.kt): `apps/android-companion/app/src/main/java/com/tether/phone/TetherDiscoveryManager.kt`
- [Phone Pairing](https://github.com/tirthsaraiya29/tether/blob/main/apps/android-companion/app/src/main/java/com/tether/phone/TetherPairingManager.kt): `apps/android-companion/app/src/main/java/com/tether/phone/TetherPairingManager.kt`
- [TLS Session](https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Transport/TetherSession.cs): `services/communication-service/Tether.CommunicationService/Transport/TetherSession.cs`

### Windows Services

- [Communication Service](https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Program.cs): `services/communication-service/Tether.CommunicationService/Program.cs`
- [Pairing Manager](https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Pairing/PairingManager.cs): `services/communication-service/Tether.CommunicationService/Pairing/PairingManager.cs`
- [Windows Identity](https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Security/WindowsIdentity.cs): `services/communication-service/Tether.CommunicationService/Security/WindowsIdentity.cs`
- [Device Registry](https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Devices/DeviceManager.cs): `services/communication-service/Tether.CommunicationService/Devices/DeviceManager.cs`
- [Session Manager](https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Sessions/SessionManager.cs): `services/communication-service/Tether.CommunicationService/Sessions/SessionManager.cs`
- [Desktop UI](https://github.com/tirthsaraiya29/tether/blob/main/apps/desktop-ui/Tether.DesktopUI/MainWindow.xaml.cs): `apps/desktop-ui/Tether.DesktopUI/MainWindow.xaml.cs`

### Remote Capabilities

- [Capability Dispatch](https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Capabilities/CapabilityManager.cs): `services/communication-service/Tether.CommunicationService/Capabilities/CapabilityManager.cs`
- [Session Helper](https://github.com/tirthsaraiya29/tether/tree/main/services/communication-service/Tether.SessionHelper): `services/communication-service/Tether.SessionHelper`
- [Remote Input](https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Transport/InputForwarder.cs): `services/communication-service/Tether.CommunicationService/Transport/InputForwarder.cs`
- [File Transfer](https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/FileTransfer/FileTransferServer.cs): `services/communication-service/Tether.CommunicationService/FileTransfer/FileTransferServer.cs`

### Trust and Recovery

- [Trust Store](https://github.com/tirthsaraiya29/tether/blob/main/services/communication-service/Tether.CommunicationService/Trust/TrustStore.cs): `services/communication-service/Tether.CommunicationService/Trust/TrustStore.cs`
- [Event Bus](https://github.com/tirthsaraiya29/tether/blob/main/services/event-bus/Tether.EventBus/IEventBus.cs): `services/event-bus/Tether.EventBus/IEventBus.cs`
- [Trust State](https://github.com/tirthsaraiya29/tether/blob/main/services/trust-engine/Tether.TrustEngine/TrustStateManager.cs): `services/trust-engine/Tether.TrustEngine/TrustStateManager.cs`
- [Panic Lock](https://github.com/tirthsaraiya29/tether/blob/main/services/panic-engine/Tether.PanicEngine/PanicManager.cs): `services/panic-engine/Tether.PanicEngine/PanicManager.cs`
- [Enforcement](https://github.com/tirthsaraiya29/tether/blob/main/services/enforcement-engine/Tether.EnforcementEngine/EnforcementManager.cs): `services/enforcement-engine/Tether.EnforcementEngine/EnforcementManager.cs`
- [Recovery](https://github.com/tirthsaraiya29/tether/blob/main/services/recovery-engine/Tether.RecoveryEngine/RecoveryManager.cs): `services/recovery-engine/Tether.RecoveryEngine/RecoveryManager.cs`

### Other components

- **Phone User**

## Connections

- Phone User → Companion UI: uses
- Companion UI → LAN Service: controls
- LAN Service → Phone Identity: uses identity (evidence: `apps/android-companion/app/src/main/java/com/tether/phone/TetherLanService.kt`)
- LAN Service → Device Discovery: discovers peers (evidence: `apps/android-companion/app/src/main/java/com/tether/phone/TetherLanService.kt`)
- LAN Service → Phone Pairing: coordinates pairing (evidence: `apps/android-companion/app/src/main/java/com/tether/phone/TetherLanService.kt`)
- LAN Service → Communication Service: exchanges LAN control
- Communication Service → Pairing Manager: registers (evidence: `services/communication-service/Tether.CommunicationService/Program.cs`)
- Pairing Manager → Windows Identity: uses identity (evidence: `services/communication-service/Tether.CommunicationService/Pairing/PairingManager.cs`)
- Pairing Manager → Device Registry: promotes paired device (evidence: `services/communication-service/Tether.CommunicationService/Pairing/PairingManager.cs`)
- Device Registry → Trust Store: persists trust (evidence: `services/communication-service/Tether.CommunicationService/Devices/DeviceManager.cs`)
- Communication Service → Session Manager: registers (evidence: `services/communication-service/Tether.CommunicationService/Program.cs`)
- Session Manager → TLS Session: tracks sessions (evidence: `services/communication-service/Tether.CommunicationService/Sessions/SessionManager.cs`)
- TLS Session → Device Registry: marks connected (evidence: `services/communication-service/Tether.CommunicationService/Transport/TetherSession.cs`)
- Communication Service → Capability Dispatch: dispatches capabilities (evidence: `services/communication-service/Tether.CommunicationService/Program.cs`)
- Capability Dispatch → Session Helper: executes session actions
- TLS Session → Remote Input: forwards input (evidence: `services/communication-service/Tether.CommunicationService/Transport/TetherSession.cs`)
- Session Manager → File Transfer: registers transfer server (evidence: `services/communication-service/Tether.CommunicationService/Sessions/SessionManager.cs`)
- Desktop UI → Communication Service: manages service
- Communication Service → Event Bus: publishes events (evidence: `services/communication-service/Tether.CommunicationService/Program.cs`)
- Trust State → Event Bus: subscribes and publishes (evidence: `services/trust-engine/Tether.TrustEngine/TrustStateManager.cs`)
- Panic Lock → Event Bus: publishes panic events (evidence: `services/panic-engine/Tether.PanicEngine/PanicManager.cs`)
- Enforcement → Event Bus: subscribes (evidence: `services/enforcement-engine/Tether.EnforcementEngine/EnforcementManager.cs`)
- Recovery → Event Bus: subscribes (evidence: `services/recovery-engine/Tether.RecoveryEngine/RecoveryManager.cs`)
- LAN Service → Panic Lock: requests emergency lock
- Companion UI → Capability Dispatch: invokes remote capabilities
