How the credits system works
Published Sep 4, 2026 · Team
engineering
The credits system uses a two-table design: credit_grant batches and an immutable credit_transaction ledger.
Batches with expiry
Every grant is a batch with amount, remaining, and an optional expiresAt. Registration gifts might expire in 30 days; purchased packages never expire.
FEFO deduction
Consumption deducts from the batch that expires first (First-Expired, First-Out), so users never lose credits that could have been spent.
Daily job
A GitHub Actions cron job (or GET /api/distribute-credits) zeroes out expired batches and writes expiration transactions, then downgrades expired subscriptions.