AI SaaS Starter
A subscription SaaS with an AI feature at its core: Next.js, Supabase, Stripe and a model API, with the data model and build order laid out.
Next.js 15 Supabase Stripe Anthropic API
How to use this blueprint
A blueprint is a build plan you follow with your AI coding tool. There is nothing to download here; you work through the page from top to bottom.
- Read the plan below. It tells you what to build, with which tools, and in what order.
- Generate your project documents. The free PRD generator and CLAUDE.md generator turn this plan into files for your project.
- Build step by step. Follow the idea-to-production workflow, giving your AI tool one build phase at a time.
Build it with AI: your kickoff prompt
Paste this into Claude Code, Cursor or any AI coding tool and it will drive the build from this blueprint. No programming knowledge needed to start.
I want to build this project with you, step by step. Project: AI SaaS Starter Stack: Next.js 15, Supabase, Stripe, Anthropic API What it is: A subscription SaaS with an AI feature at its core: Next.js, Supabase, Stripe and a model API, with the data model and build order laid out. Full build plan: https://appcodely.com/blueprints/ai-saas-starter Rules for this collaboration: - Follow the build plan phase by phase; one phase per session. - Before writing code, draft a short PRD and a CLAUDE.md with me. - Work in small steps and run the tests after every change. - Tell me when a decision is mine to make instead of guessing. Start by asking me the three most important questions about this project, then propose the plan for phase 1.
This blueprint takes you from empty repository to a subscription SaaS with an AI feature at its core: authentication, billing, a protected dashboard and a model-backed endpoint. It is trimmed to the parts every subscription SaaS needs, nothing more.
What you are building
A web application where users sign up, pick a paid plan and use an AI-powered feature (chat, generation or analysis, your choice) within usage limits. Admin views, webhooks and environment separation included. No placeholder pages; every route earns its place.
Stack and why
- Next.js 15 (App Router): server components by default keep the client bundle small, and one framework covers pages and API routes.
- Supabase: Postgres with row-level security, plus authentication that works out of the box. You own the database and can leave managed hosting later without a rewrite.
- Stripe: subscriptions, customer portal and webhooks. Do not build billing yourself.
- Anthropic API: the AI feature itself. The pattern is identical for any model provider.
Architecture
Three rules keep this codebase healthy as it grows:
- All model calls go through one server module. Client components never touch the AI provider; they call your API route, which applies auth, rate limits and usage metering in one place.
- Billing state lives in your database, mirrored from Stripe by webhook. The app reads entitlements from Postgres, never from Stripe at request time.
- Row-level security on every table. Policies enforce tenancy at the database layer, so a leaked query cannot cross accounts.
Data model
| Table | Purpose | Key columns |
|---|---|---|
| profiles | User data beyond auth | id (auth ref), display_name |
| subscriptions | Mirrored billing state | user_id, stripe_customer_id, plan, status, current_period_end |
| usage_events | Metering for limits | user_id, feature, tokens, created_at |
| ai_requests | Audit and debugging | user_id, prompt_hash, model, status, latency_ms |
Build order
- Skeleton: Next.js app, Supabase project, auth flow, one protected page. Deploy on day one so the pipeline exists.
- Billing: Stripe products, checkout, customer portal, webhook handler writing to the subscriptions table. Test with the Stripe CLI before any UI polish.
- AI feature: the server module, one endpoint, streaming to the client. Add usage metering in the same commit as the feature, not later.
- Limits and admin: enforce plan limits from usage_events, add an admin view over requests and subscriptions.
- Hardening: rate limiting on public endpoints, error states in the UI, alerts on webhook failures.
Pitfalls to plan around
- Webhooks arrive out of order. Write handlers that upsert on the latest Stripe state rather than assuming event sequence.
- Streaming responses and serverless timeouts interact badly. Check your platform limits before choosing long-form generation features.
- Meter usage on the server response, not the client. Closed tabs still consume tokens.
Working with an AI agent on this build
This blueprint pairs well with agent-driven development: each build phase above is one delegable task. Start your session with a proper CLAUDE.md, follow the idea-to-production workflow, and if you are new to the tooling, read the Claude Code guide first. Write the PRD before the first prompt; the PRD generator gets you a solid draft in minutes.
FAQ
Can I swap Supabase for another Postgres host?
Why mirror Stripe state instead of querying Stripe directly?
Does the blueprint include the AI feature implementation?
Sources
- Next.js documentation, Vercel
- Supabase documentation, Supabase
- Stripe billing documentation, Stripe