# rhythmicdias/dictateanywhere architecture

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

- Interactive diagram: https://gitdiagram.com/rhythmicdias/dictateanywhere
- Repository: https://github.com/rhythmicdias/dictateanywhere

## Overview

#### Purpose and Runtime
DictateAnywhere is a Windows desktop voice-dictation application. It captures microphone audio, transcribes it locally or through cloud providers, transforms the resulting text, and injects it into the currently focused native application. The primary runtime is Python; UI is Tkinter/pystray with Windows integration. A separate Tauri/React surface exists, likely for a floating-widget frontend.

Entry points are `src/dictateanywhere/__main__.py` and the application orchestrator `src/dictateanywhere/main.py`. The Tauri frontend entry is `src/main.tsx`, backed by `src-tauri/src/lib.rs`.

#### Application Orchestration and Interaction
`main.py` coordinates lifecycle, recording state, engine selection, UI state updates, history, text processing, and injection. Users start/stop dictation through a global hotkey, tray commands, or the floating microphone widget.

- `src/dictateanywhere/main.py`
- `src/dictateanywhere/core/hotkey_manager.py`
- `src/dictateanywhere/ui/tray.py`
- `src/dictateanywhere/ui/floating_widget.py`

#### Audio Capture and Speech Boundary
Microphone capture produces audio frames and RMS-level callbacks for the preview meter. Voice activity detection filters silence and supports auto-stop behavior; timed capture enforces recording limits. Audio then crosses a provider boundary into the selected transcription engine.

- `src/dictateanywhere/audio/capture.py`
- `src/dictateanywhere/audio/vad.py`
- `src/dictateanywhere/transcription/engine.py`

#### Transcription Providers
A shared engine abstraction isolates STT backends. Local transcription uses faster-whisper and can run CPU or CUDA/CTranslate2. Cloud/provider implementations include Azure Speech, Google Gemini, and Sarvam, with Sarvam supporting WebSocket streaming. Engine mode/config determines local, cloud, hybrid, Gemini, or Sarvam routing/fallback behavior.

- `src/dictateanywhere/transcription/engine.py`
- `src/dictateanywhere/transcription/local_engine.py`
- `src/dictateanywhere/transcription/cloud_engine.py`
- `src/dictateanywhere/transcription/gemini_engine.py`
- `src/dictateanywhere/transcription/sarvam_engine.py`

External services: Azure Speech, Google Gemini, Sarvam AI, and optionally local Ollama for post-transcription LLM processing.

#### Text Processing and Delivery Pipeline
Final transcript processing applies spoken-punctuation conversion, capitalization, ordered user correction rules, and optional LLM polishing/custom prompts. The processed result is shown in the preview/history and delivered to the active Windows text field through clipboard paste or SendInput. This is the key boundary between application-managed text and arbitrary target applications.

- `src/dictateanywhere/core/punctuation.py`
- `src/dictateanywhere/core/corrections.py`
- `src/dictateanywhere/core/polish.py`
- `src/dictateanywhere/core/text_injector.py`

#### Desktop UI and State Feedback
The tray is the persistent control surface; Tkinter windows provide settings, session history, and live transcription preview. The preview receives listening/transcript/level updates, while the floating widget represents recording state and countdown. Session history is in-memory for the process lifetime.

- `src/dictateanywhere/ui/tray.py`
- `src/dictateanywhere/ui/preview_window.py`
- `src/dictateanywhere/ui/settings_window.py`
- `src/dictateanywhere/ui/history_window.py`

#### Persistence, Secrets, and Updates
Non-secret preferences, UI positions, engine selection, and update state are persisted under `%APPDATA%\DictateAnywhere`; correction rules are separately persisted. API keys are delegated to Windows Credential Manager/DPAPI rather than plaintext configuration. The updater checks GitHub Releases with daily/version suppression logic.

- `src/dictateanywhere/utils/config.py`
- `src/dictateanywhere/utils/secure_storage.py`
- `src/dictateanywhere/core/updater.py`

#### Packaging and Native Sidecar
Windows scripts create environments, install dependencies, run development/release modes, and build a standalone PyInstaller executable. GitHub Actions handles release automation. The Tauri crate exposes sidecar command support, suggesting an optional native shell/frontend integration around the Python application.

- `scripts/build.bat`
- `.github/workflows/release.yml`
- `src-tauri/src/commands/sidecar.rs`
- `src/windows/FloatingWidget/FloatingWidget.tsx`

Main entry points: [`src/dictateanywhere/main.py`](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/main.py) (Application orchestrator), [`src/dictateanywhere/transcription/engine.py`](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/transcription/engine.py) (Transcription engine), [`src/dictateanywhere/audio/capture.py`](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/audio/capture.py) (Microphone capture), [`src/dictateanywhere/core/polish.py`](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/core/polish.py) (Text processing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Python Desktop Runtime"]
  node_entry["Python entry point<br/>bootstrap<br/>[__main__.py]"]
  node_app["Application orchestrator<br/>lifecycle coordinator<br/>[main.py]"]
  node_hotkeys["Global hotkeys<br/>input control<br/>[hotkey_manager.py]"]
  node_tray["System tray<br/>desktop control<br/>[tray.py]"]
  node_preview["Preview window<br/>Tkinter UI<br/>[preview_window.py]"]
  node_settings_history["Settings &amp; history windows<br/>Tkinter UI<br/>[history_window.py]"]
end

subgraph group_audio["Audio &amp; Transcription"]
  node_capture["Microphone capture<br/>audio capture<br/>[capture.py]"]
  node_vad["Voice activity detection<br/>audio filter<br/>[vad.py]"]
  node_engine{{"Transcription engine<br/>STT abstraction<br/>[engine.py]"}}
  node_local_stt["Local faster-whisper<br/>local STT provider<br/>[local_engine.py]"]
  node_cloud_stt["Azure cloud STT<br/>cloud STT provider<br/>[cloud_engine.py]"]
  node_gemini["Google Gemini<br/>cloud STT provider<br/>[gemini_engine.py]"]
  node_sarvam["Sarvam AI<br/>streaming STT provider<br/>[sarvam_engine.py]"]
end

subgraph group_text["Text Delivery"]
  node_text_processing["Text processing<br/>transcript pipeline<br/>[polish.py]"]
  node_injector{{"Native text injector<br/>Windows delivery<br/>[text_injector.py]"}}
end

subgraph group_platform["Persistence &amp; Updates"]
  node_config[("AppData preferences<br/>local persistence<br/>[config.py]")]
  node_secrets[("Windows credential storage<br/>secret store<br/>[secure_storage.py]")]
  node_updater["Release updater<br/>update checker<br/>[updater.py]"]
end

subgraph group_native["Optional Tauri Surface"]
  node_tauri_shell["Tauri sidecar shell<br/>native integration<br/>[sidecar.rs]"]
  node_floating_widget["Floating microphone widget<br/>recording UI<br/>[FloatingWidget.tsx]"]
end

node_entry -->|"starts"| node_app
node_hotkeys -->|"start/stop commands"| node_app
node_tray -->|"commands"| node_app
node_app -->|"controls recording"| node_capture
node_capture -->|"audio frames"| node_vad
node_capture -->|"RMS levels"| node_preview
node_vad -->|"speech audio"| node_engine
node_engine -->|"local mode"| node_local_stt
node_engine -->|"cloud mode"| node_cloud_stt
node_engine -->|"Gemini mode"| node_gemini
node_engine -->|"Sarvam mode"| node_sarvam
node_engine -->|"transcript"| node_text_processing
node_text_processing -->|"processed text"| node_injector
node_text_processing -->|"transcript updates"| node_preview
node_app -->|"state and history"| node_settings_history
node_app -->|"loads and saves preferences"| node_config
node_app -->|"retrieves provider keys"| node_secrets
node_app -.->|"checks updates"| node_updater
node_floating_widget -->|"recording controls"| node_app
node_tauri_shell -->|"hosts frontend"| node_floating_widget

click node_entry "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/__main__.py"
click node_app "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/main.py"
click node_hotkeys "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/core/hotkey_manager.py"
click node_tray "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/ui/tray.py"
click node_preview "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/ui/preview_window.py"
click node_settings_history "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/ui/history_window.py"
click node_capture "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/audio/capture.py"
click node_vad "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/audio/vad.py"
click node_engine "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/transcription/engine.py"
click node_local_stt "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/transcription/local_engine.py"
click node_cloud_stt "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/transcription/cloud_engine.py"
click node_gemini "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/transcription/gemini_engine.py"
click node_sarvam "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/transcription/sarvam_engine.py"
click node_text_processing "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/core/polish.py"
click node_injector "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/core/text_injector.py"
click node_config "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/utils/config.py"
click node_secrets "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/utils/secure_storage.py"
click node_updater "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/core/updater.py"
click node_tauri_shell "https://github.com/rhythmicdias/dictateanywhere/blob/main/src-tauri/src/commands/sidecar.rs"
click node_floating_widget "https://github.com/rhythmicdias/dictateanywhere/blob/main/src/windows/FloatingWidget/FloatingWidget.tsx"

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_entry,node_app,node_hotkeys,node_tray,node_preview,node_settings_history toneBlue
class node_capture,node_vad,node_engine,node_local_stt,node_cloud_stt,node_gemini,node_sarvam toneAmber
class node_text_processing,node_injector toneMint
class node_config,node_secrets,node_updater toneRose
class node_tauri_shell,node_floating_widget toneIndigo
```

## Components

### Python Desktop Runtime

Windows dictation application and control surfaces.

- [Python entry point](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/__main__.py): bootstrap · `src/dictateanywhere/__main__.py`
- [Application orchestrator](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/main.py): lifecycle coordinator · Coordinates recording, engine selection, state, history, and delivery. · `src/dictateanywhere/main.py`
- [Global hotkeys](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/core/hotkey_manager.py): input control · `src/dictateanywhere/core/hotkey_manager.py`
- [System tray](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/ui/tray.py): desktop control · `src/dictateanywhere/ui/tray.py`
- [Preview window](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/ui/preview_window.py): Tkinter UI · Shows listening state, audio level, and transcript updates. · `src/dictateanywhere/ui/preview_window.py`
- [Settings & history windows](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/ui/history_window.py): Tkinter UI · Settings and process-lifetime session history. · `src/dictateanywhere/ui/history_window.py`

### Audio & Transcription

Capture pipeline and selectable speech providers.

- [Microphone capture](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/audio/capture.py): audio capture · Emits audio frames and RMS-level callbacks. · `src/dictateanywhere/audio/capture.py`
- [Voice activity detection](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/audio/vad.py): audio filter · Filters silence and supports auto-stop. · `src/dictateanywhere/audio/vad.py`
- [Transcription engine](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/transcription/engine.py): STT abstraction · Selects local, cloud, hybrid, Gemini, or Sarvam routing. · `src/dictateanywhere/transcription/engine.py`
- [Local faster-whisper](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/transcription/local_engine.py): local STT provider · Runs with CPU or CUDA/CTranslate2. · `src/dictateanywhere/transcription/local_engine.py`
- [Azure cloud STT](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/transcription/cloud_engine.py): cloud STT provider · `src/dictateanywhere/transcription/cloud_engine.py`
- [Google Gemini](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/transcription/gemini_engine.py): cloud STT provider · `src/dictateanywhere/transcription/gemini_engine.py`
- [Sarvam AI](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/transcription/sarvam_engine.py): streaming STT provider · Supports WebSocket streaming. · `src/dictateanywhere/transcription/sarvam_engine.py`

### Text Delivery

Transcript transformation and native-app delivery.

- [Text processing](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/core/polish.py): transcript pipeline · Applies punctuation, capitalization, corrections, and optional LLM polish. · `src/dictateanywhere/core/polish.py`
- [Native text injector](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/core/text_injector.py): Windows delivery · Pastes through clipboard or injects with SendInput into the focused application. · `src/dictateanywhere/core/text_injector.py`

### Persistence & Updates

Local preferences, secrets, and release checks.

- [AppData preferences](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/utils/config.py): local persistence · Stores preferences, positions, engine selection, corrections, and update state. · `src/dictateanywhere/utils/config.py`
- [Windows credential storage](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/utils/secure_storage.py): secret store · Uses Credential Manager and DPAPI for API keys. · `src/dictateanywhere/utils/secure_storage.py`
- [Release updater](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/dictateanywhere/core/updater.py): update checker · Checks GitHub Releases with daily and version suppression. · `src/dictateanywhere/core/updater.py`

### Optional Tauri Surface

Native shell and React floating-widget integration.

- [Tauri sidecar shell](https://github.com/rhythmicdias/dictateanywhere/blob/main/src-tauri/src/commands/sidecar.rs): native integration · Exposes commands for Python sidecar integration. · `src-tauri/src/commands/sidecar.rs`
- [Floating microphone widget](https://github.com/rhythmicdias/dictateanywhere/blob/main/src/windows/FloatingWidget/FloatingWidget.tsx): recording UI · Represents recording state and countdown. · `src/windows/FloatingWidget/FloatingWidget.tsx`

## Connections

- Python entry point → Application orchestrator: starts
- Global hotkeys → Application orchestrator: start/stop commands
- System tray → Application orchestrator: commands
- Application orchestrator → Microphone capture: controls recording
- Microphone capture → Voice activity detection: audio frames
- Microphone capture → Preview window: RMS levels
- Voice activity detection → Transcription engine: speech audio
- Transcription engine → Local faster-whisper: local mode
- Transcription engine → Azure cloud STT: cloud mode
- Transcription engine → Google Gemini: Gemini mode
- Transcription engine → Sarvam AI: Sarvam mode
- Transcription engine → Text processing: transcript
- Text processing → Native text injector: processed text
- Text processing → Preview window: transcript updates
- Application orchestrator → Settings & history windows: state and history
- Application orchestrator → AppData preferences: loads and saves preferences
- Application orchestrator → Windows credential storage: retrieves provider keys
- Application orchestrator → Release updater: checks updates
- Floating microphone widget → Application orchestrator: recording controls
- Tauri sidecar shell → Floating microphone widget: hosts frontend
