HabitLoop is a modern, privacy-focused iOS habit tracking application engineered with SwiftUI, Core Data, WidgetKit, and modern Swift concurrency. Designed with Apple Human Interface Guidelines (HIG) at its core, HabitLoop features algorithmic pattern detection, weekly AI reflections, interactive widgets, and instant offline synchronization.
Today Dashboard |
Add/Edit Habit |
Detail & Heatmap |
Library (List/Grid) |
Pattern Insights |
Home Screen Widgets |
-
Daily Habit Dashboard: Real-time completion progress count (
3/5), animated progress rings, streak counters (🔥), and instant haptic toggle interactions. - 12-Week Activity Heatmap: Visual 84-day completion grid, monthly completion percentage rates, and total completion stats without third-party chart dependencies.
- Algorithmic Pattern Insights:
-
Weekday vs. Weekend Gap: Statistical analysis surfacing consistency discrepancies (
$\ge 30%$ gap). - Best Time of Day: Categorizes habit completions into Morning, Afternoon, and Evening peak performance buckets.
- Streak Risk Alerts: Proactive warnings when an active habit streak is at risk based on historical completion time windows.
-
Weekly AI Reflection: On-device reflection engine leveraging FoundationModels (iOS 18.1+) with deterministic fallback summaries and Core Data caching (
HabitInsightCacheEntity). - Interactive Home Screen Widgets:
-
Small Widget (
systemSmall): Circular progress ring & completion fraction. -
Medium Widget (
systemMedium): Interactive list allowing users to mark habits complete directly from their Home Screen via AppIntents (ToggleHabitIntent). - Library Management: Active and Archived segmented filtering, live title searching, drag-to-reorder custom sorting, and List/Grid layout modes.
- Preferences & Data Portability: Master notification controls, active reminder list navigation, system/light/dark appearance switching, and CSV & JSON export using SwiftUI ShareLink.
- State Management: Built with the Observation framework (
@Observable) introduced in iOS 17, eliminating@Publishedoverhead and optimizing UI re-renders. - Repository Pattern: Strict decoupling of Core Data managed object entities (
HabitEntity,HabitCompletionEntity) from pure domain value types (Habit,HabitCompletion). - Shared Persistent Container: Core Data persistent store configured for App Group URL (
group.com.ishouryasonu.habitloop), enabling real-time data sharing between the main app process and WidgetKit extensions. - AppIntents Integration:
ToggleHabitIntentallows background Core Data mutation and triggers immediate Widget timeline refreshes (WidgetCenter.shared.reloadAllTimelines()). - Zero External Dependencies: Built 100% natively using Apple frameworks (SwiftUI, CoreData, WidgetKit, UserNotifications, AppIntents, Foundation).
- Accessibility & HIG Polish: Includes Dynamic Type scaling, minimum 44pt touch target areas,
UIImpactFeedbackGenerator/UINotificationFeedbackGeneratorhaptics, and complete VoiceOver labels & hints.
The repository includes a comprehensive unit test suite written with XCTest:
HabitRepositoryTests: Core Data CRUD operations, completion toggling, date interval queries, and cascade deletions using in-memory store configurations.TodayViewModelTests: Daily completion counts, fraction progress calculations, and streak evaluations.AddEditHabitViewModelTests: Input validation, creation/edit prepopulation modes, and frequency mapping.HabitDetailViewModelTests: 12-week (84-day) heatmap date calculations, current & longest streak math.LibraryViewModelTests: Search filtering, active vs. archived segmentation, and custom drag-and-drop reordering (sortOrder).PatternInsightServiceTests: Deterministic date tests for weekday vs. weekend gap thresholds, peak time-of-day bucketing, and streak risk triggers.ReflectionServiceTests: Weekly reflection generation and fallback logic.NotificationServiceTests: Permissions & reminder cancellation logic.WidgetTests:HabitEntryprogress calculations andToggleHabitIntentexecution.





