# namastexlabs/speak architecture

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

- Interactive diagram: https://gitdiagram.com/namastexlabs/speak
- Repository: https://github.com/namastexlabs/speak

## Overview

Speak is an Electron desktop voice-dictation app. The main process coordinates global hotkey activation and recording, then the app transcribes speech and inserts text at the user’s cursor; settings, history, and tray/menu/notification interfaces support that workflow. The main-process excerpt and SOURCE INDEX establish several module relationships, while the README documents the user-facing flow and capabilities. Some renderer and orchestration details are unsampled, so those relationships are omitted or marked unverified.

Main entry points: [`src/main.js`](https://github.com/namastexlabs/speak/blob/main/src/main.js) (Electron coordinator), [`src/transcription/whisper.js`](https://github.com/namastexlabs/speak/blob/main/src/transcription/whisper.js) (Whisper transcription), [`src/config/settings.js`](https://github.com/namastexlabs/speak/blob/main/src/config/settings.js) (Settings manager), [`src/hotkey/ptt-manager-v3.js`](https://github.com/namastexlabs/speak/blob/main/src/hotkey/ptt-manager-v3.js) (Global hotkey)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Audio &amp; Hotkeys"]
  node_ptt["Global hotkey<br/>[ptt-manager-v3.js]"]
  node_audio["Audio recording<br/>[recorder.js]"]
end

subgraph group_speech["Transcription &amp; Output"]
  node_whisper["Whisper transcription<br/>[whisper.js]"]
  node_inserter["Text insertion<br/>[text-inserter.js]"]
end

subgraph group_desktop["Desktop Controls"]
  node_main["Electron coordinator<br/>[main.js]"]
  node_tray["System tray<br/>[tray.js]"]
  node_menu["Application menu<br/>[menu.js]"]
  node_notifications["Notifications<br/>[notifications.js]"]
  node_errors["Error handling<br/>[error-handler.js]"]
end

subgraph group_state["Settings &amp; History"]
  node_settings["Settings manager<br/>[settings.js]"]
  node_history[("Transcription history<br/>[history.js]")]
end

subgraph group_renderer["App Interface"]
  node_web_audio["Web Audio capture<br/>[audio-bridge.js]"]
  node_renderer["Main app interface<br/>[main.js]"]
  node_settings_ui["Settings interface<br/>[settings.js]"]
  node_timeline["History timeline<br/>[timeline.js]"]
end

node_user(("Dictation user"))
node_openai{{"OpenAI API"}}
node_target["Active application"]

node_user -->|"activates"| node_ptt
node_ptt -->|"signals recording"| node_main
node_main -->|"stops recording"| node_audio
node_main -->|"initializes"| node_whisper
node_settings -->|"provides client"| node_whisper
node_whisper -->|"requests transcription"| node_openai
node_main -.->|"coordinates insertion"| node_inserter
node_inserter -->|"pastes text"| node_target
node_main -->|"updates settings"| node_settings
node_main -.->|"uses history"| node_history
node_main -->|"creates tray"| node_tray
node_main -->|"configures menu"| node_menu
node_main -.->|"uses notifications"| node_notifications
node_errors -->|"shows errors"| node_notifications
node_main -->|"sends hotkey events"| node_renderer
node_settings_ui -.->|"edits settings"| node_settings
node_timeline -.->|"shows history"| node_history
node_web_audio -.->|"supplies recorded data"| node_audio
node_user -->|"speaks"| node_web_audio

click node_main "https://github.com/namastexlabs/speak/blob/main/src/main.js"
click node_ptt "https://github.com/namastexlabs/speak/blob/main/src/hotkey/ptt-manager-v3.js"
click node_audio "https://github.com/namastexlabs/speak/blob/main/src/audio/recorder.js"
click node_web_audio "https://github.com/namastexlabs/speak/blob/main/src/renderer/audio-bridge.js"
click node_whisper "https://github.com/namastexlabs/speak/blob/main/src/transcription/whisper.js"
click node_inserter "https://github.com/namastexlabs/speak/blob/main/src/insertion/text-inserter.js"
click node_settings "https://github.com/namastexlabs/speak/blob/main/src/config/settings.js"
click node_history "https://github.com/namastexlabs/speak/blob/main/src/config/history.js"
click node_tray "https://github.com/namastexlabs/speak/blob/main/src/ui/tray.js"
click node_menu "https://github.com/namastexlabs/speak/blob/main/src/ui/menu.js"
click node_notifications "https://github.com/namastexlabs/speak/blob/main/src/ui/notifications.js"
click node_errors "https://github.com/namastexlabs/speak/blob/main/src/utils/error-handler.js"
click node_renderer "https://github.com/namastexlabs/speak/blob/main/src/renderer/main.js"
click node_settings_ui "https://github.com/namastexlabs/speak/blob/main/src/renderer/settings.js"
click node_timeline "https://github.com/namastexlabs/speak/blob/main/src/renderer/timeline.js"

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_ptt,node_audio,node_user toneBlue
class node_whisper,node_inserter toneAmber
class node_main,node_tray,node_menu,node_notifications,node_errors,node_openai toneMint
class node_settings,node_history toneRose
class node_web_audio,node_renderer,node_settings_ui,node_timeline,node_target toneIndigo
```

## Components

### Audio & Hotkeys

- [Global hotkey](https://github.com/namastexlabs/speak/blob/main/src/hotkey/ptt-manager-v3.js): `src/hotkey/ptt-manager-v3.js`
- [Audio recording](https://github.com/namastexlabs/speak/blob/main/src/audio/recorder.js): `src/audio/recorder.js`

### Transcription & Output

- [Whisper transcription](https://github.com/namastexlabs/speak/blob/main/src/transcription/whisper.js): `src/transcription/whisper.js`
- [Text insertion](https://github.com/namastexlabs/speak/blob/main/src/insertion/text-inserter.js): `src/insertion/text-inserter.js`

### Desktop Controls

- [Electron coordinator](https://github.com/namastexlabs/speak/blob/main/src/main.js): `src/main.js`
- [System tray](https://github.com/namastexlabs/speak/blob/main/src/ui/tray.js): `src/ui/tray.js`
- [Application menu](https://github.com/namastexlabs/speak/blob/main/src/ui/menu.js): `src/ui/menu.js`
- [Notifications](https://github.com/namastexlabs/speak/blob/main/src/ui/notifications.js): `src/ui/notifications.js`
- [Error handling](https://github.com/namastexlabs/speak/blob/main/src/utils/error-handler.js): `src/utils/error-handler.js`

### Settings & History

- [Settings manager](https://github.com/namastexlabs/speak/blob/main/src/config/settings.js): `src/config/settings.js`
- [Transcription history](https://github.com/namastexlabs/speak/blob/main/src/config/history.js): `src/config/history.js`

### App Interface

- [Web Audio capture](https://github.com/namastexlabs/speak/blob/main/src/renderer/audio-bridge.js): `src/renderer/audio-bridge.js`
- [Main app interface](https://github.com/namastexlabs/speak/blob/main/src/renderer/main.js): `src/renderer/main.js`
- [Settings interface](https://github.com/namastexlabs/speak/blob/main/src/renderer/settings.js): `src/renderer/settings.js`
- [History timeline](https://github.com/namastexlabs/speak/blob/main/src/renderer/timeline.js): `src/renderer/timeline.js`

### Other components

- **Dictation user**
- **OpenAI API**
- **Active application**

## Connections

- Dictation user → Global hotkey: activates (evidence: `README.md`)
- Global hotkey → Electron coordinator: signals recording (evidence: `src/main.js`)
- Electron coordinator → Audio recording: stops recording (evidence: `src/main.js`)
- Electron coordinator → Whisper transcription: initializes (evidence: `src/main.js`)
- Settings manager → Whisper transcription: provides client (evidence: `src/transcription/whisper.js`)
- Whisper transcription → OpenAI API: requests transcription (evidence: `src/transcription/whisper.js`)
- Electron coordinator → Text insertion: coordinates insertion (evidence: `src/main.js`)
- Text insertion → Active application: pastes text (evidence: `src/insertion/text-inserter.js`)
- Electron coordinator → Settings manager: updates settings (evidence: `src/main.js`)
- Electron coordinator → Transcription history: uses history (evidence: `src/main.js`)
- Electron coordinator → System tray: creates tray (evidence: `src/main.js`)
- Electron coordinator → Application menu: configures menu (evidence: `src/main.js`)
- Electron coordinator → Notifications: uses notifications (evidence: `src/main.js`)
- Error handling → Notifications: shows errors (evidence: `src/utils/error-handler.js`)
- Electron coordinator → Main app interface: sends hotkey events (evidence: `src/main.js`)
- Settings interface → Settings manager: edits settings
- History timeline → Transcription history: shows history
- Web Audio capture → Audio recording: supplies recorded data
- Dictation user → Web Audio capture: speaks (evidence: `README.md`)
