# tausif40/snaptext architecture

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

- Interactive diagram: https://gitdiagram.com/tausif40/snaptext
- Repository: https://github.com/tausif40/snaptext

## Overview

SnapText is a macOS menu-bar app for on-device screen OCR and persistent clipboard history. Users invoke capture, select a screen region, recognize and copy text; separately, clipboard monitoring saves eligible copies for searchable history and paste-back. The graph includes settings, shortcut registration, permissions/pasting, and the UI layers. Edges follow the excerpts or README; several source modules were indexed but not sampled, so their internal links are omitted where behavior is not evidenced.

Main entry points: [`Sources/SnapText/AppDelegate.swift`](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/AppDelegate.swift) (App Coordinator), [`Sources/SnapText/HistoryPanel.swift`](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/HistoryPanel.swift) (History Search Panel), [`Sources/SnapText/ClipboardHistory.swift`](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/ClipboardHistory.swift) (History Store), [`Sources/SnapText/SettingsView.swift`](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/SettingsView.swift) (Settings View)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App Shell"]
  node_main["App Entry<br/>[main.swift]"]
  node_delegate["App Coordinator<br/>[AppDelegate.swift]"]
  node_hud["Capture Notices<br/>[HUD.swift]"]
end

subgraph group_capture["Screen Capture"]
  node_screen["Screen Selection"]
  node_recognizer["Text Recognition"]
  node_layout["Text Layout<br/>[TextLayout.swift]"]
end

subgraph group_history["Clipboard History"]
  node_history[("History Store")]
  node_watcher["Clipboard Watcher"]
  node_paster["Paste Back<br/>[Paster.swift]"]
end

subgraph group_ui["User Interface"]
  node_panel["History Search Panel<br/>[HistoryPanel.swift]"]
  node_window["Main Window<br/>[MainWindow.swift]"]
  node_settingsview["Settings View<br/>[SettingsView.swift]"]
end

subgraph group_settings["Settings And Shortcuts"]
  node_preferences[("Persistent Preferences<br/>[Preferences.swift]")]
  node_shortcut["Shortcut Model<br/>[Shortcut.swift]"]
  node_hotkey["Global Hotkeys<br/>[GlobalHotKey.swift]"]
  node_shortcutfield["Shortcut Editor"]
  node_login["Launch At Login"]
end

node_user(("Mac User"))
node_macos["macOS Services"]

node_user -->|"launches"| node_main
node_main -->|"instantiates"| node_delegate
node_delegate -->|"starts"| node_watcher
node_delegate -->|"warms up"| node_recognizer
node_delegate -->|"registers"| node_hotkey
node_hotkey -->|"uses"| node_shortcut
node_delegate -->|"captures selection"| node_screen
node_delegate -->|"recognizes image"| node_recognizer
node_delegate -->|"formats text"| node_layout
node_delegate -->|"shows notices"| node_hud
node_delegate -->|"adds capture"| node_history
node_watcher -->|"adds copies"| node_history
node_macos -->|"provides clipboard"| node_watcher
node_delegate -->|"owns"| node_history
node_delegate -->|"opens"| node_panel
node_panel -->|"searches and removes"| node_history
node_panel -->|"selects text"| node_delegate
node_delegate -->|"pastes selection"| node_paster
node_paster -->|"posts paste keys"| node_macos
node_delegate -->|"shows"| node_window
node_window -->|"shows settings"| node_settingsview
node_settingsview -->|"reads and writes"| node_preferences
node_settingsview -->|"edits shortcuts"| node_shortcutfield
node_delegate -->|"loads settings"| node_preferences
node_delegate -->|"toggles"| node_login
node_user -->|"selects region"| node_screen
node_user -->|"searches history"| node_panel
node_screen -->|"requests screen access"| node_macos

click node_main "https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/main.swift"
click node_delegate "https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/AppDelegate.swift"
click node_hud "https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/HUD.swift"
click node_screen "https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/ScreenCapture.swift"
click node_recognizer "https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/TextRecognizer.swift"
click node_layout "https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/TextLayout.swift"
click node_history "https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/ClipboardHistory.swift"
click node_watcher "https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/ClipboardWatcher.swift"
click node_panel "https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/HistoryPanel.swift"
click node_window "https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/MainWindow.swift"
click node_settingsview "https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/SettingsView.swift"
click node_paster "https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/Paster.swift"
click node_preferences "https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/Preferences.swift"
click node_shortcut "https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/Shortcut.swift"
click node_hotkey "https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/GlobalHotKey.swift"
click node_shortcutfield "https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/ShortcutField.swift"
click node_login "https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/LaunchAtLogin.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_hud,node_user toneBlue
class node_screen,node_recognizer,node_layout toneAmber
class node_history,node_watcher,node_paster toneMint
class node_panel,node_window,node_settingsview toneRose
class node_preferences,node_shortcut,node_hotkey,node_shortcutfield,node_login,node_macos toneIndigo
```

## Components

### App Shell

- [App Entry](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/main.swift): `Sources/SnapText/main.swift`
- [App Coordinator](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/AppDelegate.swift): `Sources/SnapText/AppDelegate.swift`
- [Capture Notices](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/HUD.swift): `Sources/SnapText/HUD.swift`

### Screen Capture

- [Screen Selection](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/ScreenCapture.swift): `Sources/SnapText/ScreenCapture.swift`
- [Text Recognition](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/TextRecognizer.swift): `Sources/SnapText/TextRecognizer.swift`
- [Text Layout](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/TextLayout.swift): `Sources/SnapText/TextLayout.swift`

### Clipboard History

- [History Store](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/ClipboardHistory.swift): `Sources/SnapText/ClipboardHistory.swift`
- [Clipboard Watcher](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/ClipboardWatcher.swift): `Sources/SnapText/ClipboardWatcher.swift`
- [Paste Back](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/Paster.swift): `Sources/SnapText/Paster.swift`

### User Interface

- [History Search Panel](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/HistoryPanel.swift): `Sources/SnapText/HistoryPanel.swift`
- [Main Window](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/MainWindow.swift): `Sources/SnapText/MainWindow.swift`
- [Settings View](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/SettingsView.swift): `Sources/SnapText/SettingsView.swift`

### Settings And Shortcuts

- [Persistent Preferences](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/Preferences.swift): `Sources/SnapText/Preferences.swift`
- [Shortcut Model](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/Shortcut.swift): `Sources/SnapText/Shortcut.swift`
- [Global Hotkeys](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/GlobalHotKey.swift): `Sources/SnapText/GlobalHotKey.swift`
- [Shortcut Editor](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/ShortcutField.swift): `Sources/SnapText/ShortcutField.swift`
- [Launch At Login](https://github.com/tausif40/snaptext/blob/main/Sources/SnapText/LaunchAtLogin.swift): `Sources/SnapText/LaunchAtLogin.swift`

### Other components

- **Mac User**
- **macOS Services**

## Connections

- Mac User → App Entry: launches (evidence: `Sources/SnapText/main.swift`)
- App Entry → App Coordinator: instantiates (evidence: `Sources/SnapText/main.swift`)
- App Coordinator → Clipboard Watcher: starts (evidence: `Sources/SnapText/AppDelegate.swift`)
- App Coordinator → Text Recognition: warms up (evidence: `Sources/SnapText/AppDelegate.swift`)
- App Coordinator → Global Hotkeys: registers (evidence: `Sources/SnapText/AppDelegate.swift`)
- Global Hotkeys → Shortcut Model: uses (evidence: `Sources/SnapText/GlobalHotKey.swift`)
- App Coordinator → Screen Selection: captures selection (evidence: `Sources/SnapText/AppDelegate.swift`)
- App Coordinator → Text Recognition: recognizes image (evidence: `Sources/SnapText/AppDelegate.swift`)
- App Coordinator → Text Layout: formats text (evidence: `Sources/SnapText/AppDelegate.swift`)
- App Coordinator → Capture Notices: shows notices (evidence: `Sources/SnapText/AppDelegate.swift`)
- App Coordinator → History Store: adds capture (evidence: `README.md`)
- Clipboard Watcher → History Store: adds copies (evidence: `Sources/SnapText/ClipboardWatcher.swift`)
- macOS Services → Clipboard Watcher: provides clipboard (evidence: `Sources/SnapText/ClipboardWatcher.swift`)
- App Coordinator → History Store: owns (evidence: `Sources/SnapText/AppDelegate.swift`)
- App Coordinator → History Search Panel: opens (evidence: `Sources/SnapText/AppDelegate.swift`)
- History Search Panel → History Store: searches and removes (evidence: `Sources/SnapText/HistoryPanel.swift`)
- History Search Panel → App Coordinator: selects text (evidence: `Sources/SnapText/AppDelegate.swift`)
- App Coordinator → Paste Back: pastes selection (evidence: `Sources/SnapText/AppDelegate.swift`)
- Paste Back → macOS Services: posts paste keys (evidence: `Sources/SnapText/Paster.swift`)
- App Coordinator → Main Window: shows (evidence: `Sources/SnapText/AppDelegate.swift`)
- Main Window → Settings View: shows settings (evidence: `Sources/SnapText/MainWindow.swift`)
- Settings View → Persistent Preferences: reads and writes (evidence: `Sources/SnapText/SettingsView.swift`)
- Settings View → Shortcut Editor: edits shortcuts (evidence: `Sources/SnapText/SettingsView.swift`)
- App Coordinator → Persistent Preferences: loads settings (evidence: `Sources/SnapText/AppDelegate.swift`)
- App Coordinator → Launch At Login: toggles (evidence: `Sources/SnapText/AppDelegate.swift`)
- Mac User → Screen Selection: selects region (evidence: `README.md`)
- Mac User → History Search Panel: searches history (evidence: `README.md`)
- Screen Selection → macOS Services: requests screen access (evidence: `README.md`)
