Credits
Set up, configure, and run the Reloop credits microservice locally.
Complete Base Setup First
Ensure you've finished the Setup — before proceeding.
Service Overview
Subscription tiers, credit balances, usage tracking, and Stripe billing integration.
| Property | Value |
|---|---|
| Directory | apps/backend/credits |
| Port | 8023 |
| Local URL | https://local.reloop.sh/api/credits |
| Swagger UI | https://local.reloop.sh/api/credits/openapi |
| Stack | ElysiaJS PostgreSQL NATS |
Quick Start
Run from the monorepo root:
bun be:credits:dev
The service starts with hot reloading on port 8023.
Environment Configuration
Variables live in apps/backend/credits/.env. Running bun env:setup from the root auto-populates this file.
PORT=8023
NODE_ENV=development
INITIAL_CREDITS=100
NATS_URL=nats://localhost:4222
Reference Table
| Variable | Required | Default |
|---|---|---|
PORT | YES | 8023 |
INITIAL_CREDITS | YES | 100 |
NATS_URL | YES | nats://localhost:4222 |
Development Commands
| Command | Description |
|---|---|
bun be:credits:dev | Start dev server with hot reloading |
bun run --filter=credits build | Compile production bundle |
bun run --filter=credits start | Run compiled production build |
bun run --filter=credits check-types | TypeScript type-check |
Architecture
| Layer | Detail |
|---|---|
| Credits | Tracks balances and blocks sends when credits reach zero. |
| Stripe | Manages subscriptions, invoices, and billing webhooks. |
| Events | Publishes billing.quota-warning and related NATS subjects. |
| Schema | plan, subscription, credit_ledger in packages/db/src/schema/billing.ts. |
Was this page helpful?