Cross-platform mobile health data sync application. WearaBridge connects to Health Connect (Android) and HealthKit (iOS) to automatically sync health data to your backend in the background.
WearaBridge is a simple Flutter mobile app that:
- β Auto-generates unique device ID on first launch
- β Syncs health data automatically every 30 minutes (no login required)
- β Shows 5-digit pairing code that refreshes every 30 seconds
- β Users claim devices via web dashboard using the code
- β Works with any backend - see API_REQUIREMENTS.md
-
Configure backend URL in lib/core/config/app_config.dart:
static const String apiBaseUrl = 'https://your-backend.com';
-
Backend Integration - Share API_REQUIREMENTS.md with your backend team
-
Install dependencies:
flutter pub get
-
Run:
flutter run
- App generates unique device ID (UUID) on first launch
- App starts syncing health data immediately with device IDin header
- User opens pairing screen, app requests 5-digit code from backend
- Backend generates code (valid 30 seconds) linked to device ID
- User enters code in web dashboard to claim device
- Backend associates device ID with user account
- Historical data now visible under user's account
wearabridge/
βββ lib/
β βββ main.dart # App entry point
β βββ core/
β β βββ config/app_config.dart # API endpoints & configuration
β β βββ constants/health_data_types.dart
β β βββ network/api_client.dart # HTTP client with auth
β βββ data/
β β βββ datasources/
β β β βββ health_datasource.dart # Health Connect/HealthKit wrapper
β β β βββ api_datasource.dart # Backend API calls
β β βββ models/
β β β βββ health_data_point.dart # Data models
β β βββ repositories/
β β βββ health_repository.dart # Business logic layer
β βββ services/
β β βββ background_sync_service.dart # WorkManager background tasks
β β βββ auth_service.dart # Authentication
β βββ presentation/
β βββ screens/ # UI screens
β βββ widgets/ # Reusable widgets
β βββ providers/ # Riverpod state management
- Steps - Daily step count
- Heart Rate - Continuous heart rate measurements
- Sleep - Sleep sessions with quality data
- Workouts - Exercise activities
- Distance - Distance traveled
- Active Calories - Calories burned during activity
- Blood Oxygen - SpO2 readings
- Resting Heart Rate - RHR measurements
- Flutter SDK 3.9.2+
- Android Studio (for Android development)
- Xcode (for iOS development)
-
Install dependencies:
cd wearabridge flutter pub get -
Configure backend URL: Edit
lib/core/config/app_config.dart:static const String apiBaseUrl = 'https://your-backend.com'; // CHANGE THIS
-
Backend Setup:
- Share
API_REQUIREMENTS.mdwith your backend team - Backend needs to implement 4 endpoints (see API_REQUIREMENTS.md)
- No authentication on mobile app side - device ID only
- Share
-
Android Setup:
- Health Connect requires Android 14+ or the Health Connect APK
- Permissions configured in
AndroidManifest.xml
-
iOS Setup:
- HealthKit permissions configured in
Info.plist - Requires iOS 13.0+
- HealthKit permissions configured in
-
Run:
flutter run
The app uses WorkManager to schedule periodic background syncs:
- Frequency: Every 30 minutes (configurable)
- Constraints: Requires network connection, battery not low
- Retry Policy: Exponential backoff on failure
- Data: Syncs data since last successful sync (up to 7 days lookback)
- App registers periodic background task on login
- Task wakes up every 30 minutes
- Fetches new health data from Health Connect/HealthKit
- Batches data and sends POST request to
/v1/health/sync - Updates last sync timestamp
- Retries on failure with exponential backoff
The app syncs to: POST /v1/health/sync
Request Body:
{
"userId": "user_123",
"deviceType": "android",
"syncedAt": "2026-02-26T10:30:00Z",
"lastSyncTime": "2026-02-26T10:00:00Z",
"data": [
{
"type": "STEPS",
"value": "1250",
"unit": "count",
"dateFrom": "2026-02-26T10:00:00Z",
"dateTo": "2026-02-26T10:30:00Z",
"sourcePlatform": "HEALTH_CONNECT",
"sourceDevice": "Pixel 8",
"metadata": {}
}
]
}Response (201):
{
"success": true,
"stored": 1,
"syncedAt": "2026-02-26T10:30:00Z"
}- Auto-navigates to Login or Home based on auth state
- Email/password authentication
- Connects to existing bodypress-backend auth system
- Shows sync status and last sync time
- Displays today's stats (steps, heart rate, sleep)
- Pull-to-refresh for manual sync
- Requests permissions if not granted
- Manage sync frequency
- Toggle background sync on/off
- View/request health permissions
- Logout
- π Auth tokens stored in
flutter_secure_storage - π API calls authenticated with Bearer token
β οΈ Health data never stored locally except in platform's secure health storage- π HTTPS required for all API communication
- π« No third-party analytics or tracking
- Minimum SDK: 26 (Android 8.0)
- Target SDK: 34 (Android 14)
- Health Connect installed (built-in on Android 14+)
- Permissions declared in
AndroidManifest.xml
- Minimum: iOS 13.0
- HealthKit capability enabled
- Privacy strings in
Info.plist - Background modes: fetch, processing
flutter run --debugAndroid:
flutter build apk --release
# or
flutter build appbundle --releaseiOS:
flutter build ios --releaseFor Freezed models and Riverpod providers:
flutter pub run build_runner build --delete-conflicting-outputsflutter testflutter test integration_test- Requires Health Connect certification from Google
- Submit app for review with health permissions usage explanation
- Requires clear explanation of HealthKit usage in App Review
- Privacy policy mandatory
Edit lib/core/config/app_config.dart:
// Sync every 15 minutes instead of 30
static const Duration syncInterval = Duration(minutes: 15);
// Change batch size
static const int batchSize = 50;
// Adjust retry attempts
static const int maxRetries = 5;- Install Health Connect from Play Store
- Or use Android 14+ which has it built-in
- Check Info.plist has NSHealthShareUsageDescription
- Rebuild the app after adding permissions
- Check battery optimization settings
- Ensure network connectivity
- View logs:
flutter logs
- Verify backend is running
- Check API endpoint in app_config.dart
- Ensure user is logged in
- Selective data type sync
- Sync frequency customization in UI
- Offline data visualization
- Export health data
- Multi-account support
- Dark/light theme toggle
- Framework: Flutter 3.9.2+
- Language: Dart
- State Management: Riverpod
- HTTP Client: Dio
- Health Data: health package
- Background Tasks: workmanager
- Local Storage: flutter_secure_storage, shared_preferences
- Database (Backend): PostgreSQL + Prisma
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
MIT