SplitSync
A database-native, transaction-hardened expense-splitting web application built with a custom Aurora Mint theme, PostgreSQL transaction isolation, and anomaly-detection CSV parsers.
What is SplitSync?
SplitSync is a database-native application designed to handle group bill splits, transaction tracking, and debt clearing. Unlike traditional split bills apps that implement loose client-side mathematical logic, SplitSync is built as a highly robust, hardened transactional system. It features atomic writes, database-level isolation constraints, multi-currency support, and audit trail tables.
Floating-Point Errors & Weak Isolation
Most expense trackers suffer from floating-point errors (e.g., fractional penny divisions like 0.33 + 0.33 + 0.33 = 0.99) and network failures where an expense is written but group user splits are not, resulting in broken database balances. Furthermore, manual entry of large group bills or receipts via CSV uploads frequently introduces data anomalies.
Rounding Errors
Dividing odd amounts leads to missing fractional decimals. SplitSync solves this by converting currency to integer sub-units (paise/cents).
Partial Transactions
If network connection cuts midway through an API call, expenses are created without corresponding splits. Atomic database RPCs eliminate this.
Invalid CSV Uploads
Self-settlements, negative inputs, outliers, or totals mismatching split percentages are flagged instantly by a 24-category anomalies analyzer.
Inefficient Settlements
Group transactions often result in circular, redundant debts (e.g., A owes B, B owes C, C owes A). A greedy pathfinder simplifies balances to minimal edges.
Core Hardened Subsystems
Staging Area & Custom Lexer
Built a custom CSV lexer supporting double-quoted fields, comma separators, and local currency strings. The layout provides live staging feedback before committing rows.
Fuzzy Roster Mapping
Avoids exact database matches by mapping upload identifiers with a substring distance metric (e.g., "Jan M" matches "Jan Mohammad").
Ledger Parity checks
Maintains strict mathematical parity. A background loop automatically audits balance matrices, displaying warning cards if cumulative user balances do not sum to exactly zero.
PostgreSQL Transactions (RPC)
SplitSync moves transaction validation from client Node scripts directly into the database engine. Expenses are saved by invoking a dedicated PostgreSQL Remote Procedure Call (RPC) create_expense_with_splits.
Dual-layered Write Strategy
To ensure resilience, SplitSync supports client-side transaction fallbacks:
- The React application fires the atomic Postgres RPC transaction first.
- If the migration hasn't been executed on the hosted database, it rolls back gracefully and executes an asynchronous client-side pipeline.
- Every state modification triggers triggers that log actions in an
AuditLogtable.
Greedy Debt Simplification
Reduces cumulative bank transactions among roommates or travel groups by mapping balances to a directed network. The algorithm extracts maximum creditors and maximum debtors, iteratively clearing balances in $O(N \log N)$ operations until all debts are settled.