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.
Architecture Overview
Dayflow is a native macOS application built with SwiftUI that automatically tracks your screen activity and generates intelligent timelines using AI.High-Level Architecture
Dayflow follows a modular architecture with clear separation of concerns:System Architecture
Dayflow is a native macOS application built with:- SwiftUI for the user interface
- ScreenCaptureKit for screen recording
- GRDB for local SQLite database
- Combine for reactive data flow
- Swift Concurrency (async/await) for asynchronous operations
Key Design Principles
- Privacy-First: All data stays on the user’s Mac by default
- Provider-Agnostic: Pluggable AI provider architecture (Gemini, Local, ChatGPT/Claude, Dayflow Backend)
- Efficient Capture: Screenshot-based recording (10s intervals) instead of continuous video to minimize battery impact
- Batched Analysis: Groups screenshots into logical batches (~15-30 min) for efficient AI processing
- Offline-Capable: Core functionality works without internet (with local AI providers)
Core Components
ScreenRecorder
Purpose: Captures periodic screenshots of the active display Location:Dayflow/Core/Recording/ScreenRecorder.swift:82
Key Features:
- Screenshot-based capture (configurable interval, default 10 seconds)
- No recording indicator (uses ScreenCaptureKit screenshot API)
- Automatic pause/resume on system sleep, lock, and screensaver
- Multi-display support with active display tracking
- ~1080p resolution with JPEG compression (quality: 0.85)
idle: Not capturingstarting: Initiating capture setupcapturing: Active screenshot timer runningpaused: System event pause (sleep/lock), auto-resumes when ready
StorageManager
Purpose: Manages local database and file system storage Location:Dayflow/Core/Recording/StorageManager.swift:432
Responsibilities:
- SQLite database operations (GRDB)
- Screenshot file management
- Batch creation and tracking
- Timeline card persistence
- Observation (transcript) storage
- LLM call logging
- Automatic storage cleanup
screenshots: Captured screen images with timestampsanalysis_batches: Groups of screenshots for AI processingbatch_screenshots: Junction table linking batches to screenshotsobservations: AI-generated transcriptions of screenshotstimeline_cards: Final activity summaries displayed to usersllm_calls: Detailed logging of all LLM requests/responsesjournal_entries: Daily intentions and reflections (Beta)
AnalysisManager
Purpose: Orchestrates the batching and analysis pipeline Location:Dayflow/Core/Analysis/AnalysisManager.swift:25
Key Responsibilities:
- Monitors for unprocessed screenshots (runs every 60 seconds)
- Creates logical batches based on provider config (max duration, max gap)
- Queues batches for LLM processing
- Handles batch reprocessing for error recovery
- Performance tracking via Sentry transactions
LLMService
Purpose: Manages AI provider interactions and processing pipeline Location:Dayflow/Core/AI/LLMService.swift:32
Key Features:
- Provider Abstraction: Unified interface for multiple AI providers
- Fallback System: Automatic fallback to backup provider on errors
- Two-Stage Processing:
- Transcription: Screenshots → Observations (text descriptions)
- Card Generation: Observations → Timeline Cards (activity summaries)
- Sliding Window: Uses observations from previous batches for context continuity
- Error Handling: Creates error cards for failed batches, user-friendly error messages
- Gemini: 2 LLM calls per batch (most efficient)
- Local (Ollama): 33+ LLM calls per batch (frame-by-frame analysis)
- ChatGPT/Claude: 4-6 LLM calls per batch (batch frame processing)
- Dayflow Backend: Cloud processing alternative
AI Providers
GeminiDirectProvider
Location:Dayflow/Core/AI/GeminiDirectProvider.swift:8
Leverages Gemini’s native video understanding:
- Direct video upload and analysis
- Model fallback (gemini-2.0-flash-exp → gemini-1.5-flash)
- Automatic Gemma 2 fallback on capacity errors
OllamaProvider
Location:Dayflow/Core/AI/OllamaProvider.swift
Local model support via Ollama:
- Frame-by-frame image analysis
- Multi-call segment merging
- No cloud dependency
ChatCLIProvider
Location:Dayflow/Core/AI/ChatCLIProvider.swift
CLI-based frontier models:
- Batch frame processing (10 frames per call)
- Codex CLI (ChatGPT) or Claude Code support
- Streaming and chat capabilities
Tech Stack
Frameworks & Libraries
- SwiftUI: Native UI framework
- ScreenCaptureKit: Screen recording API (macOS 13+)
- GRDB: SQLite database toolkit
- Combine: Reactive programming
- Swift Concurrency: async/await, actors, tasks
- Sparkle: Auto-update framework
- PostHog: Product analytics (privacy-conscious)
- Sentry: Error tracking and performance monitoring
Development Tools
- Xcode 15+: IDE and build system
- Swift 5.9+: Programming language
- Git: Version control
Storage
- SQLite (GRDB): Local database with WAL mode
- File System: JPEG screenshots, video timelapses
- UserDefaults: App preferences and settings
- Keychain: Secure storage for API keys
Networking
- URLSession: HTTP client for AI provider APIs
- Foundation Networking: Standard library networking
Component Interactions
Recording Flow
- AppState manages recording state (
isRecordingpublished property) - ScreenRecorder observes state changes and starts/stops capture timer
- Timer fires every 10s (configurable), captures screenshot via ScreenCaptureKit
- Screenshot saved to file system as JPEG (~1080p, 85% quality)
- StorageManager persists screenshot metadata to
screenshotstable
Analysis Flow
- AnalysisManager timer fires every 60s, checks for unprocessed screenshots
- Groups screenshots into batches based on time gaps and duration
- Persists batches to
analysis_batchesandbatch_screenshotstables - Queues batch for LLMService processing
- LLMService selects AI provider and executes two-stage pipeline:
- Stage 1: Screenshots → Observations (transcription)
- Stage 2: Observations → Timeline Cards (generation)
- StorageManager saves observations and timeline cards
- UI reactively updates to show new timeline cards
Timeline Display Flow
- SwiftUI views observe StorageManager data
- Timeline cards fetched from database for selected day
- Cards grouped by category and time
- Timelapses generated on-demand when user clicks card
- Video processing service creates timelapse from screenshot range
Data Flow
Performance Characteristics
- App Size: ~25MB
- Memory Usage: ~100MB RAM
- CPU Usage: Less than 1% idle, ~5-10% during screenshot capture
- Battery Impact: Minimal (screenshot-based vs continuous video)
- Storage: Configurable (1GB - 20GB, or unlimited)
- Screenshot Size: ~50-200KB per screenshot (JPEG)
- Database Size: Grows with usage, automatic cleanup
Threading Model
- Main Actor: UI, AppState, MainWindowManager
- Background Queues:
com.dayflow.recorder: ScreenRecorder capture operationscom.dayflow.geminianalysis.queue: Analysis processingcom.dayflow.storage.writes: Database write operations
- Async/Await: LLM provider calls, file operations
- Combine Publishers: Reactive state propagation
Next Steps
- Project Structure - Detailed codebase organization
- AI Pipeline - Deep dive into AI processing stages