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 Docs
01

Highlights

3 claims
H.01
Underamillisecond
Entitlement checks

Cached feature access lookups, because a permission check that sits on every request cannot afford a round trip.

H.02
Tenthousand
Usage events a second

Batched ingest with non-blocking calls and an automatic flush, so metering does not become the bottleneck it measures.

H.03
Integersonly
Money without floats

Multi-currency handling with proper decimals and no floating-point error anywhere in the arithmetic.

02

What it does

6 entries

Billing, metering and entitlements for a product that charges by what people actually use.

02.1
Entitlements

Checked in under a millisecond

Feature access is cached for the frequency it is actually asked at, which is every request.

Cached
02.2
Metering

Ten thousand events a second

Usage ingest is batched and non-blocking with an automatic flush, so the call that records usage does not slow down the thing being measured.

Batched
02.3
Pricing

Five models as structs

Graduated tiers, volume pricing, per-seat, flat rate and hybrids, defined in Go, so a price change turns up in review.

Typed
02.4
Subscriptions

Trials through cancellation

Upgrades, downgrades and cancellations with proration and period management computed from the billing period.

Proration
02.5
Invoicing

Line items, taxes and discounts

Invoices are generated from the metered usage and handed to a payment provider for collection.

Automatic
02.6
Money

Integers, always

Currency is held as integers with multi-currency support and proper decimal handling, so a rounding error cannot accumulate into a real one.

No floats
03

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.

04

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.

05

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
06

Where it sits

Fields · papers