# thiago-pedroso/legato architecture

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

- Interactive diagram: https://gitdiagram.com/thiago-pedroso/legato
- Repository: https://github.com/thiago-pedroso/legato
- Video tour (about a minute): https://gitdiagram.com/thiago-pedroso/legato/video

## Overview

Legato is a macOS menu-bar voice-dictation app. The main workflow is: a user holds the dictation key, audio is recorded and saved, a local or API speech engine transcribes it, optional cleanup and vocabulary/replacement correction shape the text, and the result is typed into the target app. Settings, history/retry, vocabulary suggestions, and learning from user corrections are additional product capabilities. Some subsystem links are omitted where the excerpts show no invocation; the graph uses README statements for documented behavior.

Main entry points: [`Sources/Legato/Controller.swift`](https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/Controller.swift) (Dictation controller), [`Sources/Legato/SettingsView.swift`](https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/SettingsView.swift) (Settings window), [`Sources/Legato/App.swift`](https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/App.swift) (App lifecycle), [`Sources/LegatoCore/HistoryStore.swift`](https://github.com/thiago-pedroso/legato/blob/main/Sources/LegatoCore/HistoryStore.swift) (Dictation history)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture and control"]
  node_controller["Dictation controller<br/>[Controller.swift]"]
  node_hotkey["Hotkey monitor<br/>[Hotkey.swift]"]
  node_hotkeystate["Hotkey state"]
  node_recorder["Audio recorder<br/>[Recorder.swift]"]
  node_audio["Audio devices<br/>[AudioDevices.swift]"]
end

subgraph group_transcription["Speech and text"]
  node_engines["Speech engines<br/>[Engines.swift]"]
  node_cleanup["On-device cleanup"]
  node_processor["Text processing"]
  node_language["Language check"]
  node_wav["WAV encoding<br/>[WAV.swift]"]
end

subgraph group_personalization["Vocabulary and learning"]
  node_correctionwatcher["Correction watcher"]
  node_corrections["Correction rules<br/>[Corrections.swift]"]
  node_vocab["Vocabulary tools<br/>[Vocab.swift]"]
  node_mining["Vocabulary mining"]
  node_cli["Command-line tools<br/>[CLI.swift]"]
end

subgraph group_experience["App and persistence"]
  node_app["App lifecycle<br/>[App.swift]"]
  node_history[("Dictation history<br/>[HistoryStore.swift]")]
  node_settings["Settings model<br/>[Settings.swift]"]
  node_settingsui["Settings window<br/>[SettingsView.swift]"]
  node_pill["Status pill<br/>[Pill.swift]"]
  node_assets["App assets<br/>[Assets.swift]"]
  node_theme["Visual theme<br/>[Theme.swift]"]
end

node_user(("Mac user"))

node_user -->|"holds key"| node_hotkey
node_hotkey -.->|"signals key"| node_controller
node_controller -.->|"updates state"| node_hotkeystate
node_controller -->|"starts recording"| node_recorder
node_controller -->|"selects input"| node_audio
node_controller -->|"transcribes audio"| node_engines
node_controller -->|"cleans transcript"| node_cleanup
node_controller -->|"processes text"| node_processor
node_controller -.->|"checks transcript"| node_language
node_controller -->|"saves dictation"| node_history
node_history -->|"encodes audio"| node_wav
node_controller -.->|"watches typed text"| node_correctionwatcher
node_correctionwatcher -->|"uses corrections"| node_corrections
node_app -->|"creates controller"| node_controller
node_app -->|"opens window"| node_settingsui
node_settingsui -.->|"configures dictation"| node_controller
node_controller -->|"reads preferences"| node_settings
node_settingsui -->|"lists devices"| node_audio
node_user -->|"configures app"| node_settingsui
node_controller -.->|"shows status"| node_pill
node_pill -->|"uses styling"| node_theme
node_settingsui -->|"uses styling"| node_theme
node_app -->|"uses assets"| node_assets
node_user -->|"reviews recordings"| node_history
node_user -->|"requests suggestions"| node_vocab
node_vocab -->|"mines project terms"| node_mining
node_user -->|"runs commands"| node_cli
node_controller -->|"prepares vocabulary"| node_engines

click node_app "https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/App.swift"
click node_controller "https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/Controller.swift"
click node_hotkey "https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/Hotkey.swift"
click node_hotkeystate "https://github.com/thiago-pedroso/legato/blob/main/Sources/LegatoCore/HotkeyStateMachine.swift"
click node_recorder "https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/Recorder.swift"
click node_audio "https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/AudioDevices.swift"
click node_engines "https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/Engines.swift"
click node_cleanup "https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/OnDeviceCleanup.swift"
click node_processor "https://github.com/thiago-pedroso/legato/blob/main/Sources/LegatoCore/TextProcessor.swift"
click node_language "https://github.com/thiago-pedroso/legato/blob/main/Sources/LegatoCore/LanguageCheck.swift"
click node_wav "https://github.com/thiago-pedroso/legato/blob/main/Sources/LegatoCore/WAV.swift"
click node_history "https://github.com/thiago-pedroso/legato/blob/main/Sources/LegatoCore/HistoryStore.swift"
click node_settings "https://github.com/thiago-pedroso/legato/blob/main/Sources/LegatoCore/Settings.swift"
click node_settingsui "https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/SettingsView.swift"
click node_pill "https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/Pill.swift"
click node_assets "https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/Assets.swift"
click node_theme "https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/Theme.swift"
click node_correctionwatcher "https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/CorrectionWatcher.swift"
click node_corrections "https://github.com/thiago-pedroso/legato/blob/main/Sources/LegatoCore/Corrections.swift"
click node_vocab "https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/Vocab.swift"
click node_mining "https://github.com/thiago-pedroso/legato/blob/main/Sources/LegatoCore/VocabularyMining.swift"
click node_cli "https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/CLI.swift"

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_controller,node_hotkey,node_hotkeystate,node_recorder,node_audio,node_user toneBlue
class node_engines,node_cleanup,node_processor,node_language,node_wav toneAmber
class node_correctionwatcher,node_corrections,node_vocab,node_mining,node_cli toneMint
class node_app,node_history,node_settings,node_settingsui,node_pill,node_assets,node_theme toneRose
```

## Components

### Capture and control

- [Dictation controller](https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/Controller.swift): `Sources/Legato/Controller.swift`
- [Hotkey monitor](https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/Hotkey.swift): `Sources/Legato/Hotkey.swift`
- [Hotkey state](https://github.com/thiago-pedroso/legato/blob/main/Sources/LegatoCore/HotkeyStateMachine.swift): `Sources/LegatoCore/HotkeyStateMachine.swift`
- [Audio recorder](https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/Recorder.swift): `Sources/Legato/Recorder.swift`
- [Audio devices](https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/AudioDevices.swift): `Sources/Legato/AudioDevices.swift`

### Speech and text

- [Speech engines](https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/Engines.swift): `Sources/Legato/Engines.swift`
- [On-device cleanup](https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/OnDeviceCleanup.swift): `Sources/Legato/OnDeviceCleanup.swift`
- [Text processing](https://github.com/thiago-pedroso/legato/blob/main/Sources/LegatoCore/TextProcessor.swift): `Sources/LegatoCore/TextProcessor.swift`
- [Language check](https://github.com/thiago-pedroso/legato/blob/main/Sources/LegatoCore/LanguageCheck.swift): `Sources/LegatoCore/LanguageCheck.swift`
- [WAV encoding](https://github.com/thiago-pedroso/legato/blob/main/Sources/LegatoCore/WAV.swift): `Sources/LegatoCore/WAV.swift`

### Vocabulary and learning

- [Correction watcher](https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/CorrectionWatcher.swift): `Sources/Legato/CorrectionWatcher.swift`
- [Correction rules](https://github.com/thiago-pedroso/legato/blob/main/Sources/LegatoCore/Corrections.swift): `Sources/LegatoCore/Corrections.swift`
- [Vocabulary tools](https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/Vocab.swift): `Sources/Legato/Vocab.swift`
- [Vocabulary mining](https://github.com/thiago-pedroso/legato/blob/main/Sources/LegatoCore/VocabularyMining.swift): `Sources/LegatoCore/VocabularyMining.swift`
- [Command-line tools](https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/CLI.swift): `Sources/Legato/CLI.swift`

### App and persistence

- [App lifecycle](https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/App.swift): `Sources/Legato/App.swift`
- [Dictation history](https://github.com/thiago-pedroso/legato/blob/main/Sources/LegatoCore/HistoryStore.swift): `Sources/LegatoCore/HistoryStore.swift`
- [Settings model](https://github.com/thiago-pedroso/legato/blob/main/Sources/LegatoCore/Settings.swift): `Sources/LegatoCore/Settings.swift`
- [Settings window](https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/SettingsView.swift): `Sources/Legato/SettingsView.swift`
- [Status pill](https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/Pill.swift): `Sources/Legato/Pill.swift`
- [App assets](https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/Assets.swift): `Sources/Legato/Assets.swift`
- [Visual theme](https://github.com/thiago-pedroso/legato/blob/main/Sources/Legato/Theme.swift): `Sources/Legato/Theme.swift`

### Other components

- **Mac user**

## Connections

- Mac user → Hotkey monitor: holds key (evidence: `README.md`)
- Hotkey monitor → Dictation controller: signals key
- Dictation controller → Hotkey state: updates state (evidence: `Sources/Legato/Controller.swift`)
- Dictation controller → Audio recorder: starts recording (evidence: `Sources/Legato/Controller.swift`)
- Dictation controller → Audio devices: selects input (evidence: `Sources/Legato/Controller.swift`)
- Dictation controller → Speech engines: transcribes audio (evidence: `Sources/Legato/Controller.swift`)
- Dictation controller → On-device cleanup: cleans transcript (evidence: `Sources/Legato/Controller.swift`)
- Dictation controller → Text processing: processes text (evidence: `Sources/Legato/Controller.swift`)
- Dictation controller → Language check: checks transcript (evidence: `Sources/Legato/Controller.swift`)
- Dictation controller → Dictation history: saves dictation (evidence: `Sources/Legato/Controller.swift`)
- Dictation history → WAV encoding: encodes audio (evidence: `Sources/LegatoCore/HistoryStore.swift`)
- Dictation controller → Correction watcher: watches typed text (evidence: `Sources/Legato/Controller.swift`)
- Correction watcher → Correction rules: uses corrections (evidence: `Sources/Legato/CorrectionWatcher.swift`)
- App lifecycle → Dictation controller: creates controller (evidence: `Sources/Legato/App.swift`)
- App lifecycle → Settings window: opens window (evidence: `Sources/Legato/App.swift`)
- Settings window → Dictation controller: configures dictation (evidence: `Sources/Legato/SettingsView.swift`)
- Dictation controller → Settings model: reads preferences (evidence: `Sources/Legato/Controller.swift`)
- Settings window → Audio devices: lists devices (evidence: `Sources/Legato/SettingsView.swift`)
- Mac user → Settings window: configures app (evidence: `README.md`)
- Dictation controller → Status pill: shows status
- Status pill → Visual theme: uses styling (evidence: `Sources/Legato/Pill.swift`)
- Settings window → Visual theme: uses styling (evidence: `Sources/Legato/SettingsView.swift`)
- App lifecycle → App assets: uses assets (evidence: `Sources/Legato/App.swift`)
- Mac user → Dictation history: reviews recordings (evidence: `README.md`)
- Mac user → Vocabulary tools: requests suggestions (evidence: `README.md`)
- Vocabulary tools → Vocabulary mining: mines project terms (evidence: `Sources/Legato/Vocab.swift`)
- Mac user → Command-line tools: runs commands (evidence: `README.md`)
- Dictation controller → Speech engines: prepares vocabulary (evidence: `Sources/Legato/Controller.swift`)
