# xiaokunshi5-lang/harry-translate-v2 architecture

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

- Interactive diagram: https://gitdiagram.com/xiaokunshi5-lang/harry-translate-v2
- Repository: https://github.com/xiaokunshi5-lang/harry-translate-v2

## Overview

HARRY Translate V2 is a desktop real-time interpretation app: it captures microphone or system audio, sends framed audio to a realtime translation engine, and presents source and translated subtitles in an overlay. The backend also manages sessions, glossary terms, silent correction, and optional summaries; the React UI provides monitoring and configuration, while Tauri hosts native windows. The README documents these capabilities; sampled excerpts and the source index support the main component boundaries, but not every runtime wiring detail, so uncertain links are omitted.

Main entry points: [`app/main.py`](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/main.py) (Backend API), [`app/session_manager.py`](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/session_manager.py) (Session Manager), [`frontend/src/App.tsx`](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/frontend/src/App.tsx) (UI Router), [`app/engines/registry.py`](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/engines/registry.py) (Engine Registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Audio Capture"]
  node_audio_backends["Capture Backends<br/>[backend.py]"]
  node_wasapi["WASAPI Capture<br/>[wasapi.py]"]
  node_audio_pipeline["Frame and AGC Pipeline<br/>[pipeline.py]"]
  node_audio_mixer["Audio Mixer<br/>[mixer.py]"]
end

subgraph group_backend["Translation Backend"]
  node_api["Backend API<br/>[main.py]"]
  node_sessions["Session Manager<br/>[session_manager.py]"]
  node_engine_registry["Engine Registry<br/>[registry.py]"]
  node_engine_contract["Realtime Engine Contract<br/>[base.py]"]
  node_qwen["Qwen Realtime<br/>[qwen_realtime.py]"]
  node_settings_store[("Settings Store<br/>[config_store.py]")]
  node_glossary[("Glossary Store<br/>[store.py]")]
  node_glossary_engine["Glossary Matching<br/>[engine.py]"]
  node_cleaner["Transcript Cleaner"]
  node_correction["Silent Correction<br/>[patch_worker.py]"]
  node_summary["Key Point Summary<br/>[summary_worker.py]"]
end

subgraph group_frontend["User Interface"]
  node_app_entry["UI Router<br/>[App.tsx]"]
  node_monitor["Monitor Screens<br/>[MonitorScreens.tsx]"]
  node_settings_ui["Settings View<br/>[SettingsView.tsx]"]
  node_overlay["Subtitle Overlay<br/>[OverlayWindow.tsx]"]
  node_ws_client["WebSocket Client<br/>[wsClient.ts]"]
  node_api_client["HTTP Client<br/>[apiClient.ts]"]
end

subgraph group_native["Desktop Host"]
  node_tauri["Tauri Host<br/>[lib.rs]"]
  node_sidecar["Backend Sidecar<br/>[sidecar.rs]"]
  node_native_windows["Native Windows<br/>[overlay.rs]"]
end

node_user(("User"))
node_audio(("Audio Devices"))
node_translation_service(("Qwen Service"))

node_audio -->|"provides input"| node_audio_backends
node_audio -->|"provides loopback"| node_wasapi
node_audio_backends -->|"feeds audio"| node_audio_pipeline
node_wasapi -->|"frames audio"| node_audio_pipeline
node_audio_mixer -->|"uses framing"| node_audio_pipeline
node_api -->|"configures capture"| node_audio_mixer
node_api -->|"manages sessions"| node_sessions
node_sessions -->|"selects engine"| node_engine_registry
node_engine_registry -->|"implements contract"| node_engine_contract
node_engine_registry -->|"registers provider"| node_qwen
node_qwen -->|"streams audio"| node_translation_service
node_sessions -->|"cleans transcripts"| node_cleaner
node_sessions -->|"applies fixes"| node_glossary_engine
node_glossary -->|"builds term indexes"| node_glossary_engine
node_api -->|"loads settings"| node_settings_store
node_api -->|"starts worker"| node_correction
node_api -->|"starts worker"| node_summary
node_user -->|"opens app"| node_app_entry
node_app_entry -->|"routes monitor"| node_monitor
node_app_entry -->|"routes settings"| node_settings_ui
node_app_entry -->|"routes overlay"| node_overlay
node_monitor -.->|"receives events"| node_ws_client
node_settings_ui -->|"requests settings"| node_api_client
node_ws_client -->|"exchanges events"| node_api
node_api_client -->|"calls endpoints"| node_api
node_tauri -->|"manages process"| node_sidecar
node_tauri -.->|"hosts windows"| node_native_windows
node_sidecar -->|"launches backend"| node_api
node_user -->|"speaks or plays"| node_audio

click node_audio_backends "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/audio/backend.py"
click node_wasapi "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/audio/wasapi.py"
click node_audio_pipeline "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/audio/pipeline.py"
click node_audio_mixer "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/audio/mixer.py"
click node_api "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/main.py"
click node_sessions "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/session_manager.py"
click node_engine_registry "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/engines/registry.py"
click node_engine_contract "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/engines/base.py"
click node_qwen "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/engines/qwen_realtime.py"
click node_settings_store "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/config_store.py"
click node_glossary "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/glossary/store.py"
click node_glossary_engine "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/glossary/engine.py"
click node_cleaner "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/transcript_cleaner.py"
click node_correction "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/bypass/patch_worker.py"
click node_summary "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/bypass/summary_worker.py"
click node_app_entry "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/frontend/src/App.tsx"
click node_monitor "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/frontend/src/screens/MonitorScreens.tsx"
click node_settings_ui "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/frontend/src/screens/SettingsView.tsx"
click node_overlay "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/frontend/src/windows/overlay/OverlayWindow.tsx"
click node_ws_client "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/frontend/src/shared/wsClient.ts"
click node_api_client "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/frontend/src/shared/apiClient.ts"
click node_tauri "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/src-tauri/src/lib.rs"
click node_sidecar "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/src-tauri/src/sidecar.rs"
click node_native_windows "https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/src-tauri/src/windows/overlay.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_audio_backends,node_wasapi,node_audio_pipeline,node_audio_mixer,node_user toneBlue
class node_api,node_sessions,node_engine_registry,node_engine_contract,node_qwen,node_settings_store,node_glossary,node_glossary_engine,node_cleaner,node_correction,node_summary toneAmber
class node_app_entry,node_monitor,node_settings_ui,node_overlay,node_ws_client,node_api_client toneMint
class node_tauri,node_sidecar,node_native_windows toneRose
class node_audio,node_translation_service toneIndigo
```

## Components

### Audio Capture

- [Capture Backends](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/audio/backend.py): `app/audio/backend.py`
- [WASAPI Capture](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/audio/wasapi.py): `app/audio/wasapi.py`
- [Frame and AGC Pipeline](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/audio/pipeline.py): `app/audio/pipeline.py`
- [Audio Mixer](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/audio/mixer.py): `app/audio/mixer.py`

### Translation Backend

- [Backend API](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/main.py): `app/main.py`
- [Session Manager](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/session_manager.py): `app/session_manager.py`
- [Engine Registry](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/engines/registry.py): `app/engines/registry.py`
- [Realtime Engine Contract](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/engines/base.py): `app/engines/base.py`
- [Qwen Realtime](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/engines/qwen_realtime.py): `app/engines/qwen_realtime.py`
- [Settings Store](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/config_store.py): `app/config_store.py`
- [Glossary Store](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/glossary/store.py): `app/glossary/store.py`
- [Glossary Matching](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/glossary/engine.py): `app/glossary/engine.py`
- [Transcript Cleaner](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/transcript_cleaner.py): `app/transcript_cleaner.py`
- [Silent Correction](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/bypass/patch_worker.py): `app/bypass/patch_worker.py`
- [Key Point Summary](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/app/bypass/summary_worker.py): `app/bypass/summary_worker.py`

### User Interface

- [UI Router](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Monitor Screens](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/frontend/src/screens/MonitorScreens.tsx): `frontend/src/screens/MonitorScreens.tsx`
- [Settings View](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/frontend/src/screens/SettingsView.tsx): `frontend/src/screens/SettingsView.tsx`
- [Subtitle Overlay](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/frontend/src/windows/overlay/OverlayWindow.tsx): `frontend/src/windows/overlay/OverlayWindow.tsx`
- [WebSocket Client](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/frontend/src/shared/wsClient.ts): `frontend/src/shared/wsClient.ts`
- [HTTP Client](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/frontend/src/shared/apiClient.ts): `frontend/src/shared/apiClient.ts`

### Desktop Host

- [Tauri Host](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/src-tauri/src/lib.rs): `src-tauri/src/lib.rs`
- [Backend Sidecar](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/src-tauri/src/sidecar.rs): `src-tauri/src/sidecar.rs`
- [Native Windows](https://github.com/xiaokunshi5-lang/harry-translate-v2/blob/main/src-tauri/src/windows/overlay.rs): `src-tauri/src/windows/overlay.rs`

### Other components

- **User**
- **Audio Devices**
- **Qwen Service**

## Connections

- Audio Devices → Capture Backends: provides input (evidence: `README.md`)
- Audio Devices → WASAPI Capture: provides loopback (evidence: `README.md`)
- Capture Backends → Frame and AGC Pipeline: feeds audio (evidence: `app/audio/backend.py`)
- WASAPI Capture → Frame and AGC Pipeline: frames audio (evidence: `app/audio/wasapi.py`)
- Audio Mixer → Frame and AGC Pipeline: uses framing (evidence: `app/audio/mixer.py`)
- Backend API → Audio Mixer: configures capture (evidence: `app/main.py`)
- Backend API → Session Manager: manages sessions (evidence: `app/main.py`)
- Session Manager → Engine Registry: selects engine (evidence: `app/session_manager.py`)
- Engine Registry → Realtime Engine Contract: implements contract (evidence: `app/engines/registry.py`)
- Engine Registry → Qwen Realtime: registers provider (evidence: `app/engines/registry.py`)
- Qwen Realtime → Qwen Service: streams audio (evidence: `README.md`)
- Session Manager → Transcript Cleaner: cleans transcripts (evidence: `app/session_manager.py`)
- Session Manager → Glossary Matching: applies fixes (evidence: `app/session_manager.py`)
- Glossary Store → Glossary Matching: builds term indexes (evidence: `app/glossary/store.py`)
- Backend API → Settings Store: loads settings (evidence: `app/main.py`)
- Backend API → Silent Correction: starts worker (evidence: `app/main.py`)
- Backend API → Key Point Summary: starts worker (evidence: `app/main.py`)
- User → UI Router: opens app (evidence: `frontend/src/App.tsx`)
- UI Router → Monitor Screens: routes monitor (evidence: `frontend/src/App.tsx`)
- UI Router → Settings View: routes settings (evidence: `frontend/src/App.tsx`)
- UI Router → Subtitle Overlay: routes overlay (evidence: `frontend/src/App.tsx`)
- Monitor Screens → WebSocket Client: receives events
- Settings View → HTTP Client: requests settings (evidence: `frontend/src/screens/SettingsView.tsx`)
- WebSocket Client → Backend API: exchanges events (evidence: `README.md`)
- HTTP Client → Backend API: calls endpoints (evidence: `README.md`)
- Tauri Host → Backend Sidecar: manages process (evidence: `src-tauri/src/lib.rs`)
- Tauri Host → Native Windows: hosts windows
- Backend Sidecar → Backend API: launches backend (evidence: `src-tauri/src/sidecar.rs`)
- User → Audio Devices: speaks or plays (evidence: `README.md`)
