Harsh Wardhan
Identity: Financial CorrectnessTeam ProjectIn DevelopmentPrivate Repository

Splitzy

Offline-First Financial Expense Splitting System

Engineering Challenge

“How do you build reliable financial software that remains correct even when users are offline?”

Products•In Development•Full-Stack Systems Engineer•2026
Unit Tests58Passing
Paise MathIntegerZero Float Loss
Event LogAppend-OnlyAudit Trail
TriggersPL/pgSQLDB Invariants
Splitzy
01 Product Context

Problem & Product Goals

Expense splitting applications frequently suffer from floating-point arithmetic errors, overwrite-heavy database schemas that destroy edit histories, and balance discrepancies when users edit transactions. Splitzy addresses these issues with a CQRS-lite architecture separating the immutable command log from materialized read balances.

Why I Built It

Standard expense splitters often introduce rounding errors when dividing odd amounts among friends, and editing past transactions can silently corrupt group balances. I wanted to design a ledger that treats financial accuracy as an uncompromisable engineering requirement.

02 Implementation

Technical Architecture & Core Engine

Core Engine Mechanism

The core financial engine uses BigInt integer paise values and remainder distribution algorithms to allocate exact paise remainders deterministically among split participants.

Design Philosophy: Immutability over mutations: never overwrite financial rows directly. Record every transaction edit or balance update as a signed, append-only event entry.

03 Technical Rigor

Engineering Decisions

Decision #01 • Integer Paise vs Floating Point Arithmetic
Problem:

IEEE-754 floating-point numbers in JavaScript introduce accumulation errors (e.g. 0.1 + 0.2 !== 0.3) that break financial totals.

Decision:

Represented all currency strictly as positive BigInt integer paise with custom branded types.

Tradeoff:

Requires explicit conversion at input boundaries and UI display formatting.

Outcome:

Completely eliminated precision loss across all split calculations.

Decision #02 • Immutable Event Logs vs Direct Mutations
Problem:

Updating balance records directly on expense edits makes historical auditing impossible and creates race conditions.

Decision:

Implemented an append-only event stream where edits write compensating events processed atomically by PL/pgSQL database triggers.

Tradeoff:

Higher database storage footprint for transactional event history.

Outcome:

Created a 100% verifiable financial audit log for all group ledger changes.

04 Problem Solving

Challenges & Solutions

Zero-Balance Exit Invariants

Issue: Preventing group members from leaving while holding un-settled debts using client-side checks was prone to bypasses.

Decision/Solution: Enforced the exit rule directly inside PostgreSQL database triggers (`prevent_member_leave_with_balance`), making bypasses impossible.

Chronology

Development Timeline

Jan 2026

Financial Core Spec

Defined integer-paise mathematical rules and event schemas.

Feb 2026

PL/pgSQL Trigger Pipeline

Wrote database-level invariant enforcement triggers.

Mar 2026

Offline Sync Engine

Built Zustand persistent offline mutation queue.

Future Roadmap

What's Next

CRDT-based mesh synchronization for peer-to-peer offline group syncing
Exportable CSV audit statements for transaction ledgers
Multi-currency conversion engine with fixed exchange rates
Retrospective Summary

Key Takeaways

Takeaway #01

Financial applications must represent money as integer atomic units rather than floating-point floats.

Takeaway #02

Append-only event streams preserve complete audit trails and prevent state corruption.

Takeaway #03

Pushing critical invariant rules into database triggers provides guarantees that client-side logic cannot replicate.

Continue Exploring

Related Engineering Projects