Project index

File 02 / 06

Ledgerly.

A double-entry billing engine for SaaS — usage-based pricing without the headache.

Year

2024

Role

Creator & Maintainer

Timeline

Ongoing

Status

Open source

Stack

TypeScriptStripePostgreSQLPrisma

01 — Overview

Ledgerly is an open-source, double-entry billing engine for SaaS products. It treats every cent as a ledger entry — so usage-based pricing, credits, proration and refunds reconcile exactly, instead of approximately.

02 — The challenge

Every SaaS team rebuilds the same broken billing logic: floating-point money, mystery proration, invoices that never quite match the meter. I watched three companies ship incorrect invoices and decided the industry needed a boring, correct primitive it could just adopt.

03 — Approach

  • Modeled money as integer minor units and balances as append-only double-entry journal lines
  • Implemented proration and credits as pure functions over the journal — every invoice is reproducible from history
  • Integrated Stripe as a payment rail while keeping all state authoritative in Postgres, not in Stripe
  • Published with a test suite of 900+ cases covering the invoices-that-ruined-my-weekend hall of fame

04 — The outcome

Ledgerly is now the billing backbone for dozens of indie SaaS products, with 4.2K GitHub stars and a contributor base that keeps the invoice edge cases — all of them — covered.

4.2KGitHub stars
38KWeekly downloads
900+Test cases

Next file — 03

Shipmate

Deployment CLI