src/app — App Router pages + API routes (17)
src/lib/billing — Billing: plans, access, ledger, seats, sync (6)
src/lib/actions — Server actions: auth, teams, billing (3)
src/lib/teams — Team plumbing (2)
src/lib/email — Email transport (1)
src/emails — React Email templates (10)
src/lib — Core lib: env, auth, guards, validators (7)
src/components — Shared components (2)
prisma — Schema + dev seed (2)
scripts — Webhook harness, fixtures, Stripe bootstrap (8)
tests — Unit suite (vitest) (8)
docs — Module guides with deletion guides (4)
./ — Project root (9)
What you're watching
Failure starts the clock. The first failed invoice stamps a 7-day grace deadline and sends this email to the team's owners — the real one from the run:
┌─ [email — console transport, set RESEND_API_KEY to really send] ─ │ To: ava@acceptance.test │ Subject: Payment failed for Ava's Team ├────────────────────────────────────────────────────────────────── │ A payment didn't go through │ │ The latest payment for Ava's Team failed — usually an expired card │ or a bank decline. │ │ Nothing is cut off yet: your team keeps full access until │ August 6, 2026 while the charge is retried. To fix it now, open │ Settings → Billing → "Manage billing" and update the payment method. └──────────────────────────────────────────────────────────────────
The duplicate is refused. The same event id delivered twice returns
{"duplicate":true} — the WebhookEvent ledger at work.
The download includes the harness and all 6 fixtures, so you can replay this against your own machine
with no Stripe account.
In the download
- Full source — 79 files, 5,556 lines (4,710 of code) — no build-time magic, no private packages
- Auth three ways: credentials, magic links, Google/GitHub OAuth
- Team workspaces: invitations, roles, ownership transfer, last-owner protection
- Stripe subscriptions: idempotent webhooks, per-seat + flat plans, proration, grace + dunning
- 9 React Email templates with a console transport for keyless dev
- Webhook harness + 6 signed fixtures, Stripe bootstrap script, dev seed
- README + 4 module guides, each ending in a deletion guide
Honestly not included: an admin panel, analytics, a component library, or mobile apps. It's a starter — the product on top is yours.
The test suite (72 passing)
| Suite | Covers | |
|---|---|---|
| env | env schema + feature flags | 15 |
| passwords | bcrypt contract | 4 |
| plans | price↔plan mapping | 8 |
| seats | seat quantity + proration | 6 |
| subscription | access + grace matrix | 15 |
| validators | every input schema | 18 |
| webhook-ledger | idempotency decisions | 6 |
Run them yourself: npm test — plus
npm run typecheck (strict, noUncheckedIndexedAccess) both green.