# rbc33/ghostbar architecture

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

- Interactive diagram: https://gitdiagram.com/rbc33/ghostbar
- Repository: https://github.com/rbc33/ghostbar

## Overview

Ghostbar is a native macOS menu-bar AI client whose floating chat window is excluded from screen capture. The main workflow is opening chat from the menu or global shortcut, entering a message (or attaching a screenshot), streaming a response from the configured model backend, and optionally recording voice for on-device transcription. Settings configure backends and shortcuts. The graph reflects excerpted calls and README-documented capabilities; dashed, uncited links mark relationships not verified in the sampled source.

Main entry points: [`Sources/Ghostbar/WebView/WKWebViewWrapper.swift`](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/WebView/WKWebViewWrapper.swift) (Web view bridge), [`Sources/Ghostbar/App/AppDelegate.swift`](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/App/AppDelegate.swift) (App delegate), [`Sources/Ghostbar/App/GlobalHotKey.swift`](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/App/GlobalHotKey.swift) (Global hotkey), [`Sources/Ghostbar/UI/ChatWindow.swift`](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/UI/ChatWindow.swift) (Chat window)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app_ui["App and window UI"]
  node_main["App entry<br/>[main.swift]"]
  node_delegate["App delegate<br/>[AppDelegate.swift]"]
  node_hotkey["Global hotkey<br/>[GlobalHotKey.swift]"]
  node_chat_window["Chat window<br/>[ChatWindow.swift]"]
  node_movable["Movable window"]
end

subgraph group_chat["Chat and model access"]
  node_webview["Web view bridge"]
  node_chat_html["Chat interface<br/>[ChatHTML.swift]"]
  node_stream["Stream delegate"]
  node_parsers["Stream parsers"]
  node_model_backend{{"Configured model backend"}}
end

subgraph group_voice_capture["Voice and capture"]
  node_audio["Audio recorder"]
  node_transcriber["Voice transcription<br/>[Transcriber.swift]"]
  node_screen_capture["Screenshot capture"]
end

subgraph group_settings["Settings and shortcuts"]
  node_backend_config["Backend config"]
  node_recording_shortcut["Shortcut settings"]
  node_shortcut_recorder["Shortcut recorder"]
  node_private_dropdown["Model picker"]
end

node_user(("User"))

node_user -->|"launches"| node_main
node_main -->|"starts"| node_delegate
node_delegate -->|"opens"| node_chat_window
node_delegate -->|"registers"| node_hotkey
node_hotkey -->|"toggles chat"| node_delegate
node_chat_window -->|"creates"| node_movable
node_chat_window -->|"hosts"| node_webview
node_webview -->|"loads"| node_chat_html
node_webview -->|"reads"| node_backend_config
node_webview -->|"requests models and streams"| node_model_backend
node_webview -->|"creates"| node_stream
node_stream -.->|"parses events"| node_parsers
node_stream -->|"sends tokens"| node_webview
node_delegate -->|"configures"| node_backend_config
node_delegate -->|"uses model picker"| node_private_dropdown
node_delegate -->|"configures shortcuts"| node_shortcut_recorder
node_shortcut_recorder -->|"loads and saves"| node_recording_shortcut
node_hotkey -->|"loads shortcut"| node_recording_shortcut
node_webview -->|"records audio"| node_audio
node_audio -.->|"provides recording"| node_transcriber
node_webview -.->|"captures screenshot"| node_screen_capture
node_user -->|"sends chat or voice"| node_webview

click node_main "https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/main.swift"
click node_delegate "https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/App/AppDelegate.swift"
click node_hotkey "https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/App/GlobalHotKey.swift"
click node_chat_window "https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/UI/ChatWindow.swift"
click node_movable "https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/UI/MovableWindow.swift"
click node_webview "https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/WebView/WKWebViewWrapper.swift"
click node_chat_html "https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/Resources/ChatHTML.swift"
click node_stream "https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/Streaming/StreamDelegate.swift"
click node_parsers "https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/Streaming/StreamParsers.swift"
click node_backend_config "https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/Config/BackendConfig.swift"
click node_audio "https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/Services/AudioRecorder.swift"
click node_transcriber "https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/Services/Transcriber.swift"
click node_screen_capture "https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/Services/ScreenCapture.swift"
click node_recording_shortcut "https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/Config/RecordingShortcut.swift"
click node_shortcut_recorder "https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/UI/ShortcutRecorder.swift"
click node_private_dropdown "https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/UI/PrivateDropdown.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_main,node_delegate,node_hotkey,node_chat_window,node_movable,node_user toneBlue
class node_webview,node_chat_html,node_stream,node_parsers,node_model_backend toneAmber
class node_audio,node_transcriber,node_screen_capture toneMint
class node_backend_config,node_recording_shortcut,node_shortcut_recorder,node_private_dropdown toneRose
```

## Components

### App and window UI

- [App entry](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/main.swift): `Sources/Ghostbar/main.swift`
- [App delegate](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/App/AppDelegate.swift): `Sources/Ghostbar/App/AppDelegate.swift`
- [Global hotkey](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/App/GlobalHotKey.swift): `Sources/Ghostbar/App/GlobalHotKey.swift`
- [Chat window](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/UI/ChatWindow.swift): `Sources/Ghostbar/UI/ChatWindow.swift`
- [Movable window](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/UI/MovableWindow.swift): `Sources/Ghostbar/UI/MovableWindow.swift`

### Chat and model access

- [Web view bridge](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/WebView/WKWebViewWrapper.swift): `Sources/Ghostbar/WebView/WKWebViewWrapper.swift`
- [Chat interface](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/Resources/ChatHTML.swift): `Sources/Ghostbar/Resources/ChatHTML.swift`
- [Stream delegate](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/Streaming/StreamDelegate.swift): `Sources/Ghostbar/Streaming/StreamDelegate.swift`
- [Stream parsers](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/Streaming/StreamParsers.swift): `Sources/Ghostbar/Streaming/StreamParsers.swift`
- **Configured model backend**

### Voice and capture

- [Audio recorder](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/Services/AudioRecorder.swift): `Sources/Ghostbar/Services/AudioRecorder.swift`
- [Voice transcription](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/Services/Transcriber.swift): `Sources/Ghostbar/Services/Transcriber.swift`
- [Screenshot capture](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/Services/ScreenCapture.swift): `Sources/Ghostbar/Services/ScreenCapture.swift`

### Settings and shortcuts

- [Backend config](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/Config/BackendConfig.swift): `Sources/Ghostbar/Config/BackendConfig.swift`
- [Shortcut settings](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/Config/RecordingShortcut.swift): `Sources/Ghostbar/Config/RecordingShortcut.swift`
- [Shortcut recorder](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/UI/ShortcutRecorder.swift): `Sources/Ghostbar/UI/ShortcutRecorder.swift`
- [Model picker](https://github.com/rbc33/ghostbar/blob/main/Sources/Ghostbar/UI/PrivateDropdown.swift): `Sources/Ghostbar/UI/PrivateDropdown.swift`

### Other components

- **User**

## Connections

- User → App entry: launches (evidence: `README.md`)
- App entry → App delegate: starts (evidence: `Sources/Ghostbar/main.swift`)
- App delegate → Chat window: opens (evidence: `Sources/Ghostbar/App/AppDelegate.swift`)
- App delegate → Global hotkey: registers (evidence: `Sources/Ghostbar/App/AppDelegate.swift`)
- Global hotkey → App delegate: toggles chat (evidence: `Sources/Ghostbar/App/AppDelegate.swift`)
- Chat window → Movable window: creates (evidence: `Sources/Ghostbar/UI/ChatWindow.swift`)
- Chat window → Web view bridge: hosts (evidence: `Sources/Ghostbar/UI/ChatWindow.swift`)
- Web view bridge → Chat interface: loads (evidence: `Sources/Ghostbar/WebView/WKWebViewWrapper.swift`)
- Web view bridge → Backend config: reads (evidence: `Sources/Ghostbar/WebView/WKWebViewWrapper.swift`)
- Web view bridge → Configured model backend: requests models and streams (evidence: `README.md`)
- Web view bridge → Stream delegate: creates (evidence: `Sources/Ghostbar/WebView/WKWebViewWrapper.swift`)
- Stream delegate → Stream parsers: parses events
- Stream delegate → Web view bridge: sends tokens (evidence: `Sources/Ghostbar/Streaming/StreamDelegate.swift`)
- App delegate → Backend config: configures (evidence: `Sources/Ghostbar/App/AppDelegate.swift`)
- App delegate → Model picker: uses model picker (evidence: `Sources/Ghostbar/App/AppDelegate.swift`)
- App delegate → Shortcut recorder: configures shortcuts (evidence: `Sources/Ghostbar/App/AppDelegate.swift`)
- Shortcut recorder → Shortcut settings: loads and saves (evidence: `Sources/Ghostbar/UI/ShortcutRecorder.swift`)
- Global hotkey → Shortcut settings: loads shortcut (evidence: `Sources/Ghostbar/App/GlobalHotKey.swift`)
- Web view bridge → Audio recorder: records audio (evidence: `Sources/Ghostbar/WebView/WKWebViewWrapper.swift`)
- Audio recorder → Voice transcription: provides recording
- Web view bridge → Screenshot capture: captures screenshot
- User → Web view bridge: sends chat or voice (evidence: `README.md`)
