← All projects

Supplement Ordering with a Double-Entry Ledger

What it does

A provider builds a supplement order for a patient, and the patient pays through a pay link (payments are faked). On payment, one database transaction splits the total into cost of goods, the provider’s payout and a 75 bps platform fee, recorded as balanced double-entry ledger rows. An audit page shows where every cent of a paid order went.

Claude also turns a protocol note into a suggested order, constrained by a strict schema with a keyword fallback. Refunds post reversing entries, and orders can be reordered or cancelled.

Where every cent goes
  1. Provider builds orderfrom catalog prices
  2. Patient payspay link, faked payments
  3. One transactionserver recomputes the split
  4. Ledger entriesCOGS, payout, 75 bps fee
  5. Refundsreversing entries, never edits

Engineering notes

Money is integer cents everywhere, ledger rows are append-only, and the server recomputes every split instead of trusting the client. It’s tested with property tests and a red-team suite.

Tools

TypeScript, Fastify, Vue 3, Drizzle, Postgres, Vitest, fast-check, Playwright, Claude Haiku, Render