Skip to content

JamTheDev/flowfit

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

76 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FlowFit

A comprehensive health and fitness tracking application for Wear OS (Galaxy Watch) with companion phone app support. Built with Flutter and integrated with Samsung Health Sensor SDK.

flutter run -d adb-RFAX21TD0NA-FFYRNh._adb-tls-connect._tcp -t lib/main_wear.dart flutter run -d 6ece264d -t lib/main.dart

πŸ“ Project recently reorganized! All documentation is now in docs/ and scripts in scripts/. See docs/INDEX.md for complete documentation index.

🎯 Overview

FlowFit is a dual-platform fitness app that runs on:

  • Galaxy Watch (Wear OS) - Primary device for real-time health tracking
  • Android Phone - Companion app for data visualization and management

Key Features

  • βœ… Real-time Heart Rate Monitoring - Continuous HR tracking with Samsung Health Sensor SDK
  • βœ… Inter-Beat Interval (IBI) Data - Advanced HRV analysis
  • βœ… Activity Tracking - Workout logging and exercise monitoring
  • βœ… Sleep Tracking - Sleep mode with sensor integration
  • βœ… Nutrition Logging - Food diary and calorie tracking
  • βœ… Mood Tracking - Mental wellness monitoring
  • βœ… Data Synchronization - Watch ↔ Phone data transfer
  • βœ… Supabase Backend - Cloud storage and sync

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     Galaxy Watch (Wear OS)          β”‚
β”‚  - Heart rate monitoring            β”‚
β”‚  - Activity tracking                β”‚
β”‚  - Sleep tracking                   β”‚
β”‚  - Real-time sensor data            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚ Wearable Data Layer
               β”‚ (MessageClient/DataClient)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     Android Phone (Companion)       β”‚
β”‚  - Data visualization               β”‚
β”‚  - Historical analysis              β”‚
β”‚  - Detailed reports                 β”‚
β”‚  - Settings management              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚ Supabase API
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     Supabase Backend                β”‚
β”‚  - PostgreSQL database              β”‚
β”‚  - Real-time subscriptions          β”‚
β”‚  - Authentication                   β”‚
β”‚  - Cloud storage                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“± Devices

Watch Device (SM_R930)

  • Model: Galaxy Watch (SM_R930)
  • Device ID: adb-RFAX21TD0NA-FFYRNh._adb-tls-connect._tcp
  • Platform: Wear OS powered by Samsung
  • Purpose: Primary health tracking device
  • Run Command: flutter run -d adb-RFAX21TD0NA-FFYRNh._adb-tls-connect._tcp -t lib/main_wear.dart

Phone Device (22101320G)

  • Model: Android Phone (22101320G)
  • Device ID: 6ece264d
  • Purpose: Companion app for data visualization
  • Run Command: flutter run -d 6ece264d -t lib/main.dart

πŸš€ Quick Start

Prerequisites

Hardware:

  • Galaxy Watch4 or higher (Wear OS 3.0+)
  • Android phone (API 23+)
  • Both devices paired via Galaxy Wearable app

Software:

  • Flutter SDK (3.10.0+)
  • Android Studio with Kotlin support
  • Samsung Health app installed on watch
  • Supabase account (for backend)

Installation

  1. Clone and setup

    git clone <repository-url>
    cd flowfit
    flutter pub get
  2. Configure Supabase

    • Copy lib/secrets.dart.example to lib/secrets.dart
    • Add your Supabase URL and anon key
  3. Deploy to devices

    # Watch app
    scripts\test-watch.bat
    
    # Phone app (in another terminal)
    scripts\test-phone.bat

Testing Connection

  1. Start phone app first
  2. Start watch app
  3. On watch: tap "Heart Rate" β†’ "START"
  4. Wait for heart rate reading
  5. Tap "SEND" β†’ check phone receives data

Troubleshooting? See WATCH_CONNECTION_GUIDE.md

πŸ”§ Samsung Health Sensor Integration

Setup

The app uses Samsung Health Sensor SDK for real-time heart rate monitoring. See detailed setup guides:

Usage Example

import 'package:flowfit/services/watch_bridge.dart';

final watchBridge = WatchBridgeService();

// 1. Request permission
await watchBridge.requestBodySensorPermission();

// 2. Connect to Samsung Health
await watchBridge.connectToWatch();

// 3. Start tracking
await watchBridge.startHeartRateTracking();

// 4. Listen to heart rate data
watchBridge.heartRateStream.listen((data) {
  print('Heart Rate: ${data.bpm} BPM');
  print('IBI Values: ${data.ibiValues}');
});

// 5. Stop tracking
await watchBridge.stopHeartRateTracking();

Heart Rate Data Structure

HeartRateData {
  bpm: 72,                    // Heart rate in beats per minute
  ibiValues: [850, 845, 855], // Inter-beat intervals (ms)
  timestamp: DateTime.now(),   // When reading was taken
  status: SensorStatus.active  // active, inactive, error
}

πŸ“Š Features

Watch App Features

  1. Clean Dashboard (lib/screens/wear/wear_dashboard.dart)

    • Single large "Heart Rate" button
    • Minimal, focused design
    • Optimized for small screens
  2. Heart Rate Monitor (lib/screens/wear/wear_heart_rate_screen.dart)

    • Large BPM display (56pt font)
    • Simple START/STOP button
    • One-tap SEND to phone
    • Real-time status indicator
    • Samsung Health SDK integration
    • IBI data collection

Phone App Features

  1. Dashboard (lib/screens/dashboard.dart)

    • Overview of all health metrics
    • Historical data charts
    • Sync status
  2. Workout Library (lib/screens/workout/workout_library.dart)

    • Exercise database
    • Workout history
    • Performance analytics
  3. Nutrition Logger (lib/screens/nutrition/food_logger.dart)

    • Food diary
    • Calorie tracking
    • Nutritional analysis

πŸ”Œ Data Synchronization

Watch β†’ Phone Transfer

The app uses Wearable Data Layer API for real-time data transfer:

// On Watch: Send heart rate data
messageClient.sendMessage(
  nodeId,
  "/heart_rate",
  jsonEncode(heartRateData)
);

// On Phone: Receive data
class DataListenerService extends WearableListenerService {
  @override
  void onMessageReceived(MessageEvent messageEvent) {
    final data = jsonDecode(messageEvent.data);
    // Process and display data
  }
}

Supabase Sync

Both devices sync to Supabase for persistent storage:

// Save heart rate to Supabase
await supabase.from('heart_rates').insert({
  'user_id': userId,
  'bpm': heartRateData.bpm,
  'timestamp': heartRateData.timestamp.toIso8601String(),
  'ibi_values': heartRateData.ibiValues,
});

πŸ—‚οΈ Project Structure

flowfit/
β”œβ”€β”€ android/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ libs/
β”‚   β”‚   β”‚   └── samsung-health-sensor-api-1.4.1.aar
β”‚   β”‚   └── src/main/kotlin/com/example/flowfit/
β”‚   β”‚       β”œβ”€β”€ MainActivity.kt
β”‚   β”‚       └── HealthTrackingManager.kt
β”‚   └── build.gradle.kts
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ main.dart                    # Phone app entry
β”‚   β”œβ”€β”€ main_wear.dart               # Watch app entry
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ heart_rate_data.dart
β”‚   β”‚   β”œβ”€β”€ activity.dart
β”‚   β”‚   β”œβ”€β”€ sleep_session.dart
β”‚   β”‚   └── mood_log.dart
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ watch_bridge.dart        # Samsung Health SDK bridge
β”‚   β”‚   β”œβ”€β”€ supabase_service.dart    # Backend service
β”‚   β”‚   └── sleep_service.dart
β”‚   β”œβ”€β”€ screens/
β”‚   β”‚   β”œβ”€β”€ wear/                    # Watch-specific screens
β”‚   β”‚   β”œβ”€β”€ workout/
β”‚   β”‚   β”œβ”€β”€ sleep/
β”‚   β”‚   └── nutrition/
β”‚   └── examples/
β”‚       └── heart_rate_example.dart
β”œβ”€β”€ docs/                            # Documentation
β”‚   β”œβ”€β”€ QUICK_START.md
β”‚   β”œβ”€β”€ SAMSUNG_HEALTH_SETUP_GUIDE.md
β”‚   β”œβ”€β”€ IMPLEMENTATION_CHECKLIST.md
β”‚   β”œβ”€β”€ INSTALLATION_TROUBLESHOOTING.md
β”‚   β”œβ”€β”€ BUILD_FIXES_APPLIED.md
β”‚   β”œβ”€β”€ HEART_RATE_DATA_FLOW.md
β”‚   β”œβ”€β”€ WEAR_OS_SETUP.md
β”‚   β”œβ”€β”€ RUN_INSTRUCTIONS.md
β”‚   β”œβ”€β”€ VGV_IMPROVEMENTS.md
β”‚   └── WEAR_OS_IMPROVEMENTS.md
β”œβ”€β”€ scripts/                         # Build and run scripts
β”‚   β”œβ”€β”€ build_and_install.bat
β”‚   β”œβ”€β”€ run_watch.bat
β”‚   └── run_phone.bat
β”œβ”€β”€ pubspec.yaml
└── README.md

πŸ› Troubleshooting

Build Issues

"Unresolved reference: ConnectionListener"

# Clean and rebuild
flutter clean
flutter pub get
flutter run -d <device-id>

"JVM-target compatibility detected"

  • Check android/app/build.gradle.kts
  • Ensure jvmTarget = "17" is set

Runtime Issues

"Connection Failed" on Watch

  • Ensure Samsung Health is installed
  • Check watch supports Samsung Health Sensor SDK
  • Restart watch and try again

"Permission Denied"

  • Go to Settings β†’ Apps β†’ FlowFit β†’ Permissions
  • Enable "Body sensors" permission

No Heart Rate Data

  • Wear watch on wrist (sensor needs skin contact)
  • Tighten watch band
  • Clean sensor on back of watch

Data Sync Issues

Watch not sending data to phone

  • Check both devices are paired
  • Verify Galaxy Wearable app is running
  • Check network connectivity

Supabase sync failing

  • Verify secrets.dart configuration
  • Check internet connection
  • Review Supabase logs

πŸ“š Documentation

πŸ“– Complete Documentation Index - Full list of all documentation

πŸš€ Quick Links

πŸ› Troubleshooting

πŸ” Permissions

Watch App Permissions

  • BODY_SENSORS - Heart rate and health sensors
  • FOREGROUND_SERVICE - Background tracking
  • FOREGROUND_SERVICE_HEALTH - Health-specific services
  • WAKE_LOCK - Keep device awake during tracking
  • ACTIVITY_RECOGNITION - Activity detection

Phone App Permissions

  • INTERNET - Supabase sync
  • ACCESS_NETWORK_STATE - Network status
  • WAKE_LOCK - Background sync

πŸ› οΈ Tech Stack

  • Frontend: Flutter 3.10.0+
  • Language: Dart
  • Backend: Supabase (PostgreSQL)
  • Watch SDK: Samsung Health Sensor SDK 1.4.1
  • Wearable: Wear OS 3.0+
  • Communication: Wearable Data Layer API
  • State Management: Provider
  • Charts: fl_chart
  • Location: geolocator, google_maps_flutter
  • Sensors: sensors_plus, wear_plus

πŸ“ˆ Roadmap

  • Complete watch-to-phone data transfer implementation
  • Add workout heart rate zones
  • Implement HRV analysis and trends
  • Add resting heart rate calculation
  • Background heart rate monitoring
  • Heart rate alerts (too high/low)
  • Sleep quality scoring
  • Nutrition recommendations
  • Social features and challenges

🀝 Contributing

Contributions are welcome! Please read the contributing guidelines before submitting PRs.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Samsung Health Sensor SDK
  • Flutter team
  • Supabase team
  • VGV (Very Good Ventures) for Wear OS best practices

πŸ“ž Support

For issues and questions:

  1. Check the troubleshooting section above
  2. Review the documentation files
  3. Check logcat: adb logcat | grep -i health
  4. Open an issue on GitHub

πŸš€ Quick Commands

Build & Install

# Automated build and install on watch
scripts\build_and_install.bat

# Run on watch
scripts\run_watch.bat

# Run on phone
scripts\run_phone.bat

Manual Commands

# Watch (SM_R930 - Galaxy Watch)
flutter run -d adb-RFAX21TD0NA-FFYRNh._adb-tls-connect._tcp -t lib/main_wear.dart

# Phone (22101320G)
flutter run -d 6ece264d -t lib/main.dart

⚠️ Important: Always use -t lib/main_wear.dart for watch to get Wear OS UI, not phone UI!

Troubleshooting

# View logs
adb -s 6ece264d logcat | findstr "FlowFit"

# Check devices
adb devices

# Uninstall
adb -s 6ece264d uninstall com.example.flowfit

For detailed documentation, see the docs/ folder.

About

A comprehensive health and fitness tracking application for Wear OS (Galaxy Watch) with companion phone app support. Built with Flutter and integrated with Samsung Health Sensor SDK.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Dart 86.1%
  • HTML 7.0%
  • Kotlin 3.7%
  • C++ 1.3%
  • CMake 1.0%
  • PLpgSQL 0.3%
  • Other 0.6%