AI apps

Tech stack for an AI SaaS with usage-based billing (2026)

AI writing assistant for marketing teams, designed by StackPrism from one sentence: 10 components, a reason for each, and the live checks that watch them.

The stack

  • Next.js
  • Node.js
  • Inngest
  • Clerk
  • OpenAI
  • Stripe
  • Resend
  • PostgreSQL
  • Redis
  • Sentry
AIUsage billingStripeUpdated
The idea someone typed
“An AI writing assistant for marketing teams. Users generate blog drafts and ad copy with an LLM, each workspace has a monthly token allowance, and extra usage is billed at the end of the month through Stripe, with hard spend limits.”

Make it yours. Open this stack in the editor to check its health, harden it and hand it to your coding agent. No sign-up, nothing to generate.

Start from this stack
goes down

Select a component to see what it does and what it connects to, or pick one above to see what breaks if it goes down. Pinch or use the buttons to zoom.

Why this stack

Every generation goes through one Node.js API on Vercel. Before it calls the OpenAI API, it checks the workspace’s usage counter in Redis, so a workspace that has used its allowance or hit its spend limit is stopped before any tokens are spent. Clerk handles sign-in and organizations, which map onto workspaces, and PostgreSQL keeps the workspace records. The API sends usage and plan changes to Stripe, and Stripe’s webhooks report back when a payment succeeds or fails. Inngest runs background jobs, Resend sends account emails and Sentry reports errors.

Why each piece

All 10 components on the diagram: what each one does, what it talks to, and what stops if it goes down.

  1. Next.js Web App

    Runs on Vercel

    Marketing dashboard. Calls Node.js API and Sentry (errors).

    Nothing else on the diagram depends on it.

  2. Node.js API

    Runs on Vercel, in Core Services

    Control plane. Calls Clerk (auth), PostgreSQL (reads/writes), Redis (checks), OpenAI API, Inngest (jobs), Stripe (billing) and Resend (emails). Called by Next.js Web App and Stripe (webhooks).

    If it goes down, 1 of 9 components stops working.

  3. Inngest

    Runs on Vercel, in Core Services

    Background jobs. Called by Node.js API (jobs).

    If it goes down, 1 of 9 components degrades.

  4. Clerk

    Auth and orgs. Called by Node.js API (auth).

    If it goes down, 2 of 9 components stop working.

  5. OpenAI API

    Content generation. Called by Node.js API.

    If it goes down, 1 of 9 components degrades.

  6. Stripe

    Billing and charges. Calls Node.js API (webhooks). Called by Node.js API (billing).

    If it goes down, 1 of 9 components degrades.

  7. Resend

    Operational email. Called by Node.js API (emails).

    If it goes down, 1 of 9 components degrades.

  8. PostgreSQL

    In Data & Storage

    Workspace records. Called by Node.js API (reads/writes).

    If it goes down, 2 of 9 components stop working.

  9. Redis

    In Data & Storage

    Usage counters. Called by Node.js API (checks).

    If it goes down, 1 of 9 components degrades.

  10. Sentry

    Error tracking. Called by Next.js Web App (errors) and Core Services (errors).

    If it goes down, 3 of 9 components degrade.

When this stack fits

  • Your costs grow with every token, so pricing has to grow with usage too.
  • Limits must hold in real time: the check happens before the model call, not at the end of the month.
  • Customers are teams that share one allowance per workspace.

When to pick something else

  • One provider’s outage would stop every generation: add a second model provider or a model gateway behind the API.
  • Billing is a flat subscription with fair-use limits: plain Stripe subscriptions are simpler than metered usage.

What you need to build this

10 components across 9 areas of the stack.

Build it with your AI agent

Hand the stack to Claude Code, Codex, Cursor or any coding agent as a brief: how it connects, install steps and a build plan.

Frontend1

  • Next.js Web App

    Marketing dashboard

    npm install next

    Docs

Backend & APIs2

  • Node.js API

    Control plane

    Docs
  • Inngest

    Background jobs

Data1

  • PostgreSQL

    Workspace records

    Docs

Cache & queues1

  • Redis

    Usage counters

    Docs

Auth1

  • Clerk

    Auth and orgs

    npm install @clerk/nextjs

    Docs

Payments1

  • Stripe

    Billing and charges

    npm install stripe

    Docs

Email & messaging1

  • Resend

    Operational email

AI1

  • OpenAI API

    Content generation

    npm install openai

    Docs

Observability1

  • Sentry

    Error tracking

    npm install @sentry/nextjs

    Docs

Install

npm install next @clerk/nextjs stripe openai @sentry/nextjs

SDKs only. Pick your own database driver or ORM.