When you build a personal finance app, you start with the features you think will be hardest:
Room database encryption with SQLCipher.
On-device machine learning classifiers.
Multi-threaded SMS regex pipelines.
You assume that tracking loans to friends will be the easiest feature in the entire project. After all, it's just basic arithmetic: $\text{lent} - \text{repaid} = \text{balance}$.
I could not have been more wrong.
Over the development journey of FinLedger—from early v1.0 prototypes to our comprehensive v2.1 architectural audit ( docs/audit/FINLEDGER_FEATURE_AUDIT_MASTER.md )—the Lending and Borrowing Subsystem underwent more complete rewrites and structural refactorings than almost any other module in the codebase.
Here are the three major architectural mistakes I made, how each one corrupted data, and the lessons learned from refactoring personal debt tracking into a hardened, lifecycle-driven system.
Mistake 1: Mutating the Original Principal on Repayment
In our v1.0 schema, a loan record…