# petergilles/luxasrlive architecture

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

- Interactive diagram: https://gitdiagram.com/petergilles/luxasrlive
- Repository: https://github.com/petergilles/luxasrlive

## Overview

Live ASR gateway streams browser audio over WebSocket, applies VAD, repeatedly decodes a growing PCM window with Whisper, and commits stable text while retaining a partial tail. Committed text can optionally be translated through Ollama; the browser presents transcription and translation panes and supports microphone or loopback capture. The gateway is the orchestration layer for sessions, buffering, decoding, commit policy, and translation. Internal gateway stages are documented in the README and excerpts; some implementation details are unsampled, so those relationships rely on the README where noted.

Main entry points: [`ws_gateway.py`](https://github.com/petergilles/luxasrlive/blob/main/ws_gateway.py) (WebSocket sessions), [`static/client.js`](https://github.com/petergilles/luxasrlive/blob/main/static/client.js) (Capture and controls), [`whisper_engine.py`](https://github.com/petergilles/luxasrlive/blob/main/whisper_engine.py) (Whisper engine), [`utils/translation.py`](https://github.com/petergilles/luxasrlive/blob/main/utils/translation.py) (Ollama translation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser client"]
  node_audio_source["Microphone / loopback<br/>[client.js]"]
  node_browser_client["Capture and controls<br/>[client.js]"]
  node_caption_ui["Caption panes<br/>[index.html]"]
end

subgraph group_gateway["Stream gateway"]
  node_gateway_app["WebSocket sessions<br/>[ws_gateway.py]"]
  node_vad["Silero VAD<br/>[ws_gateway.py]"]
  node_audio_buffer["Growing PCM buffer<br/>[ws_gateway.py]"]
  node_context["Decode context<br/>[ws_gateway.py]"]
  node_postprocess["Text post-processing<br/>[ws_gateway.py]"]
end

subgraph group_asr["Recognition"]
  node_whisper["Whisper engine<br/>[whisper_engine.py]"]
  node_agreement["LocalAgreement-N<br/>[local_agreement.py]"]
end

subgraph group_translation["Translation"]
  node_translation_client["Translation client<br/>[ws_gateway.py]"]
  node_translator["Ollama translation<br/>[translation.py]"]
end

node_user(("User"))
node_ollama["Ollama"]

node_user -->|"starts capture"| node_audio_source
node_audio_source -->|"provides audio"| node_browser_client
node_browser_client -->|"streams PCM"| node_gateway_app
node_gateway_app -->|"checks speech"| node_vad
node_gateway_app -->|"appends PCM"| node_audio_buffer
node_gateway_app -->|"gets context"| node_context
node_gateway_app -->|"decodes window"| node_whisper
node_whisper -->|"filters words"| node_agreement
node_gateway_app -->|"commits prefix"| node_agreement
node_gateway_app -.->|"processes text"| node_postprocess
node_gateway_app -->|"translates commits"| node_translation_client
node_translation_client -->|"requests translation"| node_translator
node_translator -->|"sends chat request"| node_ollama
node_gateway_app -->|"sends results"| node_browser_client
node_browser_client -->|"renders captions"| node_caption_ui

click node_audio_source "https://github.com/petergilles/luxasrlive/blob/main/static/client.js"
click node_browser_client "https://github.com/petergilles/luxasrlive/blob/main/static/client.js"
click node_caption_ui "https://github.com/petergilles/luxasrlive/blob/main/templates/index.html"
click node_gateway_app "https://github.com/petergilles/luxasrlive/blob/main/ws_gateway.py"
click node_vad "https://github.com/petergilles/luxasrlive/blob/main/ws_gateway.py"
click node_audio_buffer "https://github.com/petergilles/luxasrlive/blob/main/ws_gateway.py"
click node_context "https://github.com/petergilles/luxasrlive/blob/main/ws_gateway.py"
click node_whisper "https://github.com/petergilles/luxasrlive/blob/main/whisper_engine.py"
click node_agreement "https://github.com/petergilles/luxasrlive/blob/main/local_agreement.py"
click node_postprocess "https://github.com/petergilles/luxasrlive/blob/main/ws_gateway.py"
click node_translation_client "https://github.com/petergilles/luxasrlive/blob/main/ws_gateway.py"
click node_translator "https://github.com/petergilles/luxasrlive/blob/main/utils/translation.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_audio_source,node_browser_client,node_caption_ui,node_user toneBlue
class node_gateway_app,node_vad,node_audio_buffer,node_context,node_postprocess toneAmber
class node_whisper,node_agreement toneMint
class node_translation_client,node_translator toneRose
class node_ollama toneIndigo
```

## Components

### Browser client

- [Microphone / loopback](https://github.com/petergilles/luxasrlive/blob/main/static/client.js): `static/client.js`
- [Capture and controls](https://github.com/petergilles/luxasrlive/blob/main/static/client.js): `static/client.js`
- [Caption panes](https://github.com/petergilles/luxasrlive/blob/main/templates/index.html): `templates/index.html`

### Stream gateway

- [WebSocket sessions](https://github.com/petergilles/luxasrlive/blob/main/ws_gateway.py): `ws_gateway.py`
- [Silero VAD](https://github.com/petergilles/luxasrlive/blob/main/ws_gateway.py): `ws_gateway.py`
- [Growing PCM buffer](https://github.com/petergilles/luxasrlive/blob/main/ws_gateway.py): `ws_gateway.py`
- [Decode context](https://github.com/petergilles/luxasrlive/blob/main/ws_gateway.py): `ws_gateway.py`
- [Text post-processing](https://github.com/petergilles/luxasrlive/blob/main/ws_gateway.py): `ws_gateway.py`

### Recognition

- [Whisper engine](https://github.com/petergilles/luxasrlive/blob/main/whisper_engine.py): `whisper_engine.py`
- [LocalAgreement-N](https://github.com/petergilles/luxasrlive/blob/main/local_agreement.py): `local_agreement.py`

### Translation

- [Translation client](https://github.com/petergilles/luxasrlive/blob/main/ws_gateway.py): `ws_gateway.py`
- [Ollama translation](https://github.com/petergilles/luxasrlive/blob/main/utils/translation.py): `utils/translation.py`

### Other components

- **User**
- **Ollama**

## Connections

- User → Microphone / loopback: starts capture (evidence: `README.md`)
- Microphone / loopback → Capture and controls: provides audio (evidence: `README.md`)
- Capture and controls → WebSocket sessions: streams PCM (evidence: `README.md`)
- WebSocket sessions → Silero VAD: checks speech (evidence: `README.md`)
- WebSocket sessions → Growing PCM buffer: appends PCM (evidence: `README.md`)
- WebSocket sessions → Decode context: gets context (evidence: `ws_gateway.py`)
- WebSocket sessions → Whisper engine: decodes window (evidence: `ws_gateway.py`)
- Whisper engine → LocalAgreement-N: filters words (evidence: `whisper_engine.py`)
- WebSocket sessions → LocalAgreement-N: commits prefix (evidence: `ws_gateway.py`)
- WebSocket sessions → Text post-processing: processes text (evidence: `ws_gateway.py`)
- WebSocket sessions → Translation client: translates commits (evidence: `ws_gateway.py`)
- Translation client → Ollama translation: requests translation (evidence: `ws_gateway.py`)
- Ollama translation → Ollama: sends chat request (evidence: `utils/translation.py`)
- WebSocket sessions → Capture and controls: sends results (evidence: `README.md`)
- Capture and controls → Caption panes: renders captions (evidence: `README.md`)
