# ismailhrifat/dashtype architecture

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

- Interactive diagram: https://gitdiagram.com/ismailhrifat/dashtype
- Repository: https://github.com/ismailhrifat/dashtype

## Overview

1. DashType is a native macOS text-expander built in Swift/SwiftUI. The repo is split into a UI/application layer and a separate core domain package, with Xcode as the primary build system and a SwiftPM package manifest alongside the Xcode project.

2. The core boundary lives under `Sources/DashTypeCore`. It contains the snippet domain model, folder organization, matching logic, local store, and the transfer document used for import/export. This is the repo’s main non-UI subsystem and is where snippet data rules are centralized.

3. The app boundary lives under `Sources/DashTypeApp`. This layer owns the macOS experience: dashboard, settings, menu bar UI, snippet editor, and authentication sheet. These views orchestrate user actions but rely on core types for snippet data and matching.

4. Text expansion is the runtime hot path. User keystrokes in other apps are observed through macOS Accessibility permissions; the trigger text is matched against stored snippets, then the replacement engine performs the expansion. The `TextExpansionController` and `TextReplacementEngine` are the key pieces bridging system input events to snippet output.

5. Snippet commands are part of the expansion pipeline rather than the UI. The editor exposes command-aware content such as `{cursor}`, `{clipboard}`, and `{addtext}`, and the core matcher/store/processing layer must preserve these semantics when a trigger is resolved into final inserted content.

6. Local storage is the default data boundary. The app is described as local-first, so snippets and preferences live on the Mac and are available offline. `SnippetStore` and `AppPreferences` are the most likely persistence anchors, with rich text and plain text both preserved for each snippet.

7. Cloud sync is optional and isolated behind `CloudSyncManager` and `CloudSyncAuthSheetView`. The README specifies Firebase Authentication plus Cloud Firestore, with email/password sign-in, one-time merge on first enablement, conflict handling that prefers newer snippet versions, and background upload when connectivity returns.

8. The app has a clear system-permission boundary. `PermissionManager` handles Accessibility access, while `LaunchAtLoginManager` manages startup behavior. These concerns affect whether expansion can run at all and whether the app remains active in the background.

9. The UI is organized around a dashboard/settings workflow plus a menu bar presence. `DashboardView` manages snippet/folder browsing, `SnippetEditorView` and `MarkdownTextEditor` handle snippet authoring, `SettingsView` exposes app controls, and `MenuBarContentView` supports running the app without a full window.

10. Import/export is a separate data-transfer path. `SnippetTransferController` and `SnippetTransferDocument` provide snippet backup and migration between Macs, distinct from cloud sync because it is user-initiated and file-based rather than continuous.

11. The app entry point is split between `DashTypeApp.swift` and `AppDelegate.swift`, reflecting a modern SwiftUI app with some AppKit lifecycle integration. That split is typical for macOS apps that need menu bar, launch-at-login, or accessibility-related behavior beyond pure SwiftUI.

12. Tests are concentrated on the core layer in `Tests/DashTypeCoreTests`, covering matcher, store, and command processing behavior. That placement reinforces the architecture: business rules are expected to stay stable independently of the macOS UI.

13. Supporting infrastructure includes `Config/` for plist and entitlements, `Assets.xcassets` for app icon/resources, and `Tools/generate_app_icon.swift` for asset generation. The presence of `GoogleService-Info.plist` in config is the main external-service indicator, tying the app to Firebase for sync.

Main entry points: [`Sources/DashTypeCore/SnippetStore.swift`](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeCore/SnippetStore.swift) (Store), [`DashType.xcodeproj/project.pbxproj`](https://github.com/ismailhrifat/dashtype/blob/main/DashType.xcodeproj/project.pbxproj) (Xcode project), [`Sources/DashTypeApp/DashboardView.swift`](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/DashboardView.swift) (Dashboard), [`Sources/DashTypeApp/TextReplacementEngine.swift`](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/TextReplacementEngine.swift) (Replacement)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_app["App layer"]
  node_node_entry["App entry<br/>SwiftUI app lifecycle<br/>[DashTypeApp.swift]"]
  node_node_delegate["Delegate<br/>AppKit lifecycle<br/>[AppDelegate.swift]"]
  node_node_dashboard["Dashboard<br/>main workspace UI"]
  node_node_editor["Snippet editor<br/>authoring UI"]
  node_node_markdown["Markdown editor<br/>text editor view"]
  node_node_settings["Settings<br/>preferences UI<br/>[SettingsView.swift]"]
  node_node_menubar["Menu bar<br/>background UI"]
  node_node_expansion["Expansion<br/>runtime hot path"]
  node_node_replacement["Replacement<br/>insert engine"]
  node_node_transfer_ctrl["Transfer ctrl<br/>file transfer flow"]
end

subgraph group_group_core["Core domain"]
  node_node_snippet["Snippet<br/>domain model<br/>[Snippet.swift]"]
  node_node_folder["Folders<br/>organization model"]
  node_node_matcher["Matcher<br/>trigger resolver"]
  node_node_match["Match<br/>[SnippetMatch.swift]"]
  node_node_store[("Store<br/>[SnippetStore.swift]")]
  node_node_transfer_doc["Transfer doc<br/>import/export document"]
end

subgraph group_group_infra["Infrastructure"]
  node_node_app_prefs[("Prefs<br/>local preferences")]
  node_node_permissions["Permissions<br/>accessibility gate"]
  node_node_launch["Launch at login<br/>startup control"]
  node_node_sync_manager["Cloud sync<br/>sync coordinator"]
  node_node_sync_auth["Sync auth<br/>firebase auth UI"]
end

subgraph group_group_build["Build and support"]
  node_node_pkg["Package manifest<br/>SwiftPM manifest<br/>[Package.swift]"]
  node_node_xcodeproj["Xcode project<br/>build project<br/>[project.pbxproj]"]
  node_node_config["Config<br/>plist/entitlements"]
  node_node_assets["Assets<br/>app resources<br/>[Assets.xcassets]"]
  node_node_tools["Tooling<br/>generation script"]
end

node_node_tests["Core tests<br/>test suite"]

node_node_entry -->|"lifecycle"| node_node_delegate
node_node_entry -->|"loads"| node_node_dashboard
node_node_dashboard -->|"edits"| node_node_editor
node_node_editor -->|"uses"| node_node_markdown
node_node_dashboard -->|"reads/writes"| node_node_store
node_node_dashboard -->|"organizes"| node_node_folder
node_node_settings -->|"persists"| node_node_app_prefs
node_node_settings -->|"checks"| node_node_permissions
node_node_settings -->|"toggles"| node_node_launch
node_node_menubar -->|"reflects"| node_node_app_prefs
node_node_expansion -->|"requires"| node_node_permissions
node_node_expansion -->|"matches"| node_node_matcher
node_node_expansion -->|"expands"| node_node_replacement
node_node_replacement -->|"renders"| node_node_snippet
node_node_replacement -->|"applies"| node_node_match
node_node_matcher -->|"queries"| node_node_store
node_node_matcher -->|"produces"| node_node_match
node_node_store -->|"stores"| node_node_snippet
node_node_store -->|"indexes"| node_node_folder
node_node_transfer_ctrl -->|"serializes"| node_node_transfer_doc
node_node_transfer_ctrl -->|"imports/exports"| node_node_store
node_node_sync_manager -->|"authenticates"| node_node_sync_auth
node_node_sync_manager -->|"syncs"| node_node_store
node_node_sync_manager -->|"merges"| node_node_snippet
node_node_xcodeproj -->|"builds"| node_node_entry
node_node_xcodeproj -->|"includes"| node_node_pkg
node_node_xcodeproj -->|"configures"| node_node_config
node_node_xcodeproj -->|"packages"| node_node_assets
node_node_tools -->|"generates"| node_node_assets
node_node_tests -->|"verifies"| node_node_matcher
node_node_tests -->|"verifies"| node_node_store
node_node_tests -->|"verifies"| node_node_replacement

click node_node_entry "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/DashTypeApp.swift"
click node_node_delegate "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/AppDelegate.swift"
click node_node_dashboard "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/DashboardView.swift"
click node_node_editor "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/SnippetEditorView.swift"
click node_node_markdown "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/MarkdownTextEditor.swift"
click node_node_settings "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/SettingsView.swift"
click node_node_menubar "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/MenuBarContentView.swift"
click node_node_app_prefs "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/AppPreferences.swift"
click node_node_permissions "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/PermissionManager.swift"
click node_node_launch "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/LaunchAtLoginManager.swift"
click node_node_sync_manager "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/CloudSyncManager.swift"
click node_node_sync_auth "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/CloudSyncAuthSheetView.swift"
click node_node_expansion "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/TextExpansionController.swift"
click node_node_replacement "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/TextReplacementEngine.swift"
click node_node_snippet "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeCore/Snippet.swift"
click node_node_folder "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeCore/SnippetFolder.swift"
click node_node_matcher "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeCore/SnippetMatcher.swift"
click node_node_match "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeCore/SnippetMatch.swift"
click node_node_store "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeCore/SnippetStore.swift"
click node_node_transfer_doc "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeCore/SnippetTransferDocument.swift"
click node_node_transfer_ctrl "https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/SnippetTransferController.swift"
click node_node_tests "https://github.com/ismailhrifat/dashtype/tree/main/Tests/DashTypeCoreTests"
click node_node_pkg "https://github.com/ismailhrifat/dashtype/blob/main/Package.swift"
click node_node_xcodeproj "https://github.com/ismailhrifat/dashtype/blob/main/DashType.xcodeproj/project.pbxproj"
click node_node_config "https://github.com/ismailhrifat/dashtype/blob/main/Config/DashType-Info.plist"
click node_node_assets "https://github.com/ismailhrifat/dashtype/blob/main/Assets.xcassets"
click node_node_tools "https://github.com/ismailhrifat/dashtype/blob/main/Tools/generate_app_icon.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_node_entry,node_node_delegate,node_node_dashboard,node_node_editor,node_node_markdown,node_node_settings,node_node_menubar,node_node_expansion,node_node_replacement,node_node_transfer_ctrl toneBlue
class node_node_snippet,node_node_folder,node_node_matcher,node_node_match,node_node_store,node_node_transfer_doc toneAmber
class node_node_app_prefs,node_node_permissions,node_node_launch,node_node_sync_manager,node_node_sync_auth toneMint
class node_node_pkg,node_node_xcodeproj,node_node_config,node_node_assets,node_node_tools toneRose
class node_node_tests toneNeutral
```

## Components

### App layer

SwiftUI macOS application, views, and runtime orchestration.

- [App entry](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/DashTypeApp.swift): SwiftUI app lifecycle · Starts the macOS app and bridges into AppKit lifecycle code. · `Sources/DashTypeApp/DashTypeApp.swift`
- [Delegate](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/AppDelegate.swift): AppKit lifecycle · Handles app lifecycle integration beyond pure SwiftUI. · `Sources/DashTypeApp/AppDelegate.swift`
- [Dashboard](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/DashboardView.swift): main workspace UI · Primary snippet and folder browsing surface. · `Sources/DashTypeApp/DashboardView.swift`
- [Snippet editor](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/SnippetEditorView.swift): authoring UI · Snippet editing experience, including rich text entry. · `Sources/DashTypeApp/SnippetEditorView.swift`
- [Markdown editor](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/MarkdownTextEditor.swift): text editor view · Reusable rich-text/plain-text editing component. · `Sources/DashTypeApp/MarkdownTextEditor.swift`
- [Settings](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/SettingsView.swift): preferences UI · Application controls and configuration surface. · `Sources/DashTypeApp/SettingsView.swift`
- [Menu bar](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/MenuBarContentView.swift): background UI · Menu bar presence for always-available background operation. · `Sources/DashTypeApp/MenuBarContentView.swift`
- [Expansion](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/TextExpansionController.swift): runtime hot path · Observes input, matches triggers, and performs expansion. · `Sources/DashTypeApp/TextExpansionController.swift`
- [Replacement](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/TextReplacementEngine.swift): insert engine · Transforms resolved snippets into inserted output and cursor behavior. · `Sources/DashTypeApp/TextReplacementEngine.swift`
- [Transfer ctrl](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/SnippetTransferController.swift): file transfer flow · User-initiated snippet import/export orchestration. · `Sources/DashTypeApp/SnippetTransferController.swift`

### Core domain

Snippet data model, matching, storage, and transfer rules.

- [Snippet](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeCore/Snippet.swift): domain model · Core snippet representation including content and metadata. · `Sources/DashTypeCore/Snippet.swift`
- [Folders](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeCore/SnippetFolder.swift): organization model · Snippet folder hierarchy and organization rules. · `Sources/DashTypeCore/SnippetFolder.swift`
- [Matcher](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeCore/SnippetMatcher.swift): trigger resolver · Finds snippet matches from trigger text and current context. · `Sources/DashTypeCore/SnippetMatcher.swift`
- [Match](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeCore/SnippetMatch.swift): match result · Represents a resolved snippet match and its selection state. · `Sources/DashTypeCore/SnippetMatch.swift`
- [Store](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeCore/SnippetStore.swift): local store · Local-first persistence boundary for snippets and their rich/plain text. · `Sources/DashTypeCore/SnippetStore.swift`
- [Transfer doc](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeCore/SnippetTransferDocument.swift): import/export document · File-based snippet backup and migration format. · `Sources/DashTypeCore/SnippetTransferDocument.swift`

### Infrastructure

Permissions, persistence, cloud sync, and launch behavior.

- [Prefs](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/AppPreferences.swift): local preferences · Local application preferences and state. · `Sources/DashTypeApp/AppPreferences.swift`
- [Permissions](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/PermissionManager.swift): accessibility gate · Manages Accessibility access required for keystroke observation. · `Sources/DashTypeApp/PermissionManager.swift`
- [Launch at login](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/LaunchAtLoginManager.swift): startup control · Controls whether the app remains active on system start. · `Sources/DashTypeApp/LaunchAtLoginManager.swift`
- [Cloud sync](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/CloudSyncManager.swift): sync coordinator · Coordinates optional Firebase-backed snippet synchronization. · `Sources/DashTypeApp/CloudSyncManager.swift`
- [Sync auth](https://github.com/ismailhrifat/dashtype/blob/main/Sources/DashTypeApp/CloudSyncAuthSheetView.swift): firebase auth UI · Authentication sheet for enabling cloud sync. · `Sources/DashTypeApp/CloudSyncAuthSheetView.swift`

### Build and support

Project configuration, assets, and generated/supporting files.

- [Package manifest](https://github.com/ismailhrifat/dashtype/blob/main/Package.swift): SwiftPM manifest · Secondary build manifest alongside the Xcode project. · `Package.swift`
- [Xcode project](https://github.com/ismailhrifat/dashtype/blob/main/DashType.xcodeproj/project.pbxproj): build project · Primary build system and workspace configuration. · `DashType.xcodeproj/project.pbxproj`
- [Config](https://github.com/ismailhrifat/dashtype/blob/main/Config/DashType-Info.plist): plist/entitlements · App plist, entitlements, and Firebase service configuration. · `Config/DashType-Info.plist`
- [Assets](https://github.com/ismailhrifat/dashtype/blob/main/Assets.xcassets): app resources · App icon and asset catalog resources. · `Assets.xcassets`
- [Tooling](https://github.com/ismailhrifat/dashtype/blob/main/Tools/generate_app_icon.swift): generation script · Utility script for generating app icon assets. · `Tools/generate_app_icon.swift`

### Other components

- [Core tests](https://github.com/ismailhrifat/dashtype/tree/main/Tests/DashTypeCoreTests): test suite · Behavioral tests for matcher, store, and command processing. · `Tests/DashTypeCoreTests`

## Connections

- App entry → Delegate: lifecycle · App startup hands off to lifecycle integration.
- App entry → Dashboard: loads · Primary window/content starts with the dashboard.
- Dashboard → Snippet editor: edits · Dashboard opens the snippet editor for authoring.
- Snippet editor → Markdown editor: uses · Snippet editor relies on the text editing component.
- Dashboard → Store: reads/writes · Browsing and editing work against the local snippet store.
- Dashboard → Folders: organizes · Dashboard presents snippet folder structure.
- Settings → Prefs: persists · Settings update local preferences.
- Settings → Permissions: checks · Settings exposes the accessibility permission boundary.
- Settings → Launch at login: toggles · Settings controls launch-at-login behavior.
- Menu bar → Prefs: reflects · Menu bar state follows local app preferences.
- Expansion → Permissions: requires · Hot-path expansion depends on Accessibility access.
- Expansion → Matcher: matches · Observed text is resolved through the core matcher.
- Expansion → Replacement: expands · Matched snippets are converted into inserted content.
- Replacement → Snippet: renders · Replacement engine consumes snippet content and commands.
- Replacement → Match: applies · Replacement uses the resolved match to drive output behavior.
- Matcher → Store: queries · Matcher resolves triggers against stored snippets.
- Matcher → Match: produces · Matching yields a structured match result.
- Store → Snippet: stores · Local persistence centers on snippet records.
- Store → Folders: indexes · Store maintains folder organization alongside snippets.
- Transfer ctrl → Transfer doc: serializes · Import/export flow uses the transfer document format.
- Transfer ctrl → Store: imports/exports · File-based transfer moves snippets through the local store.
- Cloud sync → Sync auth: authenticates · Cloud sync is enabled through the authentication sheet.
- Cloud sync → Store: syncs · Cloud synchronization mirrors local snippet state.
- Cloud sync → Snippet: merges · Sync conflict handling operates on snippet versions.
- Xcode project → App entry: builds · Xcode project builds the app entry target.
- Xcode project → Package manifest: includes · Workspace also carries Swift Package support.
- Xcode project → Config: configures · Project consumes plist, entitlements, and Firebase config.
- Xcode project → Assets: packages · Project bundles app assets.
- Tooling → Assets: generates · Tooling creates icon assets used by the app.
- Core tests → Matcher: verifies · Tests cover matching behavior.
- Core tests → Store: verifies · Tests cover store behavior.
- Core tests → Replacement: verifies · Tests cover command-aware processing and expansion behavior.
