# scythe0425/bridgeui architecture

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

- Interactive diagram: https://gitdiagram.com/scythe0425/bridgeui
- Repository: https://github.com/scythe0425/bridgeui

## Overview

bridgeUI helps older adults understand icons and controls in other phone apps. The user freezes a screen, selects a crop, chooses a detected element, and receives a short, plain-language explanation in an overlay. The backend detects the selected UI, then checks perceptual-hash and CLIP caches before requesting Gemini Vision on a miss; new explanations are cached. Documented supporting capabilities include background screen detection, category-based cross-app matching, database seeding, and capture reanalysis. Flutter internals and some API details are unsampled, so those links rely on README statements.

Main entry points: [`backend/main.py`](https://github.com/scythe0425/bridgeui/blob/main/backend/main.py) (Capture API), [`backend/db/chroma_store.py`](https://github.com/scythe0425/bridgeui/blob/main/backend/db/chroma_store.py) (ChromaDB store), [`frontend/bridge_ui/android/app/src/main/kotlin/com/bridgeui/bridge_ui/MainActivity.kt`](https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/android/app/src/main/kotlin/com/bridgeui/bridge_ui/MainActivity.kt) (Screen capture), [`frontend/bridge_ui/lib/overlay/trigger_button.dart`](https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/lib/overlay/trigger_button.dart) (Capture trigger)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile capture"]
  node_trigger["Capture trigger"]
  node_android["Screen capture<br/>[MainActivity.kt]"]
  node_projection["Projection service"]
  node_capture_service["Capture service"]
end

subgraph group_interaction["Selection and guidance"]
  node_scanner["UI scanner<br/>[ui_scanner.dart]"]
  node_extractor["Element extractor"]
  node_freeze["Freeze overlay"]
  node_sender["Capture sender"]
  node_result["Result bubble<br/>[result_bubble.dart]"]
end

subgraph group_api["Backend API"]
  node_backend["Capture API<br/>[main.py]"]
  node_detect_api["Detection API<br/>[main.py]"]
  node_reanalyze["Reanalysis API<br/>[main.py]"]
end

subgraph group_analysis["UI analysis"]
  node_detector["OmniParser detector<br/>[ui_detector.py]"]
  node_deep["Gemini explanation<br/>[deep_track.py]"]
end

subgraph group_cache["Matching and storage"]
  node_hash["pHash stage<br/>[hash_track.py]"]
  node_embedder["CLIP embedder<br/>[embedder.py]"]
  node_fast["CLIP search<br/>[fast_track.py]"]
  node_store[("ChromaDB store<br/>[chroma_store.py]")]
  node_seed["Seed catalog<br/>[seed_db.py]"]
end

node_user(("Phone user"))
node_launcher["Target app"]

node_user -->|"opens app"| node_launcher
node_user -->|"starts capture"| node_trigger
node_trigger -.->|"requests screen"| node_android
node_android -->|"starts and binds"| node_projection
node_android -.->|"provides screenshot"| node_capture_service
node_user -->|"selects crop"| node_freeze
node_freeze -->|"requests detections"| node_scanner
node_scanner -->|"posts screenshot"| node_detect_api
node_user -->|"chooses element"| node_extractor
node_extractor -.->|"provides selection"| node_sender
node_sender -->|"posts capture"| node_backend
node_detect_api -.->|"runs detection"| node_detector
node_backend -->|"selects UI element"| node_detector
node_backend -->|"checks pHash"| node_hash
node_backend -->|"embeds cache miss"| node_embedder
node_backend -->|"searches vector"| node_fast
node_fast -->|"queries vectors"| node_store
node_backend -->|"explains cache miss"| node_deep
node_backend -.->|"writes explanation"| node_store
node_backend -->|"registers new hash"| node_hash
node_seed -->|"seeds entries"| node_store
node_backend -->|"returns explanation"| node_result
node_user -->|"reads guidance"| node_result
node_user -->|"requests reanalysis"| node_reanalyze
node_reanalyze -->|"forces explanation"| node_deep
node_reanalyze -->|"updates entry"| node_store

click node_trigger "https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/lib/overlay/trigger_button.dart"
click node_android "https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/android/app/src/main/kotlin/com/bridgeui/bridge_ui/MainActivity.kt"
click node_projection "https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/android/app/src/main/kotlin/com/bridgeui/bridge_ui/MediaProjectionForegroundService.kt"
click node_capture_service "https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/lib/capture/capture_service.dart"
click node_scanner "https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/lib/capture/ui_scanner.dart"
click node_extractor "https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/lib/capture/element_extractor.dart"
click node_freeze "https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/lib/overlay/freeze_overlay.dart"
click node_sender "https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/lib/capture/capture_sender.dart"
click node_result "https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/lib/overlay/result_bubble.dart"
click node_backend "https://github.com/scythe0425/bridgeui/blob/main/backend/main.py"
click node_detect_api "https://github.com/scythe0425/bridgeui/blob/main/backend/main.py"
click node_reanalyze "https://github.com/scythe0425/bridgeui/blob/main/backend/main.py"
click node_detector "https://github.com/scythe0425/bridgeui/blob/main/backend/pipeline/ui_detector.py"
click node_hash "https://github.com/scythe0425/bridgeui/blob/main/backend/pipeline/hash_track.py"
click node_embedder "https://github.com/scythe0425/bridgeui/blob/main/backend/pipeline/embedder.py"
click node_fast "https://github.com/scythe0425/bridgeui/blob/main/backend/pipeline/fast_track.py"
click node_deep "https://github.com/scythe0425/bridgeui/blob/main/backend/pipeline/deep_track.py"
click node_store "https://github.com/scythe0425/bridgeui/blob/main/backend/db/chroma_store.py"
click node_seed "https://github.com/scythe0425/bridgeui/blob/main/backend/db/seed_db.py"

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_trigger,node_android,node_projection,node_capture_service,node_user toneBlue
class node_scanner,node_extractor,node_freeze,node_sender,node_result toneAmber
class node_backend,node_detect_api,node_reanalyze toneMint
class node_detector,node_deep toneRose
class node_hash,node_embedder,node_fast,node_store,node_seed,node_launcher toneIndigo
```

## Components

### Mobile capture

- [Capture trigger](https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/lib/overlay/trigger_button.dart): `frontend/bridge_ui/lib/overlay/trigger_button.dart`
- [Screen capture](https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/android/app/src/main/kotlin/com/bridgeui/bridge_ui/MainActivity.kt): `frontend/bridge_ui/android/app/src/main/kotlin/com/bridgeui/bridge_ui/MainActivity.kt`
- [Projection service](https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/android/app/src/main/kotlin/com/bridgeui/bridge_ui/MediaProjectionForegroundService.kt): `frontend/bridge_ui/android/app/src/main/kotlin/com/bridgeui/bridge_ui/MediaProjectionForegroundService.kt`
- [Capture service](https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/lib/capture/capture_service.dart): `frontend/bridge_ui/lib/capture/capture_service.dart`

### Selection and guidance

- [UI scanner](https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/lib/capture/ui_scanner.dart): `frontend/bridge_ui/lib/capture/ui_scanner.dart`
- [Element extractor](https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/lib/capture/element_extractor.dart): `frontend/bridge_ui/lib/capture/element_extractor.dart`
- [Freeze overlay](https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/lib/overlay/freeze_overlay.dart): `frontend/bridge_ui/lib/overlay/freeze_overlay.dart`
- [Capture sender](https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/lib/capture/capture_sender.dart): `frontend/bridge_ui/lib/capture/capture_sender.dart`
- [Result bubble](https://github.com/scythe0425/bridgeui/blob/main/frontend/bridge_ui/lib/overlay/result_bubble.dart): `frontend/bridge_ui/lib/overlay/result_bubble.dart`

### Backend API

- [Capture API](https://github.com/scythe0425/bridgeui/blob/main/backend/main.py): `backend/main.py`
- [Detection API](https://github.com/scythe0425/bridgeui/blob/main/backend/main.py): `backend/main.py`
- [Reanalysis API](https://github.com/scythe0425/bridgeui/blob/main/backend/main.py): `backend/main.py`

### UI analysis

- [OmniParser detector](https://github.com/scythe0425/bridgeui/blob/main/backend/pipeline/ui_detector.py): `backend/pipeline/ui_detector.py`
- [Gemini explanation](https://github.com/scythe0425/bridgeui/blob/main/backend/pipeline/deep_track.py): `backend/pipeline/deep_track.py`

### Matching and storage

- [pHash stage](https://github.com/scythe0425/bridgeui/blob/main/backend/pipeline/hash_track.py): `backend/pipeline/hash_track.py`
- [CLIP embedder](https://github.com/scythe0425/bridgeui/blob/main/backend/pipeline/embedder.py): `backend/pipeline/embedder.py`
- [CLIP search](https://github.com/scythe0425/bridgeui/blob/main/backend/pipeline/fast_track.py): `backend/pipeline/fast_track.py`
- [ChromaDB store](https://github.com/scythe0425/bridgeui/blob/main/backend/db/chroma_store.py): `backend/db/chroma_store.py`
- [Seed catalog](https://github.com/scythe0425/bridgeui/blob/main/backend/db/seed_db.py): `backend/db/seed_db.py`

### Other components

- **Phone user**
- **Target app**

## Connections

- Phone user → Target app: opens app (evidence: `README.md`)
- Phone user → Capture trigger: starts capture (evidence: `README.md`)
- Capture trigger → Screen capture: requests screen
- Screen capture → Projection service: starts and binds (evidence: `frontend/bridge_ui/android/app/src/main/kotlin/com/bridgeui/bridge_ui/MainActivity.kt`)
- Screen capture → Capture service: provides screenshot
- Phone user → Freeze overlay: selects crop (evidence: `README.md`)
- Freeze overlay → UI scanner: requests detections (evidence: `README.md`)
- UI scanner → Detection API: posts screenshot (evidence: `README.md`)
- Phone user → Element extractor: chooses element (evidence: `README.md`)
- Element extractor → Capture sender: provides selection
- Capture sender → Capture API: posts capture (evidence: `README.md`)
- Detection API → OmniParser detector: runs detection (evidence: `backend/main.py`)
- Capture API → OmniParser detector: selects UI element (evidence: `backend/main.py`)
- Capture API → pHash stage: checks pHash (evidence: `backend/main.py`)
- Capture API → CLIP embedder: embeds cache miss (evidence: `backend/main.py`)
- Capture API → CLIP search: searches vector (evidence: `backend/main.py`)
- CLIP search → ChromaDB store: queries vectors (evidence: `backend/pipeline/fast_track.py`)
- Capture API → Gemini explanation: explains cache miss (evidence: `backend/main.py`)
- Capture API → ChromaDB store: writes explanation (evidence: `backend/main.py`)
- Capture API → pHash stage: registers new hash (evidence: `backend/main.py`)
- Seed catalog → ChromaDB store: seeds entries (evidence: `backend/db/seed_db.py`)
- Capture API → Result bubble: returns explanation (evidence: `README.md`)
- Phone user → Result bubble: reads guidance (evidence: `README.md`)
- Phone user → Reanalysis API: requests reanalysis (evidence: `README.md`)
- Reanalysis API → Gemini explanation: forces explanation (evidence: `backend/main.py`)
- Reanalysis API → ChromaDB store: updates entry (evidence: `backend/main.py`)
