Overview
HealthPush follows a clean, layered architecture with clear separation of concerns:Core Components
App Layer (Sources/App/)
HealthPushApp— SwiftUI app entry point. Registers background tasks and sets up the environment.AppState— Observable state container shared across views. Holds sync status, destination list, and configuration.
Models (Sources/Models/)
HealthDataPoint— The universal data structure for a single health measurement. Contains the metric type, value, unit, and timestamp.HealthMetricType— Enum of all supported Apple Health metrics (steps, heart rate, blood oxygen, etc.). Maps toHKQuantityTypeIdentifierandHKCategoryTypeIdentifier.SyncFrequency— Enum representing how often background syncs run.SyncRecord— Persisted record of each sync attempt (timestamp, destination, success/failure, data point count).DestinationConfig— SwiftData model for persisting destination settings.
Views (Sources/Views/)
Screens/— Full-screen views: Dashboard, Destinations list, Health Metrics picker, Settings, and per-destination setup screens.Components/— Reusable UI elements shared across screens.
AppState for reactive updates.
Services (Sources/Services/)
- HealthKit Service — Wraps
HKHealthStore. Handles authorization, queries, and observer queries for real-time updates. - Background Sync Service — Manages
BGTaskSchedulerregistration and execution. Coordinates the sync cycle: query HealthKit, batch data, dispatch to destinations. - Network Service — Thin wrapper around
URLSessionfor making HTTP requests. Used by destinations that push over the network.
Destinations (Sources/Destinations/)
SyncDestination— The core protocol. Every sync target implements this.DestinationManager— Registry of available destination types. Handles creating, storing, and retrieving configured destinations.S3Destination— Direct export to an S3 bucket with JSON or CSV output and deduplicated uploads.HomeAssistantDestination— Webhook-based sync to a Home Assistant instance via the custom integration.
Data Flow
Manual Sync
Background Sync
Persistence
- SwiftData stores all local state:
- Destination configurations (URLs, tokens, enabled metrics)
- Sync history (SyncRecord)
- User preferences (sync frequency, selected metrics)
- No iCloud sync — everything stays on-device
- Keychain-backed secrets — destination credentials are stored in Keychain; SwiftData stores only non-secret configuration and sync metadata
Home Assistant Integration
The HA side is a custom component (integrations/homeassistant/custom_components/healthpush/):
- Registers a webhook during config flow setup
- Parses incoming health data payloads
- Registers sensor entities with proper device classes, units, and icons, then updates them as webhook data arrives
- Supports multiple iOS devices reporting to the same HA instance