Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JerryZLiu/Dayflow/llms.txt

Use this file to discover all available pages before exploring further.

Project Structure

This page documents the organization of the Dayflow codebase and explains the purpose of each directory and key files.

Repository Layout

Dayflow/
├── Dayflow/                    # Main application sources
│   ├── App/                    # App lifecycle and state management
│   ├── Core/                   # Core services and business logic
│   ├── Views/                  # SwiftUI views and UI components
│   ├── Models/                 # Data models and types
│   ├── Menu/                   # Menu bar interface
│   ├── System/                 # System integrations
│   ├── Utilities/              # Helper functions and extensions
│   ├── Videos/                 # Video processing components
│   ├── Assets.xcassets/        # Images, icons, colors
│   ├── Fonts/                  # Custom fonts
│   ├── Info.plist              # App metadata and configuration
│   └── Dayflow.entitlements    # macOS permissions and capabilities
├── DayflowTests/               # Unit tests
├── DayflowUITests/             # UI tests
├── Dayflow.xcodeproj/          # Xcode project configuration
├── docs/                       # Documentation assets
│   └── images/                 # Screenshots, diagrams, marketing materials
└── scripts/                    # Release automation and build tools

Dayflow/ - Main App Sources

The main application code is organized into logical modules:

App/ - Application Lifecycle

Location: Dayflow/App/ Manages app initialization, state, and deep linking.
FilePurposeKey Types
DayflowApp.swiftSwiftUI app entry point@main DayflowApp
AppState.swiftGlobal app state (recording on/off)AppState (singleton)
AppDelegate.swiftAppKit app delegate for lifecycle hooksAppDelegate
MainWindowContent.swiftRoot window content viewMainWindowContent
AppDeepLinkRouter.swiftURL scheme handler (dayflow://)AppDeepLinkRouter
InactivityMonitor.swiftDetects user inactivity periodsInactivityMonitor
PauseManager.swiftManages recording pause statesPauseManager
Key Concepts:
  • AppState: Observable singleton that publishes isRecording state. All components observe this to sync recording state.
  • Deep Linking: Supports dayflow://start-recording and dayflow://stop-recording for automation.
  • Lifecycle: AppDelegate handles Sparkle updates, initial permissions, and window management.

Core/ - Business Logic Services

Location: Dayflow/Core/ Contains the core services that power Dayflow’s functionality:

Core/AI/ - AI Processing

Manages LLM providers and AI processing pipeline.
FilePurposeKey Types
LLMService.swift:32Main LLM orchestration serviceLLMService, LLMServicing
LLMTypes.swiftShared types for LLM systemBatchingConfig, LLMProviderType
GeminiDirectProvider.swift:8Gemini API providerGeminiDirectProvider
GeminiPromptPreferences.swiftGemini prompt configurationGeminiPromptPreferences
GeminiModelPreference.swiftGemini model selectionGeminiModelPreference, GeminiModel
GemmaBackupProvider.swiftGemma 2 fallback providerGemmaBackupProvider
OllamaProvider.swiftOllama local model providerOllamaProvider
OllamaPromptPreferences.swiftOllama prompt configurationOllamaPromptPreferences
ChatCLIProvider.swiftChatGPT/Claude CLI providerChatCLIProvider, ChatCLITool
ChatCLIRunner.swiftCLI execution wrapperChatCLIRunner
ChatCLIPromptPreferences.swiftCLI prompt configurationChatCLIPromptPreferences
ChatService.swiftChat interface for DashboardChatService
ChatToolExecutor.swiftTool execution for chatChatToolExecutor
DayflowBackendProvider.swiftDayflow cloud backend providerDayflowBackendProvider
LocalEngine.swiftLocal model engine abstractionLocalEngine
LocalModelPreset.swiftLocal model presetsLocalModelPreset
LocalEndpointUtilities.swiftLocal endpoint helpers-
LLMLogger.swiftLLM request/response loggingLLMLogger
LLMOutputLanguagePreferences.swiftOutput language settingsLLMOutputLanguagePreferences
DailyRecapScheduler.swiftScheduled recap generationDailyRecapScheduler
Key Concepts:
  • Provider Pattern: All AI providers implement common interfaces for transcription and card generation.
  • Fallback System: Gemini automatically falls back to Gemma 2 on capacity errors; system-wide backup provider support.
  • Sliding Window: Card generation uses observations from previous batches for context continuity.

Core/Recording/ - Screen Capture

Handles screen recording and storage management.
FilePurposeKey Types
ScreenRecorder.swift:82Screenshot capture engineScreenRecorder
StorageManager.swift:432Database and file managementStorageManager, StorageManaging
StoragePreferences.swiftStorage settingsStoragePreferences
JournalDayManager.swiftJournal day boundariesJournalDayManager
ActiveDisplayTracker.swiftMulti-display trackingActiveDisplayTracker
TimelapseStorageManager.swiftTimelapse file managementTimelapseStorageManager
VideoProcessingService.swiftTimelapse generationVideoProcessingService
Key Concepts:
  • Screenshot-Based: Captures at 10s intervals (configurable) instead of continuous video for battery efficiency.
  • GRDB: Uses SQLite with Write-Ahead Logging for safe concurrent access.
  • 4AM Boundary: Days start at 4 AM to align with natural sleep patterns.

Core/Analysis/ - Batch Processing

Orchestrates the analysis pipeline.
FilePurposeKey Types
AnalysisManager.swift:25Batch orchestrationAnalysisManager, AnalysisManaging
TimeParsing.swiftTime string parsing utilities-
Key Concepts:
  • Batching Strategy: Groups screenshots by time gaps (max 5 min) and duration (15-30 min).
  • Reprocessing: Supports day-level and batch-level retry for error recovery.

Core/Notifications/ - User Notifications

Manages system notifications and badges.
FilePurposeKey Types
NotificationService.swiftmacOS notification deliveryNotificationService
NotificationPreferences.swiftNotification settingsNotificationPreferences
NotificationBadgeManager.swiftMenu bar badge managementNotificationBadgeManager

Core/Security/ - Secure Storage

Handles sensitive data.
FilePurposeKey Types
KeychainManager.swiftAPI key storageKeychainManager

Core/Net/ - Networking

Network-related services.
FilePurposeKey Types
FaviconService.swiftFavicon fetching and cachingFaviconService

Core/Thumbnails/ - Image Caching

Screenshot thumbnail management.
FilePurposeKey Types
ThumbnailCache.swiftGeneric thumbnail cacheThumbnailCache
ScreenshotThumbnailCache.swiftScreenshot-specific cacheScreenshotThumbnailCache

Models/ - Data Types

Location: Dayflow/Models/ Defines core data structures used throughout the app.
FilePurposeKey Types
AnalysisModels.swiftAnalysis pipeline typesRecordingChunk, Screenshot, ActivityCardData, AppSites
ChatMessage.swiftChat interface typesChatMessage, ChatRole
TimelineCategory.swiftCategory systemTimelineCategory, CategoryStore, LLMCategoryDescriptor
Storage Models (defined in StorageManager.swift):
  • TimelineCard: Activity card with metadata
  • Observation: AI-generated transcript of screenshots
  • JournalEntry: Daily intentions and reflections
  • LLMCall: Logged LLM request/response
  • Distraction: Distraction event within a card

Views/ - User Interface

Location: Dayflow/Views/ SwiftUI views organized by feature area.
Views/
├── Components/          # Reusable UI components
├── Onboarding/          # First-run experience
└── UI/                  # Main app views
    ├── Timeline/        # Timeline view components
    ├── Settings/        # Settings panels
    ├── Journal/         # Daily journal (Beta)
    └── Dashboard/       # Dashboard (Beta)
Component Examples:
  • TimelineView.swift: Main timeline display
  • TimelineCardView.swift: Individual activity card
  • SettingsView.swift: Settings window
  • OnboardingFlow.swift: Setup wizard
Location: Dayflow/Menu/
FilePurpose
StatusMenuView.swiftMenu bar dropdown UI

System/ - System Integrations

Location: Dayflow/System/ Integrations with macOS system services.
FilePurposeKey Types
AnalyticsService.swiftPostHog analyticsAnalyticsService
LaunchAtLoginManager.swiftLogin item managementLaunchAtLoginManager
MainWindowManager.swiftWindow lifecycleMainWindowManager

Utilities/ - Helpers

Location: Dayflow/Utilities/ Extensions and utility functions.
  • Date extensions
  • String utilities
  • SwiftUI helpers
  • Color extensions

Videos/ - Video Processing

Location: Dayflow/Videos/ Timelapse generation from screenshots.

Configuration Files

Info.plist

Location: Dayflow/Info.plist App metadata:
  • Bundle identifier: com.jerryliudev.Dayflow
  • Minimum macOS version: 13.0
  • Required permissions: Screen Recording
  • URL schemes: dayflow://
  • Sparkle update feed

Dayflow.entitlements

Location: Dayflow/Dayflow.entitlements macOS capabilities:
  • Screen Recording
  • App Sandbox (when signed)
  • Network client (for AI APIs)
  • File system access (recordings folder)

External Directories

docs/ - Documentation Assets

Location: docs/ Marketing materials and screenshots:
  • images/: Hero images, screenshots, diagrams
  • Appcast XML for Sparkle updates

scripts/ - Build Automation

Location: scripts/ Release automation:
  • DMG creation
  • Code signing
  • Notarization
  • Sparkle appcast generation
  • One-button release workflow

Build Outputs

Build artifacts are stored outside the source tree:
  • App Bundle: DerivedData/Build/Products/Release/Dayflow.app
  • User Data: ~/Library/Application Support/Dayflow/
    • recordings/: Screenshot files (.jpg)
    • chunks.sqlite: Main database
    • backups/: Automatic database backups

Database Schema

See StorageManager.swift:638 for the complete schema. Key Tables:
  • screenshots: Captured images with timestamps
  • analysis_batches: Processing batches
  • batch_screenshots: Many-to-many junction table
  • observations: AI transcriptions
  • timeline_cards: Final activity cards
  • llm_calls: Request/response logs
  • journal_entries: Daily journal (Beta)
  • timeline_review_ratings: User ratings

Dependency Management

Dayflow uses Xcode frameworks linked directly in the project:
  • GRDB: Linked via Swift Package Manager or manual framework
  • Sparkle: Binary framework for auto-updates
  • PostHog: Analytics SDK
  • Sentry: Error tracking SDK
No CocoaPods or Carthage dependencies.

Testing Structure

DayflowTests/

Unit tests for business logic:
  • Storage layer tests
  • Date boundary tests
  • Model validation tests

DayflowUITests/

UI integration tests:
  • Onboarding flow
  • Timeline interactions
  • Settings panels

Code Organization Patterns

Protocols for Testability

Key services define protocols for dependency injection:
protocol StorageManaging: Sendable { /* ... */ }
protocol LLMServicing { /* ... */ }
protocol AnalysisManaging { /* ... */ }

Singleton Pattern

Core services use thread-safe singletons:
static let shared = LLMService()
static let shared = StorageManager()
static let shared = AnalysisManager()

Observable State

State uses Combine publishers:
@Published var isRecording: Bool

File Organization

Files follow this pattern:
  1. Copyright header
  2. Imports
  3. Protocols
  4. Main types
  5. Extensions
  6. Private helpers

Naming Conventions

  • Types: PascalCase (e.g., ScreenRecorder, LLMService)
  • Variables/Functions: camelCase (e.g., isRecording, processBatch)
  • Constants: camelCase (e.g., maxBatchDuration)
  • Protocols: Noun or -ing suffix (e.g., StorageManaging, Sendable)
  • Files: Match primary type name (e.g., ScreenRecorder.swift)

Next Steps