XRAPH/Work/Billing
Go · since 2026

Ledger

Usage-based billing for SaaS: meter events in batches, check entitlements, price them with graduated, volume, flat or hybrid tiers, and generate invoices with taxes and discounts. Money is integer-only throughout. Entitlement checks are cached and sub-millisecond because they end up on the hot path of every request.

Language
Go
Category
Billing
Since
2026
Stars
2
Repository
01

Anatomy

4 modules
01

Subscriptions

Plans, terms and changes over time.

02

Metering

Usage recorded as events, aggregated on read.

03

Entitlements

What a customer may do, derived from their plan.

04

Invoices

Generated from the record, not from a running total.

02

Why it exists

Design notes

#What it is

Ledger is a usage-based billing engine for Go: meter events, check entitlements, compute invoices, manage plans and subscriptions, and integrate a payment provider.

#What it does

  • Subscriptions: trials, upgrades, downgrades, cancellations, with proration.
  • Metering: batched high-throughput ingestion, tested above 100k events per second.
  • Entitlements: cached authorization checks in under a millisecond, because they end up on the hot path of every request rather than only at checkout.
  • Pricing: graduated, volume, flat-rate and hybrid models.
  • Invoices: line items, taxes, discounts, and a coupon system with percentage and fixed-amount validation.

#Two decisions worth calling out

Money is integer-only. There is no float anywhere in the codebase. Every rounding decision is explicit and happens at a named place, because the alternative is a reconciliation conversation with a finance team about half a cent.

Identifiers are TypeIDs: globally unique, K-sortable, and prefixed, so an id in a support ticket tells you what kind of thing it refers to without a lookup.

Storage is pluggable across PostgreSQL, SQLite, Redis and memory, and Chronicle integration gives the audit trail that billing disputes eventually require.

03

Signals

GitHub
Stars
2
Language
Go
Since
2026
Adopters
00

Shipping something on Ledger? Nobody is listed here yet. Tell me what you built and you will be the first.

Get listed
04

Where it sits

Fields · papers