A Flutter habit-tracking app focused on micro-habits (2-5 minutes) with gamification, AI suggestions, and reliable background notifications.
- Habit Management: Create, track, and manage daily micro-habits
- Smart Notifications: Reliable WorkManager-based reminders (15-min intervals)
- Offline-First: Full offline support with Hive local storage
- Cloud Sync: Firebase Firestore synchronization when online
- AI-Powered: Personalized habit suggestions via OpenRouter API
- 🔥 Streak Tracking: Build momentum with daily consecutive streaks
- 🎯 Achievement System: Unlock 15+ badges across 5 categories (Streak Master, Consistency Champion, Weekly Warrior, Milestone Master, Perfect Week)
- 📊 Progress Dashboard: Interactive charts with weekly trends and comparative statistics
- ⭐ Level System: Progress through 10 levels from "Beginner" to "Legend" with experience points
- 🏆 Badge Rarity: 5 rarity tiers (Common, Uncommon, Rare, Epic, Legendary) with visual distinctions
- 🎉 Celebrations: Confetti animations and notifications on habit completion and achievement unlocks
- 📈 Statistics: Comprehensive tracking of current streak, best streak, total completions, and weekly progress
- Multi-Process Notifications: WorkManager + Firestore for reliable background tasks
- Firebase Auth: Email/password and Google Sign-In
- AdMob Integration: Banner ads for monetization
| Category | Technology |
|---|---|
| Framework | Flutter 3.19+ / Dart 3.3+ |
| State Management | Riverpod (Code Generation) |
| Navigation | GoRouter |
| Local Storage | Hive |
| Backend | Firebase (Auth, Firestore) |
| Notifications | WorkManager + flutter_local_notifications |
| AI | OpenRouter API (Gemini, GPT-4, etc.) |
| Ads | Google Mobile Ads (AdMob) |
- Flutter SDK 3.19+
- Firebase Project (Create one)
- OpenRouter API Key (Get one)
- Android Studio / Xcode (for mobile development)
-
Clone the repository:
git clone https://github.com/yourusername/microwins.git cd microwins -
Install dependencies:
flutter pub get
-
Firebase Setup:
a. Create a Firebase project at console.firebase.google.com
b. Add Android/iOS apps to your Firebase project
c. Download configuration files:
- Android:
google-services.json→android/app/ - iOS:
GoogleService-Info.plist→ios/Runner/
d. Enable Authentication methods in Firebase Console:
- Email/Password
- Google Sign-In
e. Create Firestore database (start in test mode)
- Android:
-
Environment Setup:
Create a
.envfile in the root directory:OPENROUTER_API_KEY=your_api_key_here
-
Code Generation:
Run build_runner to generate Riverpod and Hive code:
dart run build_runner build --delete-conflicting-outputs
-
Run the App:
# Android flutter run # iOS flutter run -d ios # Specific device flutter run -d <device-id>
lib/
├── core/ # Shared utilities
│ ├── notifications/ # WorkManager + Firestore notifications
│ ├── sync/ # Firebase sync manager
│ ├── local/ # Hive setup and configuration
│ └── theme/ # App theming
├── features/
│ ├── auth/ # Authentication (Firebase)
│ ├── habits/ # Habit CRUD operations
│ ├── gamification/ # Achievements, levels, and progress tracking
│ │ ├── domain/ # Services (AchievementService, GamificationService)
│ │ ├── data/ # Repository and models (HabitCompletionModel)
│ │ └── presentation/ # UI (ProgressScreen, BadgesScreen)
│ ├── ai_suggestions/ # OpenRouter AI integration
│ └── profile/ # User settings
└── firebase_options.dart # Firebase configuration
Problem Solved: Android 12+ blocks recurring exact alarms, making traditional notification scheduling unreliable.
Solution: WorkManager + Firestore multi-process architecture
Main App Process WorkManager Process
================ ===================
User creates habit (every 15 minutes)
↓ ↓
Save to Firestore ←─────→ Read from Firestore
↓ ↓
Save userId to Read userId from
SharedPreferences SharedPreferences
↓
Check for due habits
↓
Show notifications
Key Features:
- ✅ Works across app restarts
- ✅ Survives phone reboots
- ✅ Multi-process safe (Firestore + SharedPreferences)
- ✅ Notifications arrive within 0-15 minutes of scheduled time
Trade-off: Notifications may arrive up to 15 minutes late (Android WorkManager limitation)
MicroWins features a comprehensive gamification system designed to maximize user engagement and habit consistency through psychological reinforcement mechanics.
| Category | Icon | Focus | Badges |
|---|---|---|---|
| Streak Master | 🔥 | Daily consecutive completions | 4 badges (3, 7, 30, 100 days) |
| Consistency Champion | 📅 | Monthly completion frequency | 3 badges (7, 20, 28+ days/month) |
| Weekly Warrior | 📈 | Weekly volume | 3 badges (5, 10, 20 habits/week) |
| Milestone Master | 🏆 | Cumulative achievements | 4 badges (10, 50, 100, 500 total) |
| Perfect Week | ⭐ | Weekly perfection | 2 badges (3+, 5+ habits) |
- 10 Levels: Principiante → Novato → Aprendiz → Practicante → Dedicado → Comprometido → Experto → Maestro → Gran Maestro → Leyenda
- EXP Formula: Each level requires
100 * leveladditional EXP - Bonuses: Streak bonuses (+5 to +20 EXP), first of day (+5 EXP), perfect week (+15 EXP)
| Scenario | Behavior |
|---|---|
| App open | Notification arrives 0-15 min after scheduled time |
| App closed | WorkManager continues checking every 15 min |
| Phone restart | WorkManager resumes automatically |
| No internet | Works offline (reads from Firestore cache) |
Why 15 minutes?
- Android restricts background tasks to save battery
- WorkManager is the only reliable solution on Android 12+
- Same approach used by Todoist, Microsoft To-Do, Google Keep
flutter testflutter test integration_test/- Sign in to the app (saves userId to SharedPreferences)
- Create a habit with a reminder time 5-10 minutes from now
- Close the app completely
- Wait for the notification (arrives within 15 min)
View logs:
flutter logs --device-id=<device-id> | grep -i "workmanager\|flutter"Expected output:
🔔 WorkManager: Checking for due notifications...
📦 Found 1 habits in Firestore
✅ Showed notification for: [habit name]
android/app/google-services.json- Android configios/Runner/GoogleService-Info.plist- iOS configlib/firebase_options.dart- Generated by FlutterFire CLI
OPENROUTER_API_KEY- AI suggestions API key
Required permissions in AndroidManifest.xml:
INTERNET- Network accessPOST_NOTIFICATIONS- Show notifications (Android 13+)RECEIVE_BOOT_COMPLETED- Restart WorkManager after rebootWAKE_LOCK- Keep WorkManager running
flutter_riverpod- State managementriverpod_annotation- Code generationgo_router- Navigationhive_flutter- Local storage
firebase_core- Firebase initializationfirebase_auth- Authenticationcloud_firestore- Cloud databasegoogle_sign_in- Google OAuth
flutter_local_notifications- Show notificationsworkmanager- Background task schedulingshared_preferences- Multi-process data sharingpermission_handler- Runtime permissions
http- OpenRouter API callsgoogle_mobile_ads- AdMob integration
-
Build release APK:
flutter build apk --release
-
Build App Bundle (for Play Store):
flutter build appbundle --release
-
Install on device:
flutter install --device-id=<device-id>
-
Build for iOS:
flutter build ios --release
-
Archive in Xcode for App Store submission
Issue: "Found 0 habits in Firestore" in logs
Solution:
- Sign out and sign in again (saves userId to SharedPreferences)
- Verify habit has a
reminderTimeset - Check Firestore rules allow read access
Issue: Notifications delayed more than 15 minutes
Solution:
- Check battery optimization settings (Settings → Apps → MicroWins → Battery → Unrestricted)
- Verify WorkManager is running:
adb shell dumpsys jobscheduler | grep microwins
Issue: "No user logged in" in WorkManager logs
Solution:
- Ensure user is signed in before creating habits
- Check
SharedPreferenceshascurrent_user_idkey
MIT License - see LICENSE file for details
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Follow Conventional Commits
- Submit a pull request
For issues or questions:
- Open an issue on GitHub
- Check existing documentation in
/docs
Built with ❤️ using Flutter