01 / PROJECTFull-Stack Product · Distributed Business Logic
SplitSmart
Shared-expense settlement with an auditable ledger
A shared-expense platform where the hard part is not the arithmetic but the invariants: members join and leave over time, four different split modes have to agree, and every mutation has to stay auditable.
Architecture
Client
Users
Authenticated group members acting on shared state.
Users → Next.js → Business Logic → Prisma → PostgreSQL (Neon)
The problem
Splitting expenses across a group stops being simple the moment membership changes. An expense recorded in March must not be reapportioned because someone joined in June, and any correction has to remain traceable.
Engineering challenge
Keeping settlement correct while group membership changes over time, and keeping every correction traceable rather than silently overwritten.
Approach
Modelled membership as a timeline rather than a flag, so an expense is always apportioned against the members active at its date. Balances are reduced with a greedy debt-simplification pass, and every mutation is written to an append-only audit log with JSON old/new value diffs.
- PostgreSQL
- Relational integrity and transactional guarantees for ledger state.
- Prisma
- Type-safe access across a 10-model schema, with migration history.
- NextAuth
- Session handling wired into route protection rather than bolted on.
- Neon
- Managed Postgres with branching, suited to schema iteration.
Engineering detail
- 0110-model PostgreSQL schema covering groups, members, expenses, splits and audit history
- 02Active/inactive member timeline invariant, so historical expenses are never reapportioned
- 03Four expense split modes — equal, exact, percentage and share-weighted
- 04Greedy debt simplification that collapses circular balances into the fewest transfers
- 05CSV import wizard with fuzzy member-name matching against existing members
- 0612 anomaly detection rules run over imported rows before they are committed
- 07Append-only audit log storing JSON old/new value diffs for every mutation
- 08Route protection through NextAuth session checks on every authenticated path
Engineering practices
- Append-only audit log — corrections are new records, never overwrites.
- Anomaly rules run before import is committed, not after.
- Invariant enforced in the domain layer rather than in the UI.
Features
- Four split modes with a shared settlement path.
- Debt simplification into the fewest transfers.
- CSV import with fuzzy member matching.
- Full audit history with value-level diffs.