28 Oct 2026 · Postgres & pgvector
Self-Hosted AI SaaS Stack: Next.js 15, LangGraph & pgvector
The production layers for a self-hosted AI SaaS, from Auth.js and Stripe up to Caddy and Terraform, with links to the deep-dive posts and the $149 Pro pack.
This is the map of the stack, not another 400-line tutorial. Each layer has a post that shows the failure and the fix. If you want the whole thing in one repo, that is AgenticPacks Pro at $149. If you want the free app only, that is AgenticPacks OSS.
The problem
An AI SaaS is not "call an API from a Server Action." It is a set of layers that have to survive Docker, TLS, billing, and a three-minute graph. People skip a layer, ship, then hit SIGKILL, a buffered stream, or a Stripe signature error.
Here is the order that actually works.
1. App and images
Next.js 15 App Router, output: "standalone", multi-stage Docker. Public NEXT_PUBLIC_* values are baked at build. DATABASE_URL and Stripe secrets enter at runtime.
AgenticPacks OSS includes the app image and Compose. It does not include Caddy.
2. Auth and tenancy
Auth.js v5, Prisma, sessions in Postgres. Server Actions check the session and the row owner. Teams are membership rows, not a hope.
3. Billing
Raw body for Stripe signatures. Idempotent event ids. Credits on the user (OSS) or on the organization (Pro).
4. Chat and agents
AI SDK streams for chat. LangGraph when you need a supervisor, a researcher, and a summarizer. Pause before dangerous tools.
AgenticPacks OSS has chat. Pro has the graph.
5. Retrieval
Embeddings in Postgres with pgvector. Chunk on ingest. Filter by organization on search.
6. Edge of the box
Caddy terminates TLS and must not buffer SSE. Long graphs need proxy timeouts. Cloudflare has a 100s habit.
Caddy is Pro.
7. Ops
Terraform for Hetzner. Prometheus and Grafana for token burn. A VPS instead of function duration caps.
If you are choosing a kit rather than a layer, read self-hosted vs cloud-locked starters.
Tired of collecting this stack from twelve READMEs?
The MIT app is one clone: Agentic-Packs/agenticpacks-oss.
The full stack is in the self-hosted stack in Pro.
What OSS is, what Pro is
| Layer | OSS | Pro |
|---|---|---|
| Next.js 15 + Compose + Postgres | Yes | Yes |
| Auth.js v5 | Credentials + Google | Magic links + RBAC |
| Stripe | Single plan, credits | 3-tier, portal, team pools |
| Streaming chat | Yes | Yes, plus model picker |
| LangGraph + pgvector + Redis | No | Yes |
| Caddy + Terraform + Prometheus | No | Yes |
That is also the table on the OSS page. The live Pro UI is the production demo.
Where to Go From Here
You do not have to wire every layer from a blank repo.
Option A: Free open-source baseline (MIT)
- GitHub: github.com/Agentic-Packs/agenticpacks-oss
- What is included: Next.js 15, Compose, PostgreSQL 16, Auth.js v5, streaming chat, single-plan Stripe. No Caddy, no LangGraph, no pgvector.
- Cost: free, MIT.
Option B: Ship with AgenticPacks Pro ($149 one-time)
If you want the map as a running codebase:
- Automated Hetzner provisioning: Terraform, Caddy SSL, Compose.
- Production multi-agent core: LangGraph, pgvector RAG, Redis, threaded chat.
- Usage & Unit Economics: Stripe, team pools, token ledger, Prometheus and Grafana.
