Skip to content

RantAI-dev/RustBill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

RustBill Logo

RustBill

Open-source billing, product & license management platform built with Rust and Next.js

CI Nightly E2E License: MIT Rust 1.82+ TypeScript Next.js 16


What's New

  • Rust-first API architecture - Next.js now proxies all /api/* traffic to Rust via a single catch-all API proxy; old Next API handlers are archived under api-deprecated/next-api/.
  • Subscription pre-renewal invoices - Automatic pre-generation before period end (default 7 days) with per-subscription override via preRenewalInvoiceDays.
  • Provider setup flows in UI - Payment method setup launch for Stripe/Xendit from Billing Portal, plus provider settings management in Settings.
  • Provider-grade auto-charge settlement - Auto-charge persists provider references and classifies transient vs permanent failures.
  • Comprehensive E2E coverage - Playwright smoke/core suites now validate frontend-to-backend flows and run in CI; provider sandbox tests run nightly.
  • Sales ledger hardening gates - CI now enforces reconciliation, idempotency, partition-pruning diagnostics, and reversal-link integrity tests.

Features

  • License Key Management — Ed25519 signing, online/offline verification, hardware-locked licenses, keypair management
  • Billing Engine — Recurring lifecycle, pre-renewal invoicing, dunning, credits wallet, proration, refunds, credit notes
  • Multi-Provider Payments — Stripe, Xendit, and LemonSqueezy checkout/setup support
  • Customer/Product/Deal Management — Full CRUD with pipeline tracking and auto-license generation paths
  • Subscription Control — Per-subscription pre-renewal lead time (preRenewalInvoiceDays) configurable via API and UI
  • Analytics & Reporting — Dashboard metrics, forecasting, product performance, and reports views
  • Authentication & Access — Built-in auth, optional Keycloak SSO, admin API keys, v1 customer-scoped API keys
  • Frontend-to-Backend E2E Testing — Playwright smoke/core in CI plus nightly provider sandbox coverage

Screenshots

Quick Start

Prerequisites

Setup

# Clone the repository
git clone https://github.com/RantAI-dev/RustBill.git
cd RustBill

# Install frontend dependencies
bun install

# Start PostgreSQL
bun run db:up

# Push database schema
bun run db:push

# Seed initial data
bun run db:seed

# Start the frontend dev server
bun dev

Rust Backend

cd rustbill

# Start the backend database (if not already running)
docker compose up -d

# Run the server
cargo run -p rustbill-server

# Run tests
cargo test -- --test-threads=1

Run Full Stack (Recommended)

Run Rust backend and frontend together so the UI uses Rust APIs:

# terminal 1
cd rustbill
cargo run -p rustbill-server

# terminal 2 (repo root)
RUST_BACKEND_URL=http://127.0.0.1:8787 bun dev

The frontend runs on http://localhost:3000 and Rust backend on http://localhost:8787.

Architecture

┌─────────────────────┐     ┌─────────────────────┐
│   Next.js 16 SPA    │────▶│   Rust Axum API      │
│   (Bun runtime)     │     │   (rustbill-server)   │
│   Port 3000         │     │   Port 3001           │
└────────┬────────────┘     └────────┬──────────────┘
         │                           │
         └───────────┬───────────────┘
                     ▼
          ┌─────────────────────┐
          │   PostgreSQL 17     │
          │   Port 5444         │
          └─────────────────────┘

The Next.js frontend proxies API calls through app/api/[...path]/route.ts to Rust (RUST_BACKEND_URL). Both stacks share the same PostgreSQL database.

Tech Stack

Layer Technology
Frontend Next.js 16, React 19, TypeScript, Tailwind CSS v4, shadcn/ui
Backend Rust, Axum 0.8, SQLx, Tower
Database PostgreSQL 17, Drizzle ORM (frontend), SQLx (backend)
Payments Stripe, Xendit, LemonSqueezy
Auth Built-in + Keycloak SSO
Crypto Ed25519-Dalek, Argon2, Bcrypt, HMAC-SHA256
Email Resend (frontend), Lettre (backend)
Charts Recharts
Testing Vitest + Testing Library, Playwright E2E (frontend), axum-test (backend)
CI/CD GitHub Actions
Runtime Bun, Docker (multi-stage builds)

Documentation

Development

# Frontend
bun dev              # Dev server
bun lint             # ESLint
bun test             # Vitest
bun run build        # Production build
bun run db:studio    # Drizzle Studio GUI
bun run test:e2e:smoke  # Playwright smoke
bun run test:e2e:full   # Playwright core

# Rust backend (from rustbill/ directory)
cargo fmt --all      # Format
cargo clippy --all-targets -- -D warnings  # Lint
cargo test -- --test-threads=1             # Test

Contributing

Contributions are welcome! Please read our Contributing Guide and Code of Conduct before submitting a PR.

License

This project is licensed under the MIT License.

Star History

Star History Chart

Built with 🦀 by RantAI