The 15-Second Constraint
Most mental-wellness apps lose users in week two for a surprisingly mundane reason: they treat a daily mood log like an onboarding questionnaire. If opening the app requires waiting on a splash screen, refreshing an auth token, and navigating three screens deep, the habit dies.
When I started building Feel Journal, I set a hard product and engineering budget: logging today’s mood, energy level, and an optional note must take under 15 seconds from cold start—and under 2 seconds from the Android home screen widget.
That single constraint dictated the entire data architecture. Network requests on the critical write path were off the table. The app had to be local-first from day one, with cloud sync treated as an optional background capability rather than a prerequisite.
Designing the Local-First Repository & Outbox Queue
In Feel Journal, the local database is the single source of truth for the UI. When a user taps a mood on the 10-point scale and adjusts their energy bar, the repository commits a deterministic record keyed by the local calendar date (`YYYY-MM-DD`) and stamps it with a monotonic `updatedAt` timestamp.
If the user has chosen to stay completely offline—which is the default—nothing else happens. If they have signed in with Firebase Auth for cross-device backup, the write also appends a lightweight mutation entry to a persistent outbox queue. A background worker flushes that queue whenever connectivity is available, using last-write-wins resolution per calendar day.
class MoodRepository {
MoodRepository(this._localStore, this._outboxQueue);
final LocalMoodStore _localStore;
final SyncOutboxQueue _outboxQueue;
/// Commits immediately to disk; never awaits network I/O.
Future<MoodEntry> logDailyMood({
required int score, // 1..10
required int energyLevel, // 1..5
String? note,
}) async {
final now = DateTime.now();
final entry = MoodEntry(
dayKey: DayKey.fromDate(now),
score: score,
energyLevel: energyLevel,
note: note?.trim(),
updatedAt: now.toUtc(),
);
await _localStore.upsert(entry);
unawaited(_outboxQueue.enqueueUpsert(entry));
return entry;
}
}Never gate a habit-forming write action behind an authentication screen or a network spinner. Let the user experience the value of the app for 14 days offline before ever asking them to sign in.
One-Tap Logging from the Android Home Widget
To push friction even lower, Feel Journal ships an Android Home Widget that lets you tap your current mood directly from the launcher without opening the full Flutter engine.
Under the hood, the native Android `AppWidgetProvider` writes the selected mood score into a shared preferences container and triggers a background broadcast. The next time the Flutter isolate wakes—or immediately via a background callback—the local store ingests any pending widget taps and recalculates the weekly trend line and streak counter.
Computing Streaks Without Dark Patterns
Because all entries live locally, weekly and monthly trend charts render instantaneously with zero skeleton loaders. We compute a 7-day rolling average alongside a mood distribution bar so users can spot patterns—like energy dips on Wednesdays—that are invisible in the moment.
Just as importantly, the streak counter is framed as gentle encouragement rather than punishment. Missing a day does not trigger guilt-tripping push notifications; when you return, your historical trend line is waiting right where you left it.