A comprehensive iOS habit tracking app built with SwiftUI and GRDB, designed to help users build and maintain habits through gamification, achievements, and a sophisticated rating system. Transform your life one habit at a time with intelligent tracking, personalized reminders, and motivational features.
Experience a clean, modern interface with intuitive habit tracking, comprehensive analytics, and engaging gamification elements designed to motivate long-term habit formation.
- Comprehensive Habit Tracking: Create, edit, and track habits with flexible frequency patterns
- 4 Main Sections: Today (daily tracking), Habits (management), Rating (progress), Me (profile/settings)
- Flexible Scheduling: Fixed days in week/month, N days per period, and custom patterns
- Visual Progress Tracking: Calendar views, streak counters, and completion analytics
- 15+ Achievement Types: Streak milestones, consistency rewards, perfect periods, and milestone celebrations
- Real-time Notifications: Achievement popup celebrations with visual animations
- Progressive Unlocking: Earn achievements based on streaks, total check-ins, and consistency patterns
- Social Sharing: Share your achievements and progress with friends
- Progression Levels: Advance from Beginner (F) to Legend (SSS) based on overall performance
- Multi-Dimensional Scoring:
- Active habits (max 300 points)
- Achievements unlocked (max ~150+ points)
- Total check-ins (max 200 points)
- Longest streak (max 250 points)
- Detailed Analytics: Score breakdowns with explanations and improvement suggestions
- Visual Progress: Charts and progress bars showing rating advancement
- 35+ Pre-built Habits across 8 major categories:
- Health & Fitness: Walking, workouts, yoga, swimming, running, stretching
- Nutrition & Hydration: Water intake, fruits, vegetables, healthy cooking
- Sleep & Rest: Sleep schedule, screen limits, bedtime routines
- Mental Health & Mindfulness: Meditation, gratitude, breathing exercises
- Learning & Growth: Reading, language learning, skill practice
- Productivity & Organization: Planning, workspace management, reviews
- Social & Relationships: Family calls, social activities, kindness acts
- Self-Care & Environment: Skincare, decluttering, outdoor time
- Creative & Hobbies: Creative activities, music, photography
- Personalized Notifications: Custom reminder times and messages for each habit
- Habit-Specific Alerts: Link reminders directly to individual habits
- Non-intrusive Design: Thoughtful notification timing to avoid overwhelm
- Easy Management: Simple setup and modification of notification preferences
- Modern SwiftUI Interface: Clean, intuitive design following iOS design guidelines
- Dark Mode Support: Automatic adaptation to system appearance preferences
- Custom Theming: Multiple color themes and personalization options
- Haptic Feedback & Sound Effects: Enhanced interaction feedback
- Smooth Animations: Polished transitions and micro-interactions
- GRDB Database: Robust local data storage with SQLite backend
- Calendar Integration: Monthly and yearly habit tracking visualizations
- Streak Calculation: Intelligent streak tracking with flexible rules
- Data Persistence: Reliable local storage with efficient querying
- Multi-language Support: English and Simplified Chinese localization
- Accessibility Features: VoiceOver support and accessibility labels
- Responsive Design: Optimized for various iOS device sizes
- Habit Archiving: Archive habits without losing historical data
- Icon Customization: Extensive emoji icon library with color coding
- Filtering & Sorting: Multiple options to organize habit views
- Onboarding Experience: 4-step guided setup with feature introduction
- Premium Features: In-app purchases with ad-free experience
- SwiftUI 5.0: Modern declarative UI framework
- GRDB: SQLite database with Swift integration and reactive queries
- Observation Framework: Reactive data binding and state management
- SwiftUINavigation: Type-safe navigation handling
- Google Mobile Ads: Monetization with respectful ad placement
- UserNotifications: Local notification scheduling and management
HabitDiary/
โโโ App/
โ โโโ HabitDiaryApp.swift # App entry point with dependency setup
โโโ Components/
โ โโโ Common/ # Reusable UI components
โ โ โโโ HabitCardView.swift
โ โ โโโ HabitItemView.swift
โ โ โโโ EmptyStateView.swift
โ โ โโโ StyleGuide.swift
โ โโโ Today/ # Daily habit tracking interface
โ โ โโโ TodayView.swift
โ โ โโโ TodayViewModel.swift
โ โโโ Habits/ # Habit management and gallery
โ โ โโโ HabitsList.swift
โ โ โโโ HabitForm.swift
โ โ โโโ HabitDetail.swift
โ โ โโโ HabitsGallery.swift
โ โโโ Rating/ # Progress scoring and analytics
โ โ โโโ RatingView.swift
โ โ โโโ RatingViewModel.swift
โ โ โโโ ScoreDetailView.swift
โ โโโ Me/ # User profile and settings
โ โ โโโ MeFeature.swift
โ โ โโโ SettingView.swift
โ โ โโโ UserStatsView.swift
โ โ โโโ ThemeColorView.swift
โ โโโ Achievements/ # Gamification system
โ โ โโโ AchievementsView.swift
โ โ โโโ AchievementPopupView.swift
โ โโโ Reminders/ # Notification management
โ โ โโโ RemindersView.swift
โ โ โโโ ReminderForm.swift
โ โ โโโ ReminderRow.swift
โ โโโ Onboarding/ # User introduction flow
โ โโโ OnboardingView.swift
โโโ Model/ # Core data models
โ โโโ Habit.swift # Main habit entity with frequency patterns
โ โโโ CheckIn.swift # Habit completion tracking
โ โโโ Achievement.swift # Gamification achievements
โ โโโ LongevityRating.swift # 12-tier rating system
โ โโโ Reminder.swift # Notification scheduling
โ โโโ TodayHabit.swift # Daily habit view model
โโโ Service/ # Business logic and data services
โ โโโ HabitsDataStore.swift # Pre-built habit templates
โ โโโ AchievementService.swift # Achievement logic and notifications
โ โโโ NotificationService.swift # Reminder scheduling and management
โ โโโ RatingService.swift # Score calculation and rating logic
โ โโโ PurchaseManager.swift # In-app purchase handling
โโโ Utilities/ # Helper functions and extensions
โ โโโ Constants.swift
โ โโโ Schema.swift # Database schema and migrations
โ โโโ Extension/
โ โ โโโ Color+Extensions.swift
โ โ โโโ Date+Extension.swift
โ โโโ SoundPlayer.swift # Audio feedback system
โโโ Modules/
โโโ MoreApps/ # Developer's other applications showcase
- Xcode 15.0 or later
- iOS 17.0+ deployment target
- macOS 14.0+ (for development)
- Swift 5.9+
-
Clone the repository
git clone https://github.com/banghuazhao/habit-diary.git cd habit-diary
-
Open in Xcode
open HabitDiary.xcodeproj
-
Configure Dependencies The project uses Swift Package Manager for dependencies:
- GRDB for database management
- Google Mobile Ads for monetization
- Additional utility packages
-
Build and Run
- Select your target device or simulator
- Press
Cmd + R
to build and run the app
The app uses GRDB for local data storage. The database is automatically initialized with the following tables:
habits
- Core habit definitions with frequency patternscheckIns
- Daily completion tracking with timestampsreminders
- Notification scheduling and managementachievements
- Gamification progress tracking
- Habit Categories: Extend the
HabitsDataStore
to add new pre-built habits - Achievement Types: Modify
AchievementDefinitions
to create new achievements - Rating Tiers: Adjust the 12-tier system in
LongevityRating.swift
- UI Themes: Customize colors and styling through the theme manager
- Welcome: Introduction to HabitDiary's mission and benefits
- Features: Showcase of rating system, achievements, and capabilities
- Habit Selection: Choose from 35+ categorized habit templates
- Setup Complete: Personalized tips and guidance for getting started
- Morning Check: Open Today tab to see scheduled habits
- Track Progress: Tap habits to mark as complete with satisfying animations
- Build Streaks: Maintain consistency to unlock achievements
- Monitor Growth: Check Rating tab to see score progression
- Achievement Unlocking: Celebrate milestones with popup notifications
- Rating Advancement: Progress from Beginner (F) to Legend (SSS)
- Habit Evolution: Add new habits and archive completed ones
- Data Insights: Review historical data and identify patterns
We welcome contributions to make HabitDiary even better! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Make your changes following our coding standards
- Test thoroughly on multiple devices and iOS versions
- Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request with detailed description
- Follow Swift API Design Guidelines
- Use meaningful variable and function names
- Document complex logic with comments
- Ensure all code compiles without warnings
- Write unit tests for new functionality where appropriate
- Test on both iPhone and iPad simulators
- Verify functionality across iOS 17+ versions
- Test edge cases and error scenarios
- Validate accessibility features
- Check database migrations and data integrity
This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC 4.0).
- โ Share: Copy and redistribute the material in any medium or format
- โ Adapt: Remix, transform, and build upon the material
- โ Attribution: Give appropriate credit and indicate if changes were made
- โ NonCommercial: You may not use the material for commercial purposes
For commercial use, please contact the author for licensing arrangements.
- Issues: GitHub Issues for bug reports and feature requests
- Discussions: GitHub Discussions for general questions
- Email: Contact through GitHub for direct communication
- HealthKit Integration: Sync with Apple Health for comprehensive wellness tracking
- Apple Watch App: Quick habit check-ins from your wrist
- Widget Support: iOS home screen widgets for at-a-glance progress
- Data Export: CSV/JSON export for data portability
- Advanced Analytics: Detailed insights and correlation analysis
- Community Features: Share progress and compete with friends
- AI Recommendations: Personalized habit suggestions based on user patterns
- iPad Optimization: Enhanced interface for larger screens
- Integration with wearable devices for automatic tracking
- Machine learning for optimal habit scheduling
- Advanced data visualization and insights
- Multi-platform support (macOS, watchOS)
- SwiftUI Community: For excellent resources and best practices
- GRDB: For providing a robust SQLite wrapper for Swift
- Design Inspiration: From leading habit tracking and wellness applications
- Scientific Research: Habit formation studies that inform our approach
- Beta Testers: Community members who provided valuable feedback
Built with โค๏ธ by Banghua Zhao
Transforming lives through the power of consistent habits ๐
New to HabitDiary? Here's how to get the most out of your experience:
- Start Small: Choose 3-5 habits from our gallery to begin with
- Be Consistent: Focus on daily completion rather than perfection
- Track Progress: Check your Rating tab weekly to see improvement
- Celebrate Wins: Enjoy achievement notifications and share your success
- Evolve Gradually: Add new habits as existing ones become automatic
Remember: Building habits is a journey, not a destination. HabitDiary is here to support you every step of the way! ๐