How conorzen/fitkit works
Project Type and Purpose
• This is a full‑stack mobile/watchOS fitness application (“WatchFit”) featuring:
• A watchOS frontend that tracks workouts via Apple’s WorkoutKit & HealthKit.
• An iOS companion app for settings, history, and analytics.
• A cloud backend (Supabase) for user authentication, training‑plan storage and sync.
• Local persistence (Core Data) for offline caching of workouts, user data.
• A WatchConnectivity channel to sync data between watch and phone.
File Structure
• Top‑level “run.xcodeproj” / “run” directory holds Swift code.
• “Assets.xcassets”, “Info.plist”, “runApp.swift” – entrypoint & app metadata.
• “Models” – Core Data entities & domain models (RecentRun, TrainingPlan, User).
• “Persistence.swift” + “run.xcdatamodeld” – Core Data stack.
• “Services” – AuthManager (Supabase auth), TrainingPlanService (REST calls), SupabaseConfig.
• “HKM” – HealthKitManager, workout configuration extension.
• “WatchConnectivity” – WatchSessionManager to sync between watchOS & iOS.
• “Views” – SwiftUI views, organized by feature (AuthenticationView, RunningView, CalendarView, SettingsView).
• “ThemeManager.swift” – UI theming.
• “runTests” / “runUITests” – unit & UI tests.
README for Additional Insights
• Leverages WorkoutKit & HealthKit for real‑time metrics.
• Uses Supabase as cloud backend (auth, data storage).
a. Main Components:
1. WatchOS App (UI Layer)
2. iOS Companion App (UI Layer)
3. Core Data Persistence Layer (Persistence.swift + run.xcdatamodeld)
4. HealthKit / WorkoutKit Frameworks (Apple SDKs)
5. Supabase Backend (Auth + Database)
6. WatchConnectivity Service
7. Local Models & Service Layer (AuthManager, TrainingPlanService, HealthKitManager)
b. Relationships & Interactions:
• WatchOS UI ⇄ HealthKitManager (WorkoutKit data capture)
• WatchOS UI ⇄ WatchSessionManager ⇄ iOS Companion UI (sync workout data & plans)
• Both WatchOS & iOS Apps ⇄ Persistence Layer (read/write Core Data)
• iOS App ⇄ Supabase (via AuthManager & TrainingPlanService for remote user data + plans)
• iOS App ⇄ HealthKitManager (to read/write Health data on phone)
c. Architectural Patterns & Principles:
• MVVM (SwiftUI Views bound to Models via @StateObject/ViewModel)
• Repository/Service Layer for external dependencies (HealthKit, Supabase)
• Single Source of Truth in Core Data
• Separation of Concerns: UI / Domain Models / Services / Persistence
d. Relevant Technologies:
• SwiftUI (UI)
• Apple WatchKit, HealthKit, WorkoutKit
• Core Data (Persistence)
• Supabase (Backend as a Service)
• WatchConnectivity Framework
• Combine (data binding, if used)
Elements
• Clear labels: e.g., “WatchOS App UI”, “HealthKitManager Service”, “Core Data Store”
– Data flow from WorkoutKit → WatchOS UI → Persistence → Supabase
– Client components (blue rectangles)
• Notes on authentication flow: Show OAuth token exchange with Supabase via AuthManager.