A simple Flutter app to track your daily mood, energy levels, and health insights. Works offline and syncs to the cloud when connected.
- Daily Mood Tracking - Log your mood throughout the day
- Energy Level Monitoring - Track your energy levels
- Health Insights - View trends and analytics
- Offline Support - Works without internet connection
- Cloud Sync - Automatically syncs when online
- PWA Ready - Install as a web app on any device
- Flutter SDK: 3.0 or higher
- Dart SDK: 3.0 or higher
- Platform: iOS, Android, Web, macOS, Windows, Linux
- Browser: Chrome (for PWA testing)
- Supabase Account: Free account at supabase.com
- Internet Connection: For initial setup and cloud sync (app works offline)
flutter pub getRequired Environment Variables:
Create a .env file in the project root with the following variables:
# Copy the example file
cp env.example .envEdit .env file with your credentials:
# Supabase Configuration (Required)
SUPABASE_URL=https://your-project-id.supabase.co
SUPABASE_ANON_KEY=your-anon-key-here
# App Configuration (Optional)
APP_NAME=Health Tracker
APP_VERSION=1.0.0Where to find Supabase credentials:
- Go to supabase.com and create a free account
- Create a new project
- Go to Project Settings โ API
- Copy the "Project URL" and "anon public" key
- Open Supabase Dashboard โ SQL Editor
- Copy and paste the contents of
supabase_quick_setup.sql - Click "Run"
# Mobile/Desktop
flutter run
# Web (PWA)
flutter run -d chrome --web-port 8080The app intelligently handles network connectivity:
- Entries sync automatically to Supabase
- Real-time data backup
- Full functionality available
- All entries saved locally
- App works completely offline
- Data syncs when connection returns
- Checks internet connection before syncing
- Shows clear error messages for network issues
- Prevents hanging operations when offline
Your Health Tracker app can run as a Progressive Web App in any browser and be installed like a native app!
flutter run -d chrome --web-port 8080- Opens in Chrome automatically
- Hot reload enabled for development
- Access at:
http://localhost:8080
lib/
โโโ main.dart # App entry point
โโโ models/health_entry.dart # Data model
โโโ services/
โ โโโ health_service.dart # Data management
โ โโโ network_service.dart # Network connectivity
โโโ providers/health_entries_provider.dart # State management
โโโ pages/
โ โโโ home_page.dart # Main entries page
โ โโโ insights_page.dart # Analytics page
โโโ widgets/ # Reusable UI components
# Run all tests
flutter test
# Run specific test suites
flutter test test/widget/mood_selector_test.dart
flutter test test/widget/energy_level_selector_test.dart
flutter test test/providers/health_entries_provider_test.dart
# Run with coverage
flutter test --coverageTest 1: Online to Offline Transition
- Setup: Start app with internet connection
- Action: Disable WiFi/mobile data
- Expected:
- Orange banner appears: "No internet connection. Entries are saved locally and will sync when online."
- App continues to work normally
- New entries are saved locally
- Action: Re-enable internet connection
- Expected:
- Banner disappears automatically
- Local entries sync to Supabase
Test 2: Offline Entry Creation
- Setup: Disconnect from internet
- Action: Add a new health entry
- Expected:
- Entry saves successfully
- Success dialog shows
- Entry appears in list immediately
- Entry marked as unsynced (if visible in UI)
Test 3: Sync After Coming Online
- Setup: Create entries while offline
- Action: Reconnect to internet
- Action: Tap sync button (if available) or restart app
- Expected:
- Entries sync to Supabase
- Success message appears
- All entries marked as synced
Test 4: Add Health Entry
- Action: Tap the "+" button
- Expected: Bottom sheet opens with form
- Action: Fill in mood, energy level, optional note
- Action: Tap "Save Entry"
- Expected:
- Success dialog appears
- Entry appears in list
- Form closes automatically
Test 5: Duplicate Entry Prevention
- Setup: Add an entry for "Morning" today
- Action: Try to add another entry for "Morning" today
- Expected:
- Error dialog: "You can only add one entry per time of day"
- Form remains open
- No duplicate entry created
Test 6: Daily Entry Limit
- Setup: Add entries for Morning, Afternoon, Evening
- Action: Try to add a 4th entry
- Expected:
- Error dialog: "You can only add 3 entries per day"
- Form closes
- No 4th entry created
Test 7: Bidirectional Sync
- Setup: Create entries on Device A, sync to Supabase
- Action: Open app on Device B (or clear local data)
- Expected:
- App loads entries from Supabase
- All entries appear correctly
- Timestamps preserved
Test 8: Conflict Resolution
- Setup: Create same entry on two devices while offline
- Action: Sync both devices when online
- Expected:
- Most recent entry wins (based on timestamp)
- No duplicate entries
- Sync completes successfully
Test 9: Startup Sync
- Setup: Have entries in Supabase that aren't local
- Action: Start the app
- Expected:
- App automatically syncs on startup
- Remote entries appear in local list
- No user interaction required
Test 10: Mood Distribution
- Setup: Add entries with different moods
- Action: Navigate to Insights tab
- Expected:
- Mood distribution chart shows correct counts
- All moods represented accurately
Test 11: Weekly Trend
- Setup: Add entries over multiple days
- Action: View Insights page
- Expected:
- Weekly trend chart shows last 7 days
- Average mood calculated correctly
- Days without entries show neutral mood
Test 14: Network Error Recovery
- Setup: Start sync operation
- Action: Disconnect internet mid-sync
- Expected:
- Clear error message appears
- App doesn't hang or crash
- User can retry when online
Test 15: Invalid Data Handling
- Action: Try to submit form with missing required fields
- Expected:
- Form validation prevents submission
- Clear error messages guide user
- No crashes or unexpected behavior
- Entry Creation: Smooth form interaction, immediate local save, cloud sync
- Offline Mode: Full functionality, clear status indication, automatic sync when online
- Data Sync: Bidirectional sync, conflict resolution, startup sync
- PWA: Native app experience, offline support, proper installation
- Network Issues: Graceful degradation, clear error messages, retry capability
- Validation Errors: Form validation, user guidance, no data loss
- Sync Conflicts: Automatic resolution, data integrity maintained
- App Startup: < 2 seconds to load
- Entry Creation: < 1 second to save locally
- Sync Operations: < 5 seconds for typical data set
- UI Responsiveness: Smooth animations, no lag
Test Results: Run flutter test to see current status
"No internet connection" error:
- Check your network connection
- The app works offline - entries are saved locally
- Sync will happen automatically when online
"Could not find table" error:
- Make sure you ran the Supabase setup SQL script
- Check that the table exists in Supabase Dashboard
Environment/Setup Issues:
- "Environment variables not configured": Make sure
.envfile exists and has correct Supabase credentials - "Could not find .env file": Run
cp env.example .envand edit with your credentials - "Invalid Supabase URL": Check that your URL format is
https://your-project-id.supabase.co
Sync failures:
- Verify your Supabase URL and API key in
.env - Check internet connection
- Look at Supabase logs for detailed errors
- Check the console for error messages
- Verify your
.envfile has correct Supabase credentials - Ensure you've run the database setup script
- Check Supabase Dashboard logs
Total Time: 8 hours
- Initial setup and basic functionality: 4 hours
- UI/UX styling and polish: 2 hours
- Network connectivity and offline support: 1 hour
- PWA setup and testing: 1 hour
๐จ User Experience
- Clean, intuitive interface with smooth animations
- Responsive design that works on all screen sizes
- Clear visual feedback with loading states and error messages
- Offline-first approach ensures app always works
๐๏ธ Architecture
- Simple, maintainable code structure without over-engineering
- Clean separation of concerns (UI, business logic, data)
- Robust error handling with user-friendly messages
- Efficient local storage with smart cloud sync
๐ฑ Technical Features
- Progressive Web App (PWA) support for cross-platform deployment
- Network connectivity awareness prevents hanging operations
- Local-first data storage with automatic cloud backup
- Comprehensive testing coverage for core components
๐ค User Management
- Add proper user authentication (email/password, Google, Apple)
- Implement user profiles with personalized settings
- Add multi-user support with data isolation
- User-specific mood history and insights
๐ Enhanced Features
- Data export/import functionality (CSV, JSON)
- Advanced analytics with trends and patterns
- Mood reminders and notifications
- Social features (share insights, family tracking)
๐ง Technical Improvements
- Implement proper data validation and sanitization
- Add comprehensive integration tests
- Optimize performance for large datasets
- Add accessibility features (screen reader support)
- Implement proper conflict resolution for sync
๐ฏ User Experience
- Add onboarding flow for new users
- Implement dark mode theme
- Add haptic feedback for mobile
- Create custom mood/energy level options
State Management: Provider Pattern
- Why: Simple, well-documented, and perfect for this app size
- Benefits: Easy to understand, good performance, built-in Flutter support
- Alternative: Could use Riverpod or Bloc for larger apps
Storage: SharedPreferences + Supabase
- Local Storage: SharedPreferences for fast, reliable local data
- Cloud Storage: Supabase for real-time sync and backup
- Why This Combo: Offline-first approach with cloud backup
- Benefits: Works offline, fast local access, automatic sync
Network: Connectivity Plus
- Why: Prevents hanging operations when offline
- Benefits: Better user experience, clear error messages
- Implementation: Smart sync that checks connectivity first
Quick Start:
# 1. Install dependencies
flutter pub get
# 2. Set up environment
cp env.example .env
# Edit .env with your Supabase credentials
# 3. Set up database
# Run supabase_quick_setup.sql in Supabase Dashboard
# 4. Run the app
flutter run # Mobile/Desktop
flutter run -d chrome # Web/PWAPWA Installation:
- Run
flutter run -d chrome --web-port 8080 - Open Chrome and go to
http://localhost:8080 - Click install button in address bar
- App installs like a native app! \