How jerryzliu/dayflow works
File structure
• Top-level directories:
• Dayflow/ — the Xcode project and all Swift source code
• docs/ — documentation, AppCast, images, hero assets
• scripts/ — release automation (DMG creation, Sparkle signing, appcast updates)
• .github/ — issue templates
• Inside Dayflow/Dayflow:
• App/ — SwiftUI entry points (AppDelegate, DayflowApp, AppState, InactivityMonitor)
• Core/ — capture (Recording), analysis orchestration (AnalysisManager, TimeParsing), AI provider interfaces (LLMService, GeminiDirectProvider, OllamaProvider, etc.), networking (FaviconService), security (KeychainManager), thumbnails, storage managers
• Models/ — data models for timeline cards and categories
• Views/ — SwiftUI MVVM layers: Components, Onboarding flows, UI screens (DashboardView, JournalView, SettingsView, etc.)
• System/ — low-level macOS integrations (StatusBarController, SilentUserDriver, UpdaterManager, HardwareInfo)
• Utilities/ — coloring, logging, Sentry, Gemini API helpers
Key insights from README
• Four main pipeline phases: Capture → Analyze → Generate → Display → Cleanup
• Two AI modes: Gemini (cloud calls) vs. Local (Ollama/LM Studio endpoint)
• Storage: video chunks on disk + chunks.sqlite for metadata
• Permissions: Screen & Audio Recording
• Auto-updates via Sparkle
A. Frontend / UI layer
• DayflowApp (SwiftUI) + AppDelegate → drives AppState
• Views: TimelineDashboard, JournalView, SettingsView, OnboardingFlow
B. Capture engine
• ActiveDisplayTracker + ScreenRecorder → produce 15-second .mp4 chunks at 1 FPS
• StorageManager / TimelapseStorageManager → writes video files to disk
C. Scheduling & cleanup
• InactivityMonitor / AppState scheduler → every 15 min trigger AnalysisManager
• StoragePreferences + CleanupService → auto-delete >3-day-old files
D. Analysis pipeline
• AnalysisManager + TimeParsing → batch recent video chunks
• LLMService (abstract protocol) → selects GeminiDirectProvider or OllamaProvider
• Gemini flow: single upload+transcribe call + generate cards call
• Local flow: extract frames → 30 LLM calls → merges & title generation calls
• LLMLogger → logs requests/responses (for debug/Sentry)
E. Data layer
• chunks.sqlite (SQLite) for card metadata and timeline entries
• FaviconService for website thumbnail lookups
• ThumbnailCache for UI thumbnails
F. External services
• Gemini API (cloud)
• Local LLM server (Ollama / LM Studio endpoint)
• Sparkle AppCast feed & signing service
G. System integrations
• KeychainManager for storing API keys
• UpdaterManager (Sparkle) for auto-update checks
• SilentUserDriver to interact with macOS sandbox/permissions
• HardwareInfo for device-specific tuning
Relationships & data flow
1. User launches DayflowApp → AppState initializes components (Recorder, Scheduler, UI)
2. ScreenRecorder captures frames → StorageManager writes chunks to disk
3. Scheduler (every 15 min) → AnalysisManager assembles video chunks
4. AnalysisManager → LLMService → chosen AI provider → returns timeline cards
5. AnalysisManager writes card metadata → SQLite
6. SwiftUI views observe AppState/Database → render timeline cards + thumbnails
7. InactivityMonitor + CleanupService periodically purge old chunks
8. UpdaterManager (in background) fetches appcast.xml → Sparkle handles new releases
Architectural patterns & design principles
• MVVM: SwiftUI Views bind to AppState / ObservableObjects
• Service/Provider pattern: LLMService protocol with pluggable providers (Gemini, Ollama)
• Layered architecture: UI → Application (AppState, Scheduler) → Core services → Data → External
• Separation of concerns: capture, analysis, storage, UI, external integration are modular
• Dependency injection via environment (GEMINI_API_KEY, local endpoint)
Don’t over-engineer—capture every logical component
• Even small utilities (KeychainManager, FaviconService) deserve representation if they play a role in overall flow
• Onboarding flow as a startup path before the regular pipeline