← All work
Reliable money flows
Metered billing as durable, auditable workflows
Sudoblock · 2025
8
isolated modules
100%
retryable activities
0
lost usage events
The problem
Revenue operations — plans, quotas, usage aggregation, overage pricing, invoicing — had to be reliable and auditable. No lost usage, no double-counting, and safe to retry when something fails midway.
The approach
- Built the whole billing pipeline as durable Temporal workflows with per-activity retryability, so a failure resumes instead of corrupting state.
- Architected the backend around contract-based dependency injection across eight modules, with swappable in-memory adapters for isolated testing.
- Validated inputs and money math with Zod schemas and a Vitest suite covering the edge cases that cost real money.
The outcome
- Billing that survives crashes and retries safely — no lost or double-counted usage.
- Clean module boundaries that make the system testable and cheap to change.
- Usage aggregation, overage pricing, and invoice generation running as one auditable flow.
Stack
TypeScriptNestJSTemporalPostgreSQLZodVitest