# moss-apps/latch architecture

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

- Interactive diagram: https://gitdiagram.com/moss-apps/latch
- Repository: https://github.com/moss-apps/latch

## Overview

Latch is an Android private-media vault; its documented phone workflow imports and encrypts files, protects access, organizes and views vault contents, and can back up encrypted data to the desktop companion. The tree omits the Flutter implementation, so those mobile stages are documented capabilities rather than source-mapped components. The sampled Android code supports an autofill branch. The desktop workflow pairs a phone, receives a backup, then allows browsing, verification, restore, and export. Edges reflect shown calls or README behavior; unsampled wiring is not inferred.

Main entry points: [`latchd/web-src/src/App.tsx`](https://github.com/moss-apps/latch/blob/main/latchd/web-src/src/App.tsx) (Web app shell), [`latchd/internal/webui/server.go`](https://github.com/moss-apps/latch/blob/main/latchd/internal/webui/server.go) (Web UI server), [`latchd/cmd/latchd/main.go`](https://github.com/moss-apps/latch/blob/main/latchd/cmd/latchd/main.go) (latchd commands), [`latchd/web-src/src/components/MainView.tsx`](https://github.com/moss-apps/latch/blob/main/latchd/web-src/src/components/MainView.tsx) (Backup browser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Android integration"]
  node_autofill_service["Autofill service<br/>[AutofillService.kt]"]
  node_autofill_holder["Pending fill state"]
  node_autofill_activity["Credential selection"]
  node_android_bridge["Android platform bridge<br/>[MainActivity.kt]"]
end

subgraph group_desktop["Desktop backup"]
  node_latchd_cli["latchd commands<br/>[main.go]"]
  node_web_server["Web UI server<br/>[server.go]"]
  node_receiver["Pairing receiver<br/>[receiver.go]"]
end

subgraph group_web["Web interface"]
  node_web_app["Web app shell<br/>[App.tsx]"]
  node_api_client["HTTP API client<br/>[api.ts]"]
  node_pair_view["Pairing screen<br/>[PairingView.tsx]"]
  node_main_view["Backup browser<br/>[MainView.tsx]"]
  node_browser_pane["File browser<br/>[BrowserPane.tsx]"]
  node_viewer["File viewer<br/>[Viewer.tsx]"]
  node_unlock["Backup unlock<br/>[UnlockPane.tsx]"]
  node_legal["Legal gate<br/>[LegalGate.tsx]"]
end

subgraph group_backup["Backup operations"]
  node_backup_store[("Local backup<br/>[backup.go]")]
  node_backup_crypto["Backup cryptography<br/>[crypto.go]"]
  node_verify["Backup verification<br/>[verify.go]"]
  node_export["Decrypted export<br/>[export.go]"]
end

node_phone(("Latch phone"))
node_vault["Media vault"]
node_desktop_user(("Desktop user"))
node_pocketbase["PocketBase sidecar<br/>[main.go]"]

node_phone -.->|"uses vault"| node_vault
node_phone -.->|"pushes encrypted backup"| node_receiver
node_desktop_user -->|"runs"| node_latchd_cli
node_latchd_cli -->|"serves UI"| node_web_server
node_web_server -->|"starts receiver"| node_receiver
node_receiver -.->|"receives backup"| node_backup_store
node_latchd_cli -->|"verifies backup"| node_verify
node_latchd_cli -->|"exports plaintext"| node_export
node_web_server -->|"verifies manifest"| node_verify
node_web_server -->|"exports files"| node_export
node_web_app -->|"renders pairing"| node_pair_view
node_web_app -->|"renders browser"| node_main_view
node_web_app -->|"gates access"| node_legal
node_web_app -->|"uses unlock pane"| node_unlock
node_web_app -->|"calls API"| node_api_client
node_api_client -.->|"HTTP requests"| node_web_server
node_main_view -.->|"browses files"| node_browser_pane
node_main_view -.->|"views files"| node_viewer
node_autofill_service -->|"stores callback"| node_autofill_holder
node_autofill_service -->|"launches activity"| node_autofill_activity
node_autofill_activity -->|"uses pending fill"| node_autofill_holder

click node_autofill_service "https://github.com/moss-apps/latch/blob/main/android/app/src/main/kotlin/com/mossapps/locker/AutofillService.kt"
click node_autofill_holder "https://github.com/moss-apps/latch/blob/main/android/app/src/main/kotlin/com/mossapps/locker/AutofillCallbackHolder.kt"
click node_autofill_activity "https://github.com/moss-apps/latch/blob/main/android/app/src/main/kotlin/com/mossapps/locker/AutofillSelectionActivity.kt"
click node_android_bridge "https://github.com/moss-apps/latch/blob/main/android/app/src/main/kotlin/com/mossapps/locker/MainActivity.kt"
click node_latchd_cli "https://github.com/moss-apps/latch/blob/main/latchd/cmd/latchd/main.go"
click node_web_server "https://github.com/moss-apps/latch/blob/main/latchd/internal/webui/server.go"
click node_receiver "https://github.com/moss-apps/latch/blob/main/latchd/internal/receiver/receiver.go"
click node_backup_store "https://github.com/moss-apps/latch/blob/main/latchd/internal/backup/backup.go"
click node_backup_crypto "https://github.com/moss-apps/latch/blob/main/latchd/internal/cryptoutil/crypto.go"
click node_verify "https://github.com/moss-apps/latch/blob/main/latchd/internal/backup/verify.go"
click node_export "https://github.com/moss-apps/latch/blob/main/latchd/internal/backup/export.go"
click node_web_app "https://github.com/moss-apps/latch/blob/main/latchd/web-src/src/App.tsx"
click node_api_client "https://github.com/moss-apps/latch/blob/main/latchd/web-src/src/lib/api.ts"
click node_pair_view "https://github.com/moss-apps/latch/blob/main/latchd/web-src/src/components/PairingView.tsx"
click node_main_view "https://github.com/moss-apps/latch/blob/main/latchd/web-src/src/components/MainView.tsx"
click node_browser_pane "https://github.com/moss-apps/latch/blob/main/latchd/web-src/src/components/BrowserPane.tsx"
click node_viewer "https://github.com/moss-apps/latch/blob/main/latchd/web-src/src/components/Viewer.tsx"
click node_unlock "https://github.com/moss-apps/latch/blob/main/latchd/web-src/src/components/UnlockPane.tsx"
click node_legal "https://github.com/moss-apps/latch/blob/main/latchd/web-src/src/components/LegalGate.tsx"
click node_pocketbase "https://github.com/moss-apps/latch/blob/main/pocketbase/cmd/locker-pb/main.go"

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_autofill_service,node_autofill_holder,node_autofill_activity,node_android_bridge,node_desktop_user toneBlue
class node_latchd_cli,node_web_server,node_receiver toneAmber
class node_web_app,node_api_client,node_pair_view,node_main_view,node_browser_pane,node_viewer,node_unlock,node_legal toneMint
class node_backup_store,node_backup_crypto,node_verify,node_export toneRose
class node_phone,node_vault toneIndigo
class node_pocketbase toneTeal
```

## Components

### Android integration

- [Autofill service](https://github.com/moss-apps/latch/blob/main/android/app/src/main/kotlin/com/mossapps/locker/AutofillService.kt): `android/app/src/main/kotlin/com/mossapps/locker/AutofillService.kt`
- [Pending fill state](https://github.com/moss-apps/latch/blob/main/android/app/src/main/kotlin/com/mossapps/locker/AutofillCallbackHolder.kt): `android/app/src/main/kotlin/com/mossapps/locker/AutofillCallbackHolder.kt`
- [Credential selection](https://github.com/moss-apps/latch/blob/main/android/app/src/main/kotlin/com/mossapps/locker/AutofillSelectionActivity.kt): `android/app/src/main/kotlin/com/mossapps/locker/AutofillSelectionActivity.kt`
- [Android platform bridge](https://github.com/moss-apps/latch/blob/main/android/app/src/main/kotlin/com/mossapps/locker/MainActivity.kt): `android/app/src/main/kotlin/com/mossapps/locker/MainActivity.kt`

### Desktop backup

- [latchd commands](https://github.com/moss-apps/latch/blob/main/latchd/cmd/latchd/main.go): `latchd/cmd/latchd/main.go`
- [Web UI server](https://github.com/moss-apps/latch/blob/main/latchd/internal/webui/server.go): `latchd/internal/webui/server.go`
- [Pairing receiver](https://github.com/moss-apps/latch/blob/main/latchd/internal/receiver/receiver.go): `latchd/internal/receiver/receiver.go`

### Web interface

- [Web app shell](https://github.com/moss-apps/latch/blob/main/latchd/web-src/src/App.tsx): `latchd/web-src/src/App.tsx`
- [HTTP API client](https://github.com/moss-apps/latch/blob/main/latchd/web-src/src/lib/api.ts): `latchd/web-src/src/lib/api.ts`
- [Pairing screen](https://github.com/moss-apps/latch/blob/main/latchd/web-src/src/components/PairingView.tsx): `latchd/web-src/src/components/PairingView.tsx`
- [Backup browser](https://github.com/moss-apps/latch/blob/main/latchd/web-src/src/components/MainView.tsx): `latchd/web-src/src/components/MainView.tsx`
- [File browser](https://github.com/moss-apps/latch/blob/main/latchd/web-src/src/components/BrowserPane.tsx): `latchd/web-src/src/components/BrowserPane.tsx`
- [File viewer](https://github.com/moss-apps/latch/blob/main/latchd/web-src/src/components/Viewer.tsx): `latchd/web-src/src/components/Viewer.tsx`
- [Backup unlock](https://github.com/moss-apps/latch/blob/main/latchd/web-src/src/components/UnlockPane.tsx): `latchd/web-src/src/components/UnlockPane.tsx`
- [Legal gate](https://github.com/moss-apps/latch/blob/main/latchd/web-src/src/components/LegalGate.tsx): `latchd/web-src/src/components/LegalGate.tsx`

### Backup operations

- [Local backup](https://github.com/moss-apps/latch/blob/main/latchd/internal/backup/backup.go): `latchd/internal/backup/backup.go`
- [Backup cryptography](https://github.com/moss-apps/latch/blob/main/latchd/internal/cryptoutil/crypto.go): `latchd/internal/cryptoutil/crypto.go`
- [Backup verification](https://github.com/moss-apps/latch/blob/main/latchd/internal/backup/verify.go): `latchd/internal/backup/verify.go`
- [Decrypted export](https://github.com/moss-apps/latch/blob/main/latchd/internal/backup/export.go): `latchd/internal/backup/export.go`

### Other components

- **Latch phone**
- **Media vault**
- **Desktop user**
- [PocketBase sidecar](https://github.com/moss-apps/latch/blob/main/pocketbase/cmd/locker-pb/main.go): `pocketbase/cmd/locker-pb/main.go`

## Connections

- Latch phone → Media vault: uses vault
- Latch phone → Pairing receiver: pushes encrypted backup
- Desktop user → latchd commands: runs (evidence: `latchd/cmd/latchd/main.go`)
- latchd commands → Web UI server: serves UI (evidence: `latchd/cmd/latchd/main.go`)
- Web UI server → Pairing receiver: starts receiver (evidence: `latchd/internal/webui/server.go`)
- Pairing receiver → Local backup: receives backup
- latchd commands → Backup verification: verifies backup (evidence: `latchd/cmd/latchd/main.go`)
- latchd commands → Decrypted export: exports plaintext (evidence: `latchd/cmd/latchd/main.go`)
- Web UI server → Backup verification: verifies manifest (evidence: `latchd/internal/webui/server.go`)
- Web UI server → Decrypted export: exports files (evidence: `latchd/internal/webui/server.go`)
- Web app shell → Pairing screen: renders pairing (evidence: `latchd/web-src/src/App.tsx`)
- Web app shell → Backup browser: renders browser (evidence: `latchd/web-src/src/App.tsx`)
- Web app shell → Legal gate: gates access (evidence: `latchd/web-src/src/App.tsx`)
- Web app shell → Backup unlock: uses unlock pane (evidence: `latchd/web-src/src/App.tsx`)
- Web app shell → HTTP API client: calls API (evidence: `latchd/web-src/src/App.tsx`)
- HTTP API client → Web UI server: HTTP requests
- Backup browser → File browser: browses files (evidence: `latchd/web-src/src/components/MainView.tsx`)
- Backup browser → File viewer: views files
- Autofill service → Pending fill state: stores callback (evidence: `android/app/src/main/kotlin/com/mossapps/locker/AutofillService.kt`)
- Autofill service → Credential selection: launches activity (evidence: `android/app/src/main/kotlin/com/mossapps/locker/AutofillService.kt`)
- Credential selection → Pending fill state: uses pending fill (evidence: `android/app/src/main/kotlin/com/mossapps/locker/AutofillSelectionActivity.kt`)
