Personal Product • Behavioral State Engines
IronWill
A high-accountability discipline engine and time economy application built with Flutter, Riverpod, and Dart, pairing an earned-reward point vault with strict "The Pit" failure-gate consequence state machines.
The Operational Friction: Why Standard Habit Trackers Fail
Conventional habit tracking and productivity apps rely heavily on superficial gamification: binary daily checklists, colorful badges, and fragile "streaks." When a user skips a workout, delays a project, or slips up on a routine, standard apps do little more than break the visual streak counter or present a passive guilt notification.
This design introduces a severe psychological failure mode known as the "what-the-hell effect": once a streak is broken, users experience a collapse of motivation and abandon the tracker altogether. Traditional apps have no concept of:
- Accountability Debt: If you take time off, what is the systematic cost?
- Earned Relaxation: Why should entertainment be free when daily obligations remain unfinished?
- Enforced Consequences: How do you prevent yourself from negotiating with your own commitments when energy drops?
I engineered IronWill to treat personal discipline as a closed economic loop: entertainment and comfort minutes are not free; they must be purchased using points earned through completed commitments, protected by an automated, inescapable Failure-Gate State Machine called The Pit.
The Time Economy: The Vault & Early-Use Debt
IronWill is structured around two opposing economic pillars: The Vault (rewards) and The Pit (consequences), managed through Riverpod state controllers (lib/src/features/accountability/):
- The Vault: Users earn points by completing daily "Must-Do" tasks. In The Vault, points can be exchanged for relaxation time (gaming, entertainment, leisure reading) according to custom exchange rates (e.g., 50 points = 30 minutes of gaming).
- Early-Use Discipline Debt: If a user chooses to consume comfort *before* completing their obligations, they can activate "Early Use." The system immediately converts the point cost into an active Discipline Debt.
- The 1:1 Debt Repayment Invariant: While debt exists, all future reward redemptions are locked. Every point subsequently earned from completed tasks is forcefully routed to amortize the debt balance before any points can enter the spendable vault.
"The Pit" Failure-Gate Redirect Engine
At midnight, a background task (flutter_background_service) executes the daily settlement routine. If a user failed to meet their daily quota, missed a mandatory Must-Do task, or ended the day with unpaid discipline debt, the app triggers a state transition into The Pit:
// lib/src/features/pit/pit_gate_controller.dart - Failure Gate Guard
class PitGateGuard extends AutoDisposeNotifier<PitState> {
@override
PitState build() {
final accountabilityState = ref.watch(accountabilityControllerProvider);
// Evaluate failure invariants at runtime
if (accountabilityState.hasUnresolvedPunishments ||
accountabilityState.isDailyQuotaFailed) {
return PitState.locked(
activePenalties: accountabilityState.activePenalties,
);
}
return const PitState.unlocked();
}
void acknowledgeAndAcceptConsequence(String penaltyId) {
state = state.copyWith(isAcknowledging: true);
ref.read(accountabilityControllerProvider.notifier)
.transitionPenaltyToAccepted(penaltyId);
}
}- Programmatic Routing Locks (
GoRouter): The application routes are wrapped with a global redirect guard. WhenPitState.isLockedis true, attempts to navigate toToday,The Vault, orStatsare intercepted and rerouted to/pit. - Consequence Execution: The user cannot interact with their normal schedule until they acknowledge and mark their custom consequences (e.g., physical exercise quotas, cold showers, or digital disconnect periods) as verified and executed.
- Escalation Protocol: To prevent recursive punishment stacking, unresolved consequences dynamically escalate in severity tiers (Minor $\to$ Moderate $\to$ Severe) rather than cluttering the database with duplicate penalties.
Dual Source-of-Truth Notion Cloud Sync
While IronWill operates 100% offline-first via local storage, power users require access to their accountability metrics on desktop computers and external productivity dashboards.
I engineered a custom Pull & Merge Notion API sync adapter (lib/src/features/sync/notion_adapter.dart):
- Deterministic Record Hashing: Each task, debt entry, and penalty generates a deterministic cryptographic hash based on its creation timestamp and invariant UUID.
- Two-Way Synchronization: The adapter queries the Notion Database REST API, comparing remote Notion page properties with local database records. If updates occur on both mobile and desktop while offline, the synchronization engine reconciles the states using vector clock timestamps, resolving conflicts without data loss or duplicate reward generation.
Monorepo Architecture & Hardware Integration
- Flutter Monorepo Structure (
melos): Structured across isolated Melos packages:packages/app_core(pure Dart business rules and state machines with zero UI dependencies),packages/app_ui(custom glassmorphic theme tokens, Phosphor icons, and typography primitives), andapps/ironwill(app scaffolding and navigation). - Native Android Widgets (
home_widget): Syncs real-time quota progress, active debt balances, and Must-Do checklists directly to the Android OS home screen launcher. - Analytical Visualization (
fl_chart): Renders animated discipline trends, debt recovery velocity, and life-area time distribution charts.
Production Outcomes
- Engineered Production Build: Published and maintained within the Flutter monorepo with automated Dart analysis and test gates (
dart analyze packages/app_core,flutter test). - Zero Cognitive Escape Hatches: Successfully deployed an uncompromising behavioral economics state machine that eliminates the passive "what-the-hell" abandonment cycle through mathematical debt and consequence gates.
- 100% Offline Autonomy: Instant sub-1ms state lookups and transitions with optional, conflict-free Notion cloud backups.
Key Achievements & Metrics
Architected a high-accountability time economy in Flutter & Dart using Riverpod for immutable state control.
Designed 'The Pit' failure-gate consequence engine, programmatically locking standard app navigation upon missed daily quotas.
Built 'The Vault' point economy allowing earned rewards while penalizing early comfort redemption with active discipline debt.
Engineered a dual source-of-truth sync adapter interfacing with the Notion REST API with pull-and-merge conflict resolution.