SleepFocus Frontend is a SwiftUI iOS application that connects Apple Health sleep data, backend scoring services, and model-powered recommendations into a single user experience.
The app provides:
- Sign in with Apple authentication and session management.
- HealthKit data access and sync for sleep and biometric streams.
- Home dashboard for sleep quality, focus prediction, and recommendations.
- Insights views for trend analysis and sleep/focus relationships.
- In-app chat experience for AI-assisted guidance.
- Smart alarm support with widget integration.
-
Authentication
- Sign in with Apple flow with profile confirmation for new users.
- Access and refresh token lifecycle support.
- Secure sign-out with server-side token revocation.
-
Health Data Pipeline
- Reads HealthKit samples for heart rate, HRV, respiratory rate, wrist temperature, environmental noise, and sleep stages.
- Builds adaptive chunked payloads to stay within backend upload size limits.
- Uses deterministic idempotency keys to prevent duplicate ingestion.
- Supports automatic and manual sync ranges.
-
Home and Insights
- Fetches
home-summarydata from backend APIs. - Caches month summaries for faster date navigation.
- Polls for model-backed scores while processing is in progress.
- Shows sleep metrics and stage breakdown from local HealthKit data for immediate UI feedback.
- Fetches
-
Smart Alarm
- Widget extension (
WidgetSmartAlarm) for alarm-related surfaces. - Shared models between app and widget target.
- Widget extension (
- SwiftUI
- Swift Concurrency (
async/await,actor) - HealthKit
- AuthenticationServices (Sign in with Apple)
- WidgetKit
SleepFocus_Frontend/
.github/workflows/build.yml
SleepFocus/
Components/
Extensions/
Models/
Screens/
Services/
ContentView.swift
SleepFocusApp.swift
WidgetSmartAlarm/
SleepFocus.xcodeproj/
- macOS with Xcode installed.
- iOS Simulator or physical iOS device.
- Apple Developer capabilities configured for:
- Sign in with Apple
- HealthKit
- Widget extension support
git clone git@github.com:SleepFocus/SleepFocus_Frontend.git
cd SleepFocus_FrontendOpen SleepFocus.xcodeproj, select the SleepFocus scheme, then build and run.
APIWrapper defaults to:
https://api.sleepfocusapp.com
For local or staging backends, update the base URL in SleepFocus/Services/API_Wrapper.swift or call updateBaseURL(...) at runtime in your app flow.
GitHub Actions workflow: .github/workflows/build.yml
Current workflow behavior:
- Runs on pushes to
mainand on pull requests. - Executes an iOS simulator build using
xcodebuildand theSleepFocusscheme.
- This repository contains only the iOS frontend and widget code.
- Backend APIs and model services are maintained in separate repositories.