DEV Community

I built an AI invoicing SaaS boilerplate — here's what I learned

I spent the last few months building InvoiceAI — a full-stack, production-ready SaaS boilerplate for AI-powered invoicing. Here's what I built and what I learned along the way.

What is it?

InvoiceAI is a Next.js 15 boilerplate that lets you launch your own invoicing SaaS. Not a tutorial project — a real product you can deploy and charge for on day one.

Live demo: https://ai-invoice-generator-five-rosy.vercel.app
(demo@example.com / demo123456)

Tech stack

  • Next.js 15 (App Router) + TypeScript
  • Prisma ORM — SQLite for dev, PostgreSQL for prod
  • NextAuth v5 — credentials + Google + GitHub OAuth
  • Stripe — subscriptions, Customer Portal, webhooks
  • pdf-lib — server-side PDF generation
  • Resend — transactional email
  • Tailwind CSS + Zod + React Hook Form

Key features

1. Multi-provider AI generation

The app supports 8 AI providers switchable from the admin panel — no code changes needed:

  • OpenAI (GPT-4o, GPT-4o Mini)
  • Groq (Llama 3.3 70B — free tier)
  • Anthropic (Claude 3.5 Sonnet)
  • Google Gemini (1.5 Pro, 2.0 Flash)
  • Mistral, DeepSeek, xAI (Grok), Cohere

Since Groq, Mistral, DeepSeek and xAI all use OpenAI-compatible APIs, I only needed one generateOpenAICompat() function for all of them.

2. Server-side PDF generation

I used pdf-lib instead of headless Chrome. It's much faster, has zero cold-start issues on Vercel, and produces clean output. The tricky part was i18n — I implemented 5 languages (EN, RU, DE, FR, ES) with a translation map.

3. Recurring invoices with Vercel cron

vercel.json schedules two cron jobs:

  • Daily at 8am: send overdue reminders
  • Daily at 9am: process recurring invoices

Each job is just a Next.js API route protected by a CRON_SECRET header.

4. Client portal without login

Each client gets a unique token (publicToken) stored on the invoice. They can view and download their invoices at /invoice/[token] without creating an account. Simple but very useful feature.

5. Stripe subscription flow

Full flow: Free plan (5 invoices/month) → Stripe Checkout → webhook → Pro plan (unlimited + AI). The webhook handler covers all cases: checkout, renewal, cancellation, payment failure.

What I learned

SQLite for dev is underrated. Zero setup, instant local development. Just switching the Prisma provider string deploys to PostgreSQL.

Groq is surprisingly good for structured output. Llama 3.1 8B on Groq returns valid JSON consistently and it's free. Perfect for demos.

Next.js 15 App Router caches aggressively. Server components cache subscription status — had to be careful to invalidate after plan changes.

pdf-lib has no font support out of the box. I had to embed a custom font for non-latin characters (Cyrillic for Russian). Worth knowing upfront.

Get it

The full source code is available on Gumroad for $97 (MIT license, commercial use allowed):

👉 https://stepanova12.gumroad.com/l/urykyi

Happy to answer questions in the comments!

Top comments (0)