Billing + tenancy · one embedded family

Billing and tenancy, exact by construction

Meter usage, price it to a fraction of a cent, keep a double-entry ledger, and hold every tenant’s boundary at the database — a family of Apache-2.0 libraries you embed in the app you already run. No revenue cut, no second service to operate.

Get started for free$ npm i billing-kit
One interface, any providerStripePaddleLago+ your own adapter
The Money type

A cent that can’t drift into a rounding error.

Amounts are integer minor units in a bigint — never a JavaScript number. Once a value passes through a float, an exact 19.99 and a drifted 19.99 are indistinguishable. billing-kit refuses the ambiguity at the type level.

  • Exact decimals, no float
  • ISO-4217 aware (JPY, KWD)
  • Rounds once, auditably
price.ts
import { Money, Quantity, Rate, price } from '@quxkit/billing-kit';

const q = Quantity.fromDecimalString('1234567');  // tokens
const r = Rate.fromDecimalString('0.00012'); // cents / token

const { amount } = price(q, r, 'USD');
amount.toDecimalString();          // '1.48' — exactly
The metering engine

Built to meter billions of events.

One set-based pass in Postgres — FOR UPDATE SKIP LOCKED, batched, idempotent — so concurrent workers can never double-bill and a run is a bounded transaction no matter how much is due.

109
events / run, bounded
0
double-charges under load
O(1)
recovery after downtime
live meter
API requests842,137
Compute minutes12,408
Storage GB·hr3,050
Aggregated to billable quantities, then priced — every amount a Money.
The double-entry ledger

Every cent, traceable — and it still balances.

Append-only and double-entry. Positive is a debit, negative a credit, and a transaction’s legs sum to zero — enforced by a deferred trigger, not by hope. Cash reaches the ledger only from a verified payment, never a stray credit().

  • Append-only, trigger-enforced
  • Balanced per currency
  • Idempotent postings
transaction · pay_9
cash+$19.99
customer_balance−$19.99
Σ per currency= 0.00 ✓
Re-derivable from raw events at any time — the audit never runs out of ground truth.
The tenant boundary

“Whose rows” is a property of the connection.

tenant-kit holds isolation at the database: tenancy.protect() forces row-level security per table, and the scoped executor sets the tenant per transaction. The forgotten WHERE tenant_id — the classic multi-tenant leak — degrades from a breach into an empty result.

  • Forced RLS — owners included
  • Scope dies with its transaction
  • The tenantId billing-kit consumes
psql · tenancy.protect('projects')
scoped · tenant-a
alpha
apex
(2 rows)
unscoped · same table
 
(0 rows)
Same query, same table — the policy is the WHERE.
The UI, shadcn-compatible

Drop billing into your app with one command.

Pricing tables, usage meters, a ledger explorer, checkout and a superadmin — installed with npx shadcn add, styled with your tokens, yours to own. Every amount renders through one Money formatter, never number math.

Browse the registry →

PlanPicker · Invoice
Regular$9.00
Pro$99.00
Input tokens · 842,137$101.06
Team seats · 8$40.00
Total$242.12
PaidDueOverdueVoid
The family

One stack, each kit owning one narrow thing.

Composed over shared shapes — one executor interface, one opaque tenant id, one Money type. What’s planned is labeled, not pre-announced as shipped.

Pricing

Open at the core. Priced where it’s hosted.

The libraries are Apache-2.0 and free forever. Pay only for the hosted service, or for the commercial UI — by the seat.

Open Source
$0

Self-host the Apache-2.0 core. Unlimited events, forever.

Cloud
$49 / mo

Hosted metering and ledger, managed for you.

Components
$199 / seat / yr

The commercial UI library, per developer seat.

Full pricing, computed exactly →
Get started

Start billing in minutes.

Precise money, a metering engine for scale, tenant boundaries the database holds, and the UI to show it — open source at the core.