# sitelift/chirp architecture

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

- Interactive diagram: https://gitdiagram.com/sitelift/chirp
- Repository: https://github.com/sitelift/chirp

## Overview

1. **Overall shape**
   - Chirp is a **desktop voice-to-text app** built as a **Tauri 2** shell: **React/TypeScript frontend** for UI and **Rust backend** for all OS- and audio-sensitive work.
   - There is **no remote backend** in the runtime path. The core user journey is fully local and offline after model download.

2. **Primary runtime boundary**
   - The **frontend** owns screens, overlays, onboarding, settings, and user interaction.
   - The **Rust backend** owns system hotkeys, audio capture, transcription, text cleanup, text injection, persistence, and model/runtime integration.
   - Communication crosses the Tauri command/event boundary; the UI reacts to backend state rather than controlling OS devices directly.

3. **User interaction flow**
   - A **global hotkey** starts or stops recording.
   - The app shows a small **overlay** with states such as listening, processing, polishing, done, or error.
   - The result is inserted at the current cursor position in whatever app is focused.

4. **Audio + transcription pipeline**
   - Audio capture is handled natively in Rust using **cpal**.
   - The speech model is **NVIDIA Parakeet TDT** running through **sherpa-onnx**.
   - This is the first major processing stage: microphone audio becomes raw transcript text.

5. **Cleanup / “polishing” stage**
   - After transcription, Chirp can pass text through a **local LLM** for cleanup: filler-word removal, punctuation, grammar, and formatting.
   - The README says this uses **llama-server** locally.
   - This stage is optional/feature-driven and sits after ASR, before insertion.

6. **Text output to other apps**
   - Final text is inserted via **enigo** using clipboard and keystroke simulation.
   - This is an important architectural boundary: Chirp does not “integrate” with target apps; it **emulates user input** into the active window.

7. **Persistence and user data**
   - The backend modules for **settings, history, snippets, dictionary, and feedback** indicate local app state is persisted and reused across sessions.
   - The frontend settings pages are essentially a view/editor over backend-managed state, including hotkey configuration, vocabulary entries, saved snippets, and transcription history.

8. **Onboarding and model acquisition**
   - First launch includes onboarding steps such as permissions, model download, and optional help-improve flows.
   - The app expects a large speech model download on first run; after that, it runs offline.
   - The frontend has dedicated onboarding components, while the backend likely manages the actual download/state transitions.

9. **Platform-specific native layer**
   - The Rust side is split into modules such as **hotkey**, **native_hotkey**, **audio**, **inject**, and **transcribe**, suggesting clear OS integration boundaries.
   - The repo includes separate Tauri configs and entitlements for **Windows** and **macOS**, plus platform assets/icons and an installer wrapper.

10. **Frontend structure**
   - `src/App.tsx` and `src/main.tsx` bootstrap the React app.
   - UI is organized into:
     - **onboarding**
     - **overlay**
     - **settings**
     - **shared UI components**
   - A central store (`src/stores/appStore.ts`) and hooks (`useSettingsSync`, `useRecording`, `useTauri`, etc.) connect UI state to backend events.

11. **Assets and offline bundles**
   - Sounds, brand assets, and model-related files are checked in or packaged alongside the app.
   - The `src-tauri/sherpa-onnx-lib` directory contains the native library interface needed for speech runtime integration.
   - The installer assets under `src-tauri/installer` show that packaging is part of the repo’s deliverable, not an external concern.

12. **Non-runtime subsystems**
   - `training/` is a separate offline ML pipeline for generating and tuning cleanup models and exporting ONNX/GGUF artifacts.
   - `scripts/` contains benchmark and release tooling.
   - These directories support model development and release engineering, but they are not in the normal end-user execution path.

13. **What to draw in an architecture diagram**
   - A good diagram should center on:
     - **Keyboard hotkey → Rust backend**
     - **Microphone audio capture → ASR model**
     - **Transcript → optional LLM cleanup**
     - **Final text → injection into active app**
     - **Backend state → React UI overlay/settings**
   - Surround that with local persisted data, model assets, and platform-specific native integrations.

Main entry points: [`src-tauri/src/state.rs`](https://github.com/sitelift/chirp/blob/master/src-tauri/src/state.rs) (Backend State), [`src/App.tsx`](https://github.com/sitelift/chirp/blob/master/src/App.tsx) (App Shell), [`src-tauri/src/transcribe.rs`](https://github.com/sitelift/chirp/blob/master/src-tauri/src/transcribe.rs) (ASR Pipeline), [`src-tauri/src/cleanup.rs`](https://github.com/sitelift/chirp/blob/master/src-tauri/src/cleanup.rs) (Cleanup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React UI"]
  node_app_boot["App Shell<br/>React bootstrap<br/>[App.tsx]"]
  node_onboarding["Onboarding<br/>UI flow<br/>[Onboarding.tsx]"]
  node_overlay(("Overlay<br/>UI status<br/>[Overlay.tsx]"))
  node_settings_ui["Settings<br/>UI editor<br/>[Settings.tsx]"]
  node_store{{"App Store<br/>state store<br/>[appStore.ts]"}}
  node_hooks["UI Hooks<br/>sync hooks<br/>[useTauri.ts]"]
end

subgraph group_backend["Rust Core"]
  node_commands{{"Tauri Commands<br/>bridge API<br/>[commands.rs]"}}
  node_state[("Backend State<br/>runtime state<br/>[state.rs]")]
  node_hotkey["Hotkey<br/>global shortcut<br/>[hotkey.rs]"]
  node_audio["Audio Capture<br/>microphone input<br/>[audio.rs]"]
  node_transcribe{{"ASR Pipeline<br/>speech model<br/>[transcribe.rs]"}}
  node_cleanup{{"Cleanup<br/>local LLM stage<br/>[cleanup.rs]"}}
  node_llm["Llama Server<br/>LLM runtime<br/>[llm.rs]"]
  node_inject["Text Inject<br/>input emulation<br/>[inject.rs]"]
  node_settings_data[("Settings Data<br/>local persistence<br/>[settings.rs]")]
  node_history[("History<br/>local persistence<br/>[history.rs]")]
  node_snippets[("Snippets<br/>local persistence<br/>[snippets.rs]")]
  node_dictionary[("Dictionary<br/>local persistence<br/>[dictionary.rs]")]
  node_feedback[("Feedback<br/>local persistence<br/>[feedback.rs]")]
end

subgraph group_platform["Platform Layer"]
  node_native_hotkey["Native Hotkey<br/>OS integration<br/>[native_hotkey.rs]"]
  node_tauri_cfg["Tauri Config<br/>desktop packaging<br/>[tauri.conf.json]"]
  node_installer["Installer Assets<br/>packaging assets<br/>[chirp-header.bmp]"]
end

subgraph group_offline["Offline Assets"]
  node_sherpa_lib["Sherpa Lib<br/>native library<br/>[c-api.h]"]
  node_model_assets["Models & Sounds<br/>bundled assets<br/>[chirp.mp3]"]
  node_training["Training Pipeline<br/>offline ML tools<br/>[train.py]"]
  node_scripts["Release Tools<br/>dev tooling<br/>[release.sh]"]
end

node_app_boot -->|"reads/writes"| node_store
node_app_boot -->|"renders"| node_onboarding
node_app_boot -->|"renders"| node_overlay
node_app_boot -->|"renders"| node_settings_ui
node_hooks -->|"calls"| node_commands
node_overlay -->|"subscribes"| node_store
node_settings_ui -->|"edits"| node_store
node_commands -->|"routes through"| node_state
node_hotkey -->|"delegates"| node_native_hotkey
node_hotkey -->|"starts/stops"| node_audio
node_audio -->|"feeds"| node_transcribe
node_transcribe -->|"optional handoff"| node_cleanup
node_cleanup -->|"uses"| node_llm
node_cleanup -->|"outputs"| node_inject
node_transcribe -->|"outputs"| node_inject
node_inject -->|"updates"| node_state
node_settings_data -->|"persists"| node_state
node_history -->|"persists"| node_state
node_snippets -->|"persists"| node_state
node_dictionary -->|"persists"| node_state
node_feedback -->|"persists"| node_state
node_onboarding -->|"downloads/prepares"| node_model_assets
node_tauri_cfg -->|"enables"| node_commands
node_installer -->|"packages"| node_tauri_cfg
node_transcribe -->|"binds to"| node_sherpa_lib
node_scripts -->|"supports"| node_training
node_training -->|"produces"| node_model_assets

click node_app_boot "https://github.com/sitelift/chirp/blob/master/src/App.tsx"
click node_onboarding "https://github.com/sitelift/chirp/blob/master/src/components/onboarding/Onboarding.tsx"
click node_overlay "https://github.com/sitelift/chirp/blob/master/src/components/overlay/Overlay.tsx"
click node_settings_ui "https://github.com/sitelift/chirp/blob/master/src/components/settings/Settings.tsx"
click node_store "https://github.com/sitelift/chirp/blob/master/src/stores/appStore.ts"
click node_hooks "https://github.com/sitelift/chirp/blob/master/src/hooks/useTauri.ts"
click node_commands "https://github.com/sitelift/chirp/blob/master/src-tauri/src/commands.rs"
click node_state "https://github.com/sitelift/chirp/blob/master/src-tauri/src/state.rs"
click node_hotkey "https://github.com/sitelift/chirp/blob/master/src-tauri/src/hotkey.rs"
click node_audio "https://github.com/sitelift/chirp/blob/master/src-tauri/src/audio.rs"
click node_transcribe "https://github.com/sitelift/chirp/blob/master/src-tauri/src/transcribe.rs"
click node_cleanup "https://github.com/sitelift/chirp/blob/master/src-tauri/src/cleanup.rs"
click node_llm "https://github.com/sitelift/chirp/blob/master/src-tauri/src/llm.rs"
click node_inject "https://github.com/sitelift/chirp/blob/master/src-tauri/src/inject.rs"
click node_settings_data "https://github.com/sitelift/chirp/blob/master/src-tauri/src/settings.rs"
click node_history "https://github.com/sitelift/chirp/blob/master/src-tauri/src/history.rs"
click node_snippets "https://github.com/sitelift/chirp/blob/master/src-tauri/src/snippets.rs"
click node_dictionary "https://github.com/sitelift/chirp/blob/master/src-tauri/src/dictionary.rs"
click node_feedback "https://github.com/sitelift/chirp/blob/master/src-tauri/src/feedback.rs"
click node_native_hotkey "https://github.com/sitelift/chirp/blob/master/src-tauri/src/native_hotkey.rs"
click node_tauri_cfg "https://github.com/sitelift/chirp/blob/master/src-tauri/tauri.conf.json"
click node_installer "https://github.com/sitelift/chirp/blob/master/src-tauri/installer/chirp-header.bmp"
click node_sherpa_lib "https://github.com/sitelift/chirp/blob/master/src-tauri/sherpa-onnx-lib/include/sherpa-onnx/c-api/c-api.h"
click node_model_assets "https://github.com/sitelift/chirp/blob/master/public/sounds/chirp.mp3"
click node_training "https://github.com/sitelift/chirp/blob/master/training/train.py"
click node_scripts "https://github.com/sitelift/chirp/blob/master/scripts/release.sh"

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_app_boot,node_onboarding,node_overlay,node_settings_ui,node_store,node_hooks toneBlue
class node_commands,node_state,node_hotkey,node_audio,node_transcribe,node_cleanup,node_llm,node_inject,node_settings_data,node_history,node_snippets,node_dictionary,node_feedback toneAmber
class node_native_hotkey,node_tauri_cfg,node_installer toneMint
class node_sherpa_lib,node_model_assets,node_training,node_scripts toneRose
```

## Components

### React UI

Screens, overlays, and settings in the Tauri frontend.

- [App Shell](https://github.com/sitelift/chirp/blob/master/src/App.tsx): React bootstrap · Entry points that mount the UI and wire global app state. · `src/App.tsx`
- [Onboarding](https://github.com/sitelift/chirp/blob/master/src/components/onboarding/Onboarding.tsx): UI flow · First-run setup for permissions, downloads, and help-improve choices. · `src/components/onboarding/Onboarding.tsx`
- [Overlay](https://github.com/sitelift/chirp/blob/master/src/components/overlay/Overlay.tsx): UI status · Recording/status overlay with listening, processing, polishing, done, and error states. · `src/components/overlay/Overlay.tsx`
- [Settings](https://github.com/sitelift/chirp/blob/master/src/components/settings/Settings.tsx): UI editor · Settings pages for hotkeys, dictionary, snippets, history, and preferences. · `src/components/settings/Settings.tsx`
- [App Store](https://github.com/sitelift/chirp/blob/master/src/stores/appStore.ts): state store · Central frontend state shared by overlay, onboarding, and settings. · `src/stores/appStore.ts`
- [UI Hooks](https://github.com/sitelift/chirp/blob/master/src/hooks/useTauri.ts): sync hooks · React hooks that synchronize recording, settings, Tauri events, and cleanup toggles. · `src/hooks/useTauri.ts`

### Rust Core

Local runtime logic, OS integration, transcription, persistence, and injection.

- [Tauri Commands](https://github.com/sitelift/chirp/blob/master/src-tauri/src/commands.rs): bridge API · Command and event boundary between the frontend and Rust backend. · `src-tauri/src/commands.rs`
- [Backend State](https://github.com/sitelift/chirp/blob/master/src-tauri/src/state.rs): runtime state · Shared local state for app lifecycle, device status, and feature flags. · `src-tauri/src/state.rs`
- [Hotkey](https://github.com/sitelift/chirp/blob/master/src-tauri/src/hotkey.rs): global shortcut · Registers and handles the global record toggle shortcut. · `src-tauri/src/hotkey.rs`
- [Audio Capture](https://github.com/sitelift/chirp/blob/master/src-tauri/src/audio.rs): microphone input · Native microphone capture and buffering using the host audio stack. · `src-tauri/src/audio.rs`
- [ASR Pipeline](https://github.com/sitelift/chirp/blob/master/src-tauri/src/transcribe.rs): speech model · Runs Parakeet TDT via sherpa-onnx to convert audio into transcript text. · `src-tauri/src/transcribe.rs`
- [Cleanup](https://github.com/sitelift/chirp/blob/master/src-tauri/src/cleanup.rs): local LLM stage · Optional text polishing: punctuation, formatting, and filler-word removal. · `src-tauri/src/cleanup.rs`
- [Llama Server](https://github.com/sitelift/chirp/blob/master/src-tauri/src/llm.rs): LLM runtime · Local server/runtime used for cleanup and polishing generation. · `src-tauri/src/llm.rs`
- [Text Inject](https://github.com/sitelift/chirp/blob/master/src-tauri/src/inject.rs): input emulation · Inserts final text into the active app using clipboard and keystroke simulation. · `src-tauri/src/inject.rs`
- [Settings Data](https://github.com/sitelift/chirp/blob/master/src-tauri/src/settings.rs): local persistence · Stored preferences, hotkeys, and user-facing configuration. · `src-tauri/src/settings.rs`
- [History](https://github.com/sitelift/chirp/blob/master/src-tauri/src/history.rs): local persistence · Saved transcription history reused across sessions. · `src-tauri/src/history.rs`
- [Snippets](https://github.com/sitelift/chirp/blob/master/src-tauri/src/snippets.rs): local persistence · Reusable text snippets maintained locally. · `src-tauri/src/snippets.rs`
- [Dictionary](https://github.com/sitelift/chirp/blob/master/src-tauri/src/dictionary.rs): local persistence · Custom vocabulary and word normalization data. · `src-tauri/src/dictionary.rs`
- [Feedback](https://github.com/sitelift/chirp/blob/master/src-tauri/src/feedback.rs): local persistence · Stored user feedback and improve-the-model signals. · `src-tauri/src/feedback.rs`

### Platform Layer

Native packaging and OS-specific configuration.

- [Native Hotkey](https://github.com/sitelift/chirp/blob/master/src-tauri/src/native_hotkey.rs): OS integration · Platform-specific hotkey plumbing behind the shared shortcut layer. · `src-tauri/src/native_hotkey.rs`
- [Tauri Config](https://github.com/sitelift/chirp/blob/master/src-tauri/tauri.conf.json): desktop packaging · Desktop shell configuration, capabilities, and platform entitlements. · `src-tauri/tauri.conf.json`
- [Installer Assets](https://github.com/sitelift/chirp/blob/master/src-tauri/installer/chirp-header.bmp): packaging assets · Installer wrapper and platform branding assets used for distribution. · `src-tauri/installer/chirp-header.bmp`

### Offline Assets

Bundled models, sounds, and training/release tooling.

- [Sherpa Lib](https://github.com/sitelift/chirp/blob/master/src-tauri/sherpa-onnx-lib/include/sherpa-onnx/c-api/c-api.h): native library · Bundled sherpa-onnx native interface for speech runtime integration. · `src-tauri/sherpa-onnx-lib/include/sherpa-onnx/c-api/c-api.h`
- [Models & Sounds](https://github.com/sitelift/chirp/blob/master/public/sounds/chirp.mp3): bundled assets · Offline speech and audio assets, including packaged sounds and model files. · `public/sounds/chirp.mp3`
- [Training Pipeline](https://github.com/sitelift/chirp/blob/master/training/train.py): offline ML tools · Model data prep, training, export, and benchmarking for cleanup models. · `training/train.py`
- [Release Tools](https://github.com/sitelift/chirp/blob/master/scripts/release.sh): dev tooling · Benchmarking, model download, pruning, and release automation. · `scripts/release.sh`

## Connections

- App Shell → App Store: reads/writes · Root UI state flows through the shared store.
- App Shell → Onboarding: renders · First-run and setup screens are mounted from the app shell.
- App Shell → Overlay: renders · Recording status overlay is part of the main UI shell.
- App Shell → Settings: renders · Settings pages are mounted from the main shell.
- UI Hooks → Tauri Commands: calls · Hooks bridge UI actions into backend commands and events.
- Overlay → App Store: subscribes · Overlay reflects backend-driven app state.
- Settings → App Store: edits · Settings UI reads and updates shared state.
- Tauri Commands → Backend State: routes through · Commands operate on shared backend state.
- Hotkey → Native Hotkey: delegates · Shared hotkey handling is backed by native OS integration.
- Hotkey → Audio Capture: starts/stops · Global shortcut controls microphone capture.
- Audio Capture → ASR Pipeline: feeds · Captured microphone audio is passed into ASR.
- ASR Pipeline → Cleanup: optional handoff · Transcript text can be sent to polishing.
- Cleanup → Llama Server: uses · Cleanup stage runs through the local LLM runtime.
- Cleanup → Text Inject: outputs · Polished text is prepared for insertion.
- ASR Pipeline → Text Inject: outputs · Raw transcript can be inserted directly when cleanup is skipped.
- Text Inject → Backend State: updates · Injection and recording outcomes are reflected in backend state.
- Settings Data → Backend State: persists · Persistent settings are loaded into runtime state.
- History → Backend State: persists · Saved transcript history is managed by backend state.
- Snippets → Backend State: persists · Snippet storage is exposed through backend state.
- Dictionary → Backend State: persists · Vocabulary data is managed locally by the backend.
- Feedback → Backend State: persists · Feedback and improve-improve signals are stored locally.
- Onboarding → Models & Sounds: downloads/prepares · Onboarding includes model acquisition and readiness steps.
- Tauri Config → Tauri Commands: enables · Desktop capability and platform configuration gate the runtime bridge.
- Installer Assets → Tauri Config: packages · Installer assets participate in desktop distribution.
- ASR Pipeline → Sherpa Lib: binds to · ASR runtime depends on the bundled sherpa-onnx interface.
- Release Tools → Training Pipeline: supports · Release and benchmark tools support the offline model pipeline.
- Training Pipeline → Models & Sounds: produces · Training/export pipeline produces model artifacts used by the app.
