# styayur/tinystt architecture

> Architecture diagram of the GitHub repository styayur/tinystt, 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/styayur/tinystt
- Repository: https://github.com/styayur/tinystt

## Overview

TinySTT is an offline Windows push-to-talk speech-to-text app, with a separate microphone-free WAV recognition mode. The main workflow captures and bounds microphone audio, sends it to a persistent SenseVoice worker, then displays and copies the transcript, with optional paste. The graph also preserves configuration, tray/hotkey controls, debug WAV export, and CLI recognition. Some wiring is supported by README descriptions and module references; unsampled implementation details are not inferred as confirmed calls.

Main entry points: [`src/app.rs`](https://github.com/styayur/tinystt/blob/main/src/app.rs) (Desktop UI), [`src/asr/worker.rs`](https://github.com/styayur/tinystt/blob/main/src/asr/worker.rs) (ASR worker), [`src/hotkey.rs`](https://github.com/styayur/tinystt/blob/main/src/hotkey.rs) (Global hotkey), [`src/audio/capture.rs`](https://github.com/styayur/tinystt/blob/main/src/audio/capture.rs) (Microphone capture)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["App interaction"]
  node_window["Desktop UI<br/>[app.rs]"]
  node_lifecycle["App state<br/>[state.rs]"]
  node_global_hotkey["Global hotkey<br/>[hotkey.rs]"]
  node_tray["Tray menu<br/>[tray.rs]"]
  node_cli["CLI entry point<br/>[main.rs]"]
end

subgraph group_audio["Audio capture"]
  node_recording_pipeline["Recording pipeline<br/>[pipeline.rs]"]
  node_microphone["Microphone capture<br/>[capture.rs]"]
  node_sample_conversion["Sample conversion<br/>[convert.rs]"]
  node_recording_buffer["Bounded buffer<br/>[buffer.rs]"]
  node_wav_tools["WAV tools<br/>[wav.rs]"]
end

subgraph group_recognition["Speech recognition"]
  node_asr_worker["ASR worker<br/>[worker.rs]"]
  node_recognizer_contract["Recognizer interface<br/>[mod.rs]"]
  node_sensevoice["SenseVoice engine<br/>[sensevoice.rs]"]
end

subgraph group_platform["Local platform services"]
  node_settings["Settings<br/>[settings.rs]"]
  node_paths["Path and model discovery<br/>[paths.rs]"]
  node_clipboard["Clipboard<br/>[clipboard.rs]"]
  node_auto_paste["Optional auto-paste<br/>[paste.rs]"]
  node_runtime_log["Runtime logging<br/>[log.rs]"]
end

node_user(("User"))
node_windows(("Windows desktop"))
node_model_files["Local model files"]

node_user -->|"controls"| node_window
node_user -->|"presses shortcut"| node_global_hotkey
node_global_hotkey -.->|"triggers recording"| node_window
node_window -->|"starts or stops"| node_recording_pipeline
node_recording_pipeline -->|"starts capture"| node_microphone
node_microphone -->|"converts samples"| node_sample_conversion
node_microphone -->|"appends samples"| node_recording_buffer
node_window -->|"submits audio"| node_asr_worker
node_asr_worker -->|"runs inference"| node_sensevoice
node_sensevoice -->|"implements"| node_recognizer_contract
node_asr_worker -->|"resolves model"| node_paths
node_asr_worker -->|"reads inference options"| node_settings
node_model_files -->|"provides weights"| node_sensevoice
node_asr_worker -->|"returns transcript events"| node_window
node_window -->|"copies transcript"| node_clipboard
node_window -->|"optionally invokes"| node_auto_paste
node_window -.->|"updates state"| node_lifecycle
node_window -.->|"handles tray actions"| node_tray
node_window -.->|"loads and saves"| node_settings
node_settings -->|"configures model location"| node_paths
node_window -->|"exports debug audio"| node_wav_tools
node_cli -->|"reads WAV audio"| node_wav_tools
node_cli -.->|"recognizes WAV"| node_asr_worker
node_tray -.->|"integrates with desktop"| node_windows
node_global_hotkey -.->|"registers shortcut"| node_windows
node_clipboard -.->|"writes text"| node_windows
node_auto_paste -.->|"sends Ctrl+V"| node_windows
node_window -.->|"records runtime events"| node_runtime_log

click node_window "https://github.com/styayur/tinystt/blob/main/src/app.rs"
click node_lifecycle "https://github.com/styayur/tinystt/blob/main/src/state.rs"
click node_global_hotkey "https://github.com/styayur/tinystt/blob/main/src/hotkey.rs"
click node_tray "https://github.com/styayur/tinystt/blob/main/src/tray.rs"
click node_recording_pipeline "https://github.com/styayur/tinystt/blob/main/src/pipeline.rs"
click node_microphone "https://github.com/styayur/tinystt/blob/main/src/audio/capture.rs"
click node_sample_conversion "https://github.com/styayur/tinystt/blob/main/src/audio/convert.rs"
click node_recording_buffer "https://github.com/styayur/tinystt/blob/main/src/audio/buffer.rs"
click node_wav_tools "https://github.com/styayur/tinystt/blob/main/src/audio/wav.rs"
click node_asr_worker "https://github.com/styayur/tinystt/blob/main/src/asr/worker.rs"
click node_recognizer_contract "https://github.com/styayur/tinystt/blob/main/src/asr/mod.rs"
click node_sensevoice "https://github.com/styayur/tinystt/blob/main/src/asr/sensevoice.rs"
click node_cli "https://github.com/styayur/tinystt/blob/main/src/main.rs"
click node_settings "https://github.com/styayur/tinystt/blob/main/src/settings.rs"
click node_paths "https://github.com/styayur/tinystt/blob/main/src/paths.rs"
click node_clipboard "https://github.com/styayur/tinystt/blob/main/src/clipboard.rs"
click node_auto_paste "https://github.com/styayur/tinystt/blob/main/src/paste.rs"
click node_runtime_log "https://github.com/styayur/tinystt/blob/main/src/log.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_window,node_lifecycle,node_global_hotkey,node_tray,node_cli,node_user toneBlue
class node_recording_pipeline,node_microphone,node_sample_conversion,node_recording_buffer,node_wav_tools toneAmber
class node_asr_worker,node_recognizer_contract,node_sensevoice toneMint
class node_settings,node_paths,node_clipboard,node_auto_paste,node_runtime_log toneRose
class node_windows,node_model_files toneIndigo
```

## Components

### App interaction

- [Desktop UI](https://github.com/styayur/tinystt/blob/main/src/app.rs): `src/app.rs`
- [App state](https://github.com/styayur/tinystt/blob/main/src/state.rs): `src/state.rs`
- [Global hotkey](https://github.com/styayur/tinystt/blob/main/src/hotkey.rs): `src/hotkey.rs`
- [Tray menu](https://github.com/styayur/tinystt/blob/main/src/tray.rs): `src/tray.rs`
- [CLI entry point](https://github.com/styayur/tinystt/blob/main/src/main.rs): `src/main.rs`

### Audio capture

- [Recording pipeline](https://github.com/styayur/tinystt/blob/main/src/pipeline.rs): `src/pipeline.rs`
- [Microphone capture](https://github.com/styayur/tinystt/blob/main/src/audio/capture.rs): `src/audio/capture.rs`
- [Sample conversion](https://github.com/styayur/tinystt/blob/main/src/audio/convert.rs): `src/audio/convert.rs`
- [Bounded buffer](https://github.com/styayur/tinystt/blob/main/src/audio/buffer.rs): `src/audio/buffer.rs`
- [WAV tools](https://github.com/styayur/tinystt/blob/main/src/audio/wav.rs): `src/audio/wav.rs`

### Speech recognition

- [ASR worker](https://github.com/styayur/tinystt/blob/main/src/asr/worker.rs): `src/asr/worker.rs`
- [Recognizer interface](https://github.com/styayur/tinystt/blob/main/src/asr/mod.rs): `src/asr/mod.rs`
- [SenseVoice engine](https://github.com/styayur/tinystt/blob/main/src/asr/sensevoice.rs): `src/asr/sensevoice.rs`

### Local platform services

- [Settings](https://github.com/styayur/tinystt/blob/main/src/settings.rs): `src/settings.rs`
- [Path and model discovery](https://github.com/styayur/tinystt/blob/main/src/paths.rs): `src/paths.rs`
- [Clipboard](https://github.com/styayur/tinystt/blob/main/src/clipboard.rs): `src/clipboard.rs`
- [Optional auto-paste](https://github.com/styayur/tinystt/blob/main/src/paste.rs): `src/paste.rs`
- [Runtime logging](https://github.com/styayur/tinystt/blob/main/src/log.rs): `src/log.rs`

### Other components

- **User**
- **Windows desktop**
- **Local model files**

## Connections

- User → Desktop UI: controls (evidence: `README.md`)
- User → Global hotkey: presses shortcut (evidence: `README.md`)
- Global hotkey → Desktop UI: triggers recording (evidence: `src/app.rs`)
- Desktop UI → Recording pipeline: starts or stops (evidence: `src/app.rs`)
- Recording pipeline → Microphone capture: starts capture (evidence: `src/pipeline.rs`)
- Microphone capture → Sample conversion: converts samples (evidence: `src/audio/capture.rs`)
- Microphone capture → Bounded buffer: appends samples (evidence: `src/audio/capture.rs`)
- Desktop UI → ASR worker: submits audio (evidence: `README.md`)
- ASR worker → SenseVoice engine: runs inference (evidence: `src/asr/worker.rs`)
- SenseVoice engine → Recognizer interface: implements (evidence: `src/asr/sensevoice.rs`)
- ASR worker → Path and model discovery: resolves model (evidence: `src/asr/worker.rs`)
- ASR worker → Settings: reads inference options (evidence: `src/asr/worker.rs`)
- Local model files → SenseVoice engine: provides weights (evidence: `README.md`)
- ASR worker → Desktop UI: returns transcript events (evidence: `src/app.rs`)
- Desktop UI → Clipboard: copies transcript (evidence: `src/app.rs`)
- Desktop UI → Optional auto-paste: optionally invokes (evidence: `src/app.rs`)
- Desktop UI → App state: updates state (evidence: `src/app.rs`)
- Desktop UI → Tray menu: handles tray actions (evidence: `src/app.rs`)
- Desktop UI → Settings: loads and saves (evidence: `src/app.rs`)
- Settings → Path and model discovery: configures model location (evidence: `src/paths.rs`)
- Desktop UI → WAV tools: exports debug audio (evidence: `README.md`)
- CLI entry point → WAV tools: reads WAV audio (evidence: `README.md`)
- CLI entry point → ASR worker: recognizes WAV
- Tray menu → Windows desktop: integrates with desktop
- Global hotkey → Windows desktop: registers shortcut
- Clipboard → Windows desktop: writes text
- Optional auto-paste → Windows desktop: sends Ctrl+V
- Desktop UI → Runtime logging: records runtime events (evidence: `src/app.rs`)
