# matthartman/ghost-pepper architecture

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

- Interactive diagram: https://gitdiagram.com/matthartman/ghost-pepper
- Repository: https://github.com/matthartman/ghost-pepper

## Overview

#### Purpose and runtime

Ghost Pepper is a macOS 14+/Apple Silicon menu-bar application for private, on-device dictation and meeting transcription. It captures microphone/system audio, runs local speech and cleanup models, and stores transcripts, summaries, and knowledge artifacts as local Markdown. Optional integrations can use user-configured cloud credentials.

Primary app entry points are `GhostPepper/GhostPepperApp.swift` and state composition in `GhostPepper/AppState.swift`; the Xcode project is `GhostPepper.xcodeproj/project.pbxproj`.

#### Application shell, permissions, and interaction

The SwiftUI menu-bar UI coordinates recording, settings, transcripts, model controls, search, and chat. App lifecycle utilities handle relaunch/update behavior. macOS permission boundaries are microphone, Accessibility (global hotkey and synthetic paste), and screen recording for OCR/window capture.

Key paths: `GhostPepper/GhostPepperApp.swift`, `GhostPepper/AppState.swift`, `GhostPepper/PermissionChecker.swift`, `GhostPepper/UI/MenuBarView.swift`.

#### Dictation control flow

A global Control-key monitor feeds chord/action handling and creates paste sessions. The recorder captures input audio; after release, the selected transcriber produces text, cleanup normalizes it, and the text paster injects it into the focused external application. Accessibility-based focused-element lookup and optional OCR provide contextual input to cleanup.

Key paths: `GhostPepper/Input/HotkeyMonitor.swift`, `GhostPepper/Input/ChordEngine.swift`, `GhostPepper/Input/TextPaster.swift`, `GhostPepper/Audio/AudioRecorder.swift`, `GhostPepper/Context/FocusedElementLocator.swift`.

#### Local transcription subsystem

`RecordingSessionCoordinator` owns recording-to-transcription orchestration. `SpeechTranscriber` selects among WhisperKit, FluidAudio, and MLX Audio implementations; chunked and streaming paths support recorded meetings and low-latency dictation. `ModelManager`/catalog manage downloadable local speech-model inventory and selection.

Key paths: `GhostPepper/Transcription/RecordingSessionCoordinator.swift`, `GhostPepper/Transcription/SpeechTranscriber.swift`, `GhostPepper/Transcription/ChunkedTranscriptionPipeline.swift`, `GhostPepper/Transcription/FluidAudioSpeechSession.swift`, `GhostPepper/Transcription/NemotronStreamingModel.swift`.

#### Cleanup and contextual correction

The cleanup manager is an abstraction boundary between deterministic correction and local LLM cleanup. It builds prompts from transcription plus OCR context, tracks learned corrections after paste, and invokes LLM.swift-backed local Qwen models. A standalone probe target isolates model validation/CLI execution.

Key paths: `GhostPepper/Cleanup/TextCleanupManager.swift`, `GhostPepper/Cleanup/LocalLLMCleanupBackend.swift`, `GhostPepper/Cleanup/PostPasteLearningCoordinator.swift`, `CleanupModelProbe/main.swift`.

#### Meeting capture, archive, and knowledge generation

Meeting detection identifies active calls; dual-stream capture records microphone and system audio. Transcripts, speaker identity resolution, summaries, and meeting Markdown are persisted locally. The Wiki subsystem chunks meeting content and uses structured local LLM output to generate/reconcile entities and cards; indexing builds searchable archive entries.

Key paths: `GhostPepper/Meeting/MeetingDetector.swift`, `GhostPepper/Audio/DualStreamCapture.swift`, `GhostPepper/Meeting/MeetingMarkdownWriter.swift`, `GhostPepper/Wiki/GeneratedWikiEngine.swift`, `GhostPepper/Indexing/IndexBuilder.swift`.

#### Search, QA, and integrations

QA is an agent layer over local meeting/wiki files, with sandboxed file tools and QMD/wiki search. Providers include local LLMs and an optional Anthropic-backed path, with credentials isolated through Keychain. Pepper Chat routes commands to optional Zo and Trello backends; Airtable and Granola importers ingest external meeting data.

Key paths: `GhostPepper/QA/MeetingQAAgent.swift`, `GhostPepper/QA/PathSandbox.swift`, `GhostPepper/QA/AnthropicProvider.swift`, `GhostPepper/PepperChat/PepperChatSession.swift`, `GhostPepper/Meeting/GranolaImporter.swift`.

#### Infrastructure and operational boundaries

Inference is local through WhisperKit, FluidAudio, MLX Audio, and LLM.swift; model artifacts are downloaded once from Hugging Face and cached locally. Sparkle-style update metadata is represented by `appcast.xml`; usage and debug data remain local. Signing, entitlement, and privacy constraints are central to macOS deployment.

Key paths: `GhostPepper/ModelInventory.swift`, `GhostPepper/UpdaterController.swift`, `GhostPepper/GhostPepper.entitlements`, `GhostPepper/UsageStats/UsageStatsStore.swift`, `PRIVACY_AUDIT.md`.

Main entry points: [`GhostPepper/Transcription/RecordingSessionCoordinator.swift`](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Transcription/RecordingSessionCoordinator.swift) (Recording coordinator), [`GhostPepper/Transcription/SpeechTranscriber.swift`](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Transcription/SpeechTranscriber.swift) (Speech transcriber), [`GhostPepper/Meeting/MeetingMarkdownWriter.swift`](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Meeting/MeetingMarkdownWriter.swift) (Meeting Markdown archive), [`GhostPepper/Cleanup/TextCleanupManager.swift`](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Cleanup/TextCleanupManager.swift) (Text cleanup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["macOS Shell"]
  node_app["App composition<br/>SwiftUI app state"]
  node_menu["Menu-bar UI<br/>SwiftUI view<br/>[MenuBarView.swift]"]
  node_permissions["Permissions<br/>macOS boundary"]
end

subgraph group_dictation["Dictation"]
  node_hotkey["Global hotkey<br/>input monitor"]
  node_chords["Chord actions<br/>input state machine<br/>[ChordEngine.swift]"]
  node_recorder["Microphone recorder<br/>audio capture"]
  node_context["Focused-app context<br/>Accessibility context"]
  node_paster["Text paster<br/>Accessibility output<br/>[TextPaster.swift]"]
  node_cleanup["Text cleanup<br/>correction boundary"]
  node_learning["Post-paste learning<br/>correction learner"]
end

subgraph group_transcription["Local Speech"]
  node_session["Recording coordinator<br/>orchestrator"]
  node_transcriber["Speech transcriber<br/>provider selector"]
  node_speechpipeline["Chunked transcription<br/>batch pipeline"]
  node_streaming["Streaming speech<br/>low-latency session"]
  node_models[("Model inventory<br/>local model catalog")]
end

subgraph group_meetings["Meetings &amp; Knowledge"]
  node_meetingdetect["Meeting detection<br/>call detector"]
  node_dualaudio["Dual-stream capture<br/>meeting audio capture"]
  node_archive[("Meeting Markdown archive<br/>local document store")]
  node_wiki["Generated wiki<br/>knowledge pipeline"]
  node_index["Archive index<br/>search indexer<br/>[IndexBuilder.swift]"]
end

subgraph group_qa["QA &amp; Integrations"]
  node_qaagent["Meeting QA agent<br/>file-grounded agent"]
  node_sandbox["Path sandbox<br/>file-access boundary<br/>[PathSandbox.swift]"]
  node_anthropic["Anthropic provider<br/>optional cloud provider"]
  node_chat["Pepper Chat<br/>command router"]
  node_importer["Granola importer<br/>external meeting import"]
end

node_app -->|"renders"| node_menu
node_app -->|"checks"| node_permissions
node_menu -->|"controls"| node_session
node_menu -->|"opens"| node_chat
node_permissions -.->|"authorizes"| node_hotkey
node_permissions -.->|"authorizes"| node_context
node_hotkey -->|"feeds"| node_chords
node_chords -->|"starts/stops"| node_session
node_session -->|"records"| node_recorder
node_session -->|"submits audio"| node_transcriber
node_transcriber -->|"uses for batch"| node_speechpipeline
node_transcriber -->|"uses for live"| node_streaming
node_models -->|"supplies speech models"| node_transcriber
node_session -->|"sends transcript"| node_cleanup
node_context -->|"provides context"| node_cleanup
node_cleanup -->|"returns cleaned text"| node_paster
node_paster -->|"records corrections"| node_learning
node_learning -.->|"improves corrections"| node_cleanup
node_meetingdetect -->|"triggers"| node_dualaudio
node_dualaudio -->|"supplies meeting audio"| node_session
node_speechpipeline -->|"produces transcript"| node_archive
node_archive -->|"sources content"| node_wiki
node_wiki -->|"indexes artifacts"| node_index
node_archive -->|"indexes meetings"| node_index
node_index -->|"retrieves local knowledge"| node_qaagent
node_sandbox -->|"limits file tools"| node_qaagent
node_anthropic -.->|"optional model path"| node_qaagent
node_importer -->|"ingests meetings"| node_archive
node_chat -->|"routes knowledge commands"| node_qaagent

click node_app "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/GhostPepperApp.swift"
click node_menu "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/UI/MenuBarView.swift"
click node_permissions "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/PermissionChecker.swift"
click node_hotkey "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Input/HotkeyMonitor.swift"
click node_chords "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Input/ChordEngine.swift"
click node_recorder "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Audio/AudioRecorder.swift"
click node_context "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Context/FocusedElementLocator.swift"
click node_paster "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Input/TextPaster.swift"
click node_session "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Transcription/RecordingSessionCoordinator.swift"
click node_transcriber "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Transcription/SpeechTranscriber.swift"
click node_speechpipeline "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Transcription/ChunkedTranscriptionPipeline.swift"
click node_streaming "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Transcription/FluidAudioSpeechSession.swift"
click node_models "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/ModelInventory.swift"
click node_cleanup "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Cleanup/TextCleanupManager.swift"
click node_learning "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Cleanup/PostPasteLearningCoordinator.swift"
click node_meetingdetect "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Meeting/MeetingDetector.swift"
click node_dualaudio "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Audio/DualStreamCapture.swift"
click node_archive "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Meeting/MeetingMarkdownWriter.swift"
click node_wiki "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Wiki/GeneratedWikiEngine.swift"
click node_index "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Indexing/IndexBuilder.swift"
click node_qaagent "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/QA/MeetingQAAgent.swift"
click node_sandbox "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/QA/PathSandbox.swift"
click node_anthropic "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/QA/AnthropicProvider.swift"
click node_chat "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/PepperChat/PepperChatSession.swift"
click node_importer "https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Meeting/GranolaImporter.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_app,node_menu,node_permissions toneBlue
class node_hotkey,node_chords,node_recorder,node_context,node_paster,node_cleanup,node_learning toneAmber
class node_session,node_transcriber,node_speechpipeline,node_streaming,node_models toneMint
class node_meetingdetect,node_dualaudio,node_archive,node_wiki,node_index toneRose
class node_qaagent,node_sandbox,node_anthropic,node_chat,node_importer toneIndigo
```

## Components

### macOS Shell

- [App composition](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/GhostPepperApp.swift): SwiftUI app state · Menu-bar lifecycle and shared application state. · `GhostPepper/GhostPepperApp.swift`
- [Menu-bar UI](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/UI/MenuBarView.swift): SwiftUI view · `GhostPepper/UI/MenuBarView.swift`
- [Permissions](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/PermissionChecker.swift): macOS boundary · Controls microphone, Accessibility, and screen-recording access. · `GhostPepper/PermissionChecker.swift`

### Dictation

- [Global hotkey](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Input/HotkeyMonitor.swift): input monitor · `GhostPepper/Input/HotkeyMonitor.swift`
- [Chord actions](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Input/ChordEngine.swift): input state machine · `GhostPepper/Input/ChordEngine.swift`
- [Microphone recorder](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Audio/AudioRecorder.swift): audio capture · `GhostPepper/Audio/AudioRecorder.swift`
- [Focused-app context](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Context/FocusedElementLocator.swift): Accessibility context · Finds focused input; OCR can supplement cleanup context. · `GhostPepper/Context/FocusedElementLocator.swift`
- [Text paster](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Input/TextPaster.swift): Accessibility output · Injects cleaned dictation into the focused external app. · `GhostPepper/Input/TextPaster.swift`
- [Text cleanup](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Cleanup/TextCleanupManager.swift): correction boundary · Combines deterministic correction, local LLM cleanup, and contextual prompts. · `GhostPepper/Cleanup/TextCleanupManager.swift`
- [Post-paste learning](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Cleanup/PostPasteLearningCoordinator.swift): correction learner · `GhostPepper/Cleanup/PostPasteLearningCoordinator.swift`

### Local Speech

- [Recording coordinator](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Transcription/RecordingSessionCoordinator.swift): orchestrator · Owns recording-to-transcription lifecycle. · `GhostPepper/Transcription/RecordingSessionCoordinator.swift`
- [Speech transcriber](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Transcription/SpeechTranscriber.swift): provider selector · Selects WhisperKit, FluidAudio, or MLX Audio transcription. · `GhostPepper/Transcription/SpeechTranscriber.swift`
- [Chunked transcription](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Transcription/ChunkedTranscriptionPipeline.swift): batch pipeline · Processes recorded meetings in chunks. · `GhostPepper/Transcription/ChunkedTranscriptionPipeline.swift`
- [Streaming speech](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Transcription/FluidAudioSpeechSession.swift): low-latency session · `GhostPepper/Transcription/FluidAudioSpeechSession.swift`
- [Model inventory](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/ModelInventory.swift): local model catalog · Downloads and caches selectable local model artifacts. · `GhostPepper/ModelInventory.swift`

### Meetings & Knowledge

- [Meeting detection](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Meeting/MeetingDetector.swift): call detector · `GhostPepper/Meeting/MeetingDetector.swift`
- [Dual-stream capture](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Audio/DualStreamCapture.swift): meeting audio capture · Captures microphone and system audio. · `GhostPepper/Audio/DualStreamCapture.swift`
- [Meeting Markdown archive](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Meeting/MeetingMarkdownWriter.swift): local document store · Persists transcripts, speaker resolution, and summaries locally. · `GhostPepper/Meeting/MeetingMarkdownWriter.swift`
- [Generated wiki](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Wiki/GeneratedWikiEngine.swift): knowledge pipeline · Generates and reconciles entities and cards from meeting content. · `GhostPepper/Wiki/GeneratedWikiEngine.swift`
- [Archive index](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Indexing/IndexBuilder.swift): search indexer · `GhostPepper/Indexing/IndexBuilder.swift`

### QA & Integrations

- [Meeting QA agent](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/QA/MeetingQAAgent.swift): file-grounded agent · Answers over local meeting and wiki files. · `GhostPepper/QA/MeetingQAAgent.swift`
- [Path sandbox](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/QA/PathSandbox.swift): file-access boundary · `GhostPepper/QA/PathSandbox.swift`
- [Anthropic provider](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/QA/AnthropicProvider.swift): optional cloud provider · Uses user-configured credentials isolated through Keychain. · `GhostPepper/QA/AnthropicProvider.swift`
- [Pepper Chat](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/PepperChat/PepperChatSession.swift): command router · Routes commands to optional Zo and Trello backends. · `GhostPepper/PepperChat/PepperChatSession.swift`
- [Granola importer](https://github.com/matthartman/ghost-pepper/blob/main/GhostPepper/Meeting/GranolaImporter.swift): external meeting import · `GhostPepper/Meeting/GranolaImporter.swift`

## Connections

- App composition → Menu-bar UI: renders
- App composition → Permissions: checks
- Menu-bar UI → Recording coordinator: controls
- Menu-bar UI → Pepper Chat: opens
- Permissions → Global hotkey: authorizes
- Permissions → Focused-app context: authorizes
- Global hotkey → Chord actions: feeds
- Chord actions → Recording coordinator: starts/stops
- Recording coordinator → Microphone recorder: records
- Recording coordinator → Speech transcriber: submits audio
- Speech transcriber → Chunked transcription: uses for batch
- Speech transcriber → Streaming speech: uses for live
- Model inventory → Speech transcriber: supplies speech models
- Recording coordinator → Text cleanup: sends transcript
- Focused-app context → Text cleanup: provides context
- Text cleanup → Text paster: returns cleaned text
- Text paster → Post-paste learning: records corrections
- Post-paste learning → Text cleanup: improves corrections
- Meeting detection → Dual-stream capture: triggers
- Dual-stream capture → Recording coordinator: supplies meeting audio
- Chunked transcription → Meeting Markdown archive: produces transcript
- Meeting Markdown archive → Generated wiki: sources content
- Generated wiki → Archive index: indexes artifacts
- Meeting Markdown archive → Archive index: indexes meetings
- Archive index → Meeting QA agent: retrieves local knowledge
- Path sandbox → Meeting QA agent: limits file tools
- Anthropic provider → Meeting QA agent: optional model path
- Granola importer → Meeting Markdown archive: ingests meetings
- Pepper Chat → Meeting QA agent: routes knowledge commands
