Skip to content

A comprehensive iOS habit tracking app with gamification, 35+ habit templates, 12-tier rating system (F-SSS), achievements, and smart reminders. Built with SwiftUI and GRDB for seamless habit formation and personal growth.

License

Notifications You must be signed in to change notification settings

banghuazhao/habit-diary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

HabitDiary ๐Ÿ“”

Swift iOS SwiftUI License

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.

๐Ÿ“ฑ Screenshots

HabitDiary Screenshot 1 HabitDiary Screenshot 2 HabitDiary Screenshot 3 HabitDiary Screenshot 4

Experience a clean, modern interface with intuitive habit tracking, comprehensive analytics, and engaging gamification elements designed to motivate long-term habit formation.

โœจ Features

๐ŸŽฏ Core Functionality

  • 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

๐Ÿ† Gamification & Achievements

  • 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

๐Ÿ“Š 12-Tier Rating System

  • 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

๐Ÿ—‚๏ธ Comprehensive Habit Library

  • 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

๐Ÿ”” Smart Reminder System

  • 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

๐ŸŽจ User Experience

  • 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

๐Ÿ’พ Data Management

  • 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

๐ŸŒ Localization & Accessibility

  • Multi-language Support: English and Simplified Chinese localization
  • Accessibility Features: VoiceOver support and accessibility labels
  • Responsive Design: Optimized for various iOS device sizes

๐Ÿ”ง Advanced Features

  • 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

๐Ÿ—๏ธ Architecture

Tech Stack

  • 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

Project Structure

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

๐Ÿš€ Getting Started

Prerequisites

  • Xcode 15.0 or later
  • iOS 17.0+ deployment target
  • macOS 14.0+ (for development)
  • Swift 5.9+

Installation

  1. Clone the repository

    git clone https://github.com/banghuazhao/habit-diary.git
    cd habit-diary
  2. Open in Xcode

    open HabitDiary.xcodeproj
  3. Configure Dependencies The project uses Swift Package Manager for dependencies:

    • GRDB for database management
    • Google Mobile Ads for monetization
    • Additional utility packages
  4. Build and Run

    • Select your target device or simulator
    • Press Cmd + R to build and run the app

Development Setup

Database Configuration

The app uses GRDB for local data storage. The database is automatically initialized with the following tables:

  • habits - Core habit definitions with frequency patterns
  • checkIns - Daily completion tracking with timestamps
  • reminders - Notification scheduling and management
  • achievements - Gamification progress tracking

Customization Options

  • 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

๐ŸŽฎ User Journey

Onboarding Experience

  1. Welcome: Introduction to HabitDiary's mission and benefits
  2. Features: Showcase of rating system, achievements, and capabilities
  3. Habit Selection: Choose from 35+ categorized habit templates
  4. Setup Complete: Personalized tips and guidance for getting started

Daily Workflow

  1. Morning Check: Open Today tab to see scheduled habits
  2. Track Progress: Tap habits to mark as complete with satisfying animations
  3. Build Streaks: Maintain consistency to unlock achievements
  4. Monitor Growth: Check Rating tab to see score progression

Long-term Engagement

  • 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

๐Ÿค Contributing

We welcome contributions to make HabitDiary even better! Here's how you can help:

Development Process

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes following our coding standards
  4. Test thoroughly on multiple devices and iOS versions
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request with detailed description

Code Style Guidelines

  • 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

Testing Requirements

  • 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

๐Ÿ“„ License

This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC 4.0).

What this means:

  • โœ… 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.

๐Ÿ†˜ Support & Community

  • Issues: GitHub Issues for bug reports and feature requests
  • Discussions: GitHub Discussions for general questions
  • Email: Contact through GitHub for direct communication

๐Ÿ—บ๏ธ Roadmap

Planned Features

  • 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

Long-term Vision

  • Integration with wearable devices for automatic tracking
  • Machine learning for optimal habit scheduling
  • Advanced data visualization and insights
  • Multi-platform support (macOS, watchOS)

๐Ÿ™ Acknowledgments

  • 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 ๐ŸŒŸ


Quick Start Guide

New to HabitDiary? Here's how to get the most out of your experience:

  1. Start Small: Choose 3-5 habits from our gallery to begin with
  2. Be Consistent: Focus on daily completion rather than perfection
  3. Track Progress: Check your Rating tab weekly to see improvement
  4. Celebrate Wins: Enjoy achievement notifications and share your success
  5. 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! ๐Ÿš€

About

A comprehensive iOS habit tracking app with gamification, 35+ habit templates, 12-tier rating system (F-SSS), achievements, and smart reminders. Built with SwiftUI and GRDB for seamless habit formation and personal growth.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages