How ismailhrifat/dashtype works
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: SnippetStore.swift Store · project.pbxproj Xcode project · DashboardView.swift Dashboard · TextReplacementEngine.swift Replacement
Components 27
App layer
SwiftUI macOS application, views, and runtime orchestration.
- App entry · Starts the macOS app and bridges into AppKit lifecycle code.
Sources/DashTypeApp/DashTypeApp.swift - Delegate · Handles app lifecycle integration beyond pure SwiftUI.
Sources/DashTypeApp/AppDelegate.swift - Dashboard · Primary snippet and folder browsing surface.
Sources/DashTypeApp/DashboardView.swift - Snippet editor · Snippet editing experience, including rich text entry.
Sources/DashTypeApp/SnippetEditorView.swift - Markdown editor · Reusable rich-text/plain-text editing component.
Sources/DashTypeApp/MarkdownTextEditor.swift - Settings · Application controls and configuration surface.
Sources/DashTypeApp/SettingsView.swift - Menu bar · Menu bar presence for always-available background operation.
Sources/DashTypeApp/MenuBarContentView.swift - Expansion · Observes input, matches triggers, and performs expansion.
Sources/DashTypeApp/TextExpansionController.swift - Replacement · Transforms resolved snippets into inserted output and cursor behavior.
Sources/DashTypeApp/TextReplacementEngine.swift - Transfer ctrl · User-initiated snippet import/export orchestration.
Sources/DashTypeApp/SnippetTransferController.swift
Core domain
Snippet data model, matching, storage, and transfer rules.
- Snippet · Core snippet representation including content and metadata.
Sources/DashTypeCore/Snippet.swift - Folders · Snippet folder hierarchy and organization rules.
Sources/DashTypeCore/SnippetFolder.swift - Matcher · Finds snippet matches from trigger text and current context.
Sources/DashTypeCore/SnippetMatcher.swift - Match · Represents a resolved snippet match and its selection state.
Sources/DashTypeCore/SnippetMatch.swift - Store · Local-first persistence boundary for snippets and their rich/plain text.
Sources/DashTypeCore/SnippetStore.swift - Transfer doc · File-based snippet backup and migration format.
Sources/DashTypeCore/SnippetTransferDocument.swift
Infrastructure
Permissions, persistence, cloud sync, and launch behavior.
- Prefs · Local application preferences and state.
Sources/DashTypeApp/AppPreferences.swift - Permissions · Manages Accessibility access required for keystroke observation.
Sources/DashTypeApp/PermissionManager.swift - Launch at login · Controls whether the app remains active on system start.
Sources/DashTypeApp/LaunchAtLoginManager.swift - Cloud sync · Coordinates optional Firebase-backed snippet synchronization.
Sources/DashTypeApp/CloudSyncManager.swift - Sync auth · Authentication sheet for enabling cloud sync.
Sources/DashTypeApp/CloudSyncAuthSheetView.swift
Build and support
Project configuration, assets, and generated/supporting files.
- Package manifest · Secondary build manifest alongside the Xcode project.
Package.swift - Xcode project · Primary build system and workspace configuration.
DashType.xcodeproj/project.pbxproj - Config · App plist, entitlements, and Firebase service configuration.
Config/DashType-Info.plist - Assets · App icon and asset catalog resources.
Assets.xcassets - Tooling · Utility script for generating app icon assets.
Tools/generate_app_icon.swift
Other components
- Core tests · Behavioral tests for matcher, store, and command processing.
Tests/DashTypeCoreTests
Connections 32
- 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.