DEV Community

Cover image for 8 Hardening Sprints Later: How FinLedger Went From Working to Bulletproof
DEVANSHU PATIL
DEVANSHU PATIL

Posted on

8 Hardening Sprints Later: How FinLedger Went From Working to Bulletproof

8 Hardening Sprints Later: How FinLedger Went From Working to Bulletproof

In the lifecycle of every growing software project, there comes a critical crossroads.

You have shipped feature after feature: multiple accounts, SMS transaction parsing, credit card reconciliation, debt tracking, and spending reports. The app works, users are testing it, and your backlog is full of exciting new ideas: stock portfolio tracking, crypto sync, and multi-currency exchange.

Then, you conduct a formal, rigorous architectural audit (docs/AUDIT.md).

And the audit hits you like a bucket of ice water:

  • Five core database tables lack indexes, causing sequential table scans during searches.
  • Four separate modules calculate account balances using slightly different posting rules.
  • Certain ViewModel observers execute JSON parsing and entity mapping directly on the main Android UI thread.
  • If a user imports a CSV file with an error on row 412, the database is left in a corrupted, half-imported state.

At that moment, you face a choice: Keep rushing out new features, or freeze feature development to fix your foundations.

In FinLedger, we chose the disciplined path: we paused all new feature development and executed Eight Structured Hardening Sprints (H1 through H8) (docs/HARDENING_SPRINTS.md).

Here is how eight weeks of systematic architectural hardening transformed FinLedger from a fragile prototype into a production-grade personal financial ledger.

The Two-Track Engineering Model

To maintain ruthless focus, we separated our engineering roadmap into two distinct tracks:

  1. Feature Track (Sprint N): User-facing capabilities (Sprints 0 through 10).
  2. Hardening Track (Sprint HN): Stability, performance, accounting correctness, and security.
flowchart TD
    subgraph HardeningGating["The Hardening Gate Architecture"]
        direction TB
        subgraph P0["P0: Must Fix Before Any Release"]
            H1["H1: Baseline & Safety Net
            Replace guesses with real measurements"] --> H2["H2: Database Integrity & Atomicity
            Indexes, withTransaction, Rollbacks"]
            H2 --> H3["H3: Posting Parity Truth
            Unify four balance calculators into pure Kotlin"]
            H3 --> H4["H4: Correct Numbers & Deduplication
            TASK-H4.4 10-minute collision windows"]
            H4 --> H5["H5: Backup & Restore Integrity
            Cryptographic verification of exported vaults"]
        end

        P0 --> Gate{"THE RELEASE GATE:
        All P0 Hardening Sprints Complete?"}

        Gate -->|NO: Hard Freeze| Block["Sprint 11 Feature Work BLOCKED"]
        Gate -->|YES: Gate Unlocked| P2P3["P2 / P3 Polish Track:
        H6: Main-Thread Offload & Flow Sharing
        H7: UI Design System & WCAG Contrast
        H8: God Screen Decomposition & PBKDF2"]

        P2P3 --> Ship["Ready for Production Release"]
    end

We established an uncompromising rule: The Hardening Gate.

No new features from Sprint 11 could be touched until Sprints H1 through H5 were complete and verified by automated regression tests. Building new features on top of known-wrong posting rules or unindexed tables is the definition of accumulating toxic technical debt.

The Eight Sprints at a Glance

Sprint H1: Baseline & Safety Net

Before fixing anything, you must measure everything. H1 focused on empirical reality: establishing release build sizing, capturing baseline startup latency, measuring frame drop rates on physical hardware, and expanding the unit test suite to over 1,200 assertions.

Sprint H2: Database Integrity & Atomicity

Eliminating partial database writes. Every multi-row operation (transaction insertion, account deletion, debt reconciliation) was wrapped inside Room's atomic withTransaction. Created missing database indexes across dateTimestamp, accountId, and categoryId.

Sprint H3: Posting Truth & Financial Parity

The most critical engineering sprint in FinLedger's history. We eliminated four contradictory balance calculation engines, unifying them into a single, authoritative pure Kotlin engine (LedgerEngine.kt). Ensured that replaying 10,000 transactions from day zero produces the exact same balance as incremental daily updates.

Sprint H4: Correct Numbers & Deduplication Windows

Diagnosed and eliminated the silent data loss bug in SMS deduplication (TASK-H4.4). Replaced the flawed query with our four-factor matching engine and 10-minute collision window.

Sprint H5: Backup & Restore Integrity

Hardened our export/import pipeline. Guaranteed that restoring a backup never leaves the database half-written if the JSON payload is malformed. Ensured dark theme preferences and account settings restore cleanly alongside transactional data.

Sprint H6: Main-Thread Offload & Flow Consolidation

Profiling revealed that several ViewModels were mapping Room database entities to domain models on the main thread, causing frame jank during fast scrolling. We offloaded all transformations to Dispatchers.Default and consolidated multiple cold database Flow observers into shared hot StateFlow streams.

Sprint H7: WCAG AA Contrast Compliance & UI Polish

Refactored the color token system. Ensured that financial warning badges, negative expense indicators, and chart legends meet WCAG AA contrast standards (4.5:1 ratio) in both Light and Dark themes.

Sprint H8: God Screen Decomposition & Security Modernization

Decomposed a 3,000-line monolithic SettingsScreen.kt into 11 modular components. Modernized user PIN authentication from legacy single-pass hashing to 50,000-iteration PBKDF2 with constant-time equality checks.

Key Takeaway

Features attract users, but architectural hardening retains them.

Taking two months to pause feature development and execute eight disciplined hardening sprints was the best engineering decision in the history of FinLedger. It turned a promising prototype into an unshakeable, mathematically sound financial engine that users can trust with their life savings.


FinLedger is a privacy-first, offline-first personal finance application for Android that models bank accounts, credit cards, and cash without double-counting.

Explore FinLedger on Google Play: https://play.google.com/store/apps/details?id=com.devanshufinance.app

Top comments (0)