From 34d0731205c3edd8354780944d43b56e30e11b81 Mon Sep 17 00:00:00 2001 From: Rahul Varghese Date: Thu, 15 Oct 2026 07:37:53 +0530 Subject: [PATCH] SA4: ready to instantiate The as-built status names the PRs, every departure from upstream (the per-request getDb() over the Hyperdrive binding, proxy.ts, the Stripe fetch transport and SubtleCrypto webhook, the dropped PPR keys, the force-dynamic pricing page, the build-time Stripe placeholder, the stripe pin, the jsx rewrite, the relaxed Next 16 lint rules), the versions with their reasons, what was verified (locally under wrangler dev route by route, the offline migration plan, terraform validate, Checks) and what was not (the applies and a live deploy, gated on a linked workspace). The epic is completed. Co-Authored-By: Claude Fable 5.1 Orun-Task: SA-5 --- specs/epics/README.md | 2 +- specs/epics/saas-starter/IMPLEMENTATION-STATUS.md | 2 +- specs/epics/saas-starter/README.md | 4 ++-- specs/epics/saas-starter/epic.yaml | 2 +- specs/epics/saas-starter/implementation-plan.md | 10 +++++----- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/specs/epics/README.md b/specs/epics/README.md index edb7249..8bb574b 100644 --- a/specs/epics/README.md +++ b/specs/epics/README.md @@ -7,6 +7,6 @@ folder is the adoption; the merge creates the epic in the workspace. | Epic | Cluster | Status | What it is | |------|---------|--------|------------| -| [`saas-starter/`](./saas-starter/) | **SA** | Draft | Vercel's Next.js SaaS Starter, equivalent in code and function, on Cloudflare Workers with Supabase Postgres through Hyperdrive | +| [`saas-starter/`](./saas-starter/) | **SA** | ✅ Shipped | Vercel's Next.js SaaS Starter, equivalent in code and function, on Cloudflare Workers with Supabase Postgres through Hyperdrive | As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`. diff --git a/specs/epics/saas-starter/IMPLEMENTATION-STATUS.md b/specs/epics/saas-starter/IMPLEMENTATION-STATUS.md index 7a48d5b..df2774a 100644 --- a/specs/epics/saas-starter/IMPLEMENTATION-STATUS.md +++ b/specs/epics/saas-starter/IMPLEMENTATION-STATUS.md @@ -129,7 +129,7 @@ template is kept as written rather than edited to satisfy the linter. `getUser()` logs `connection attempt failed` and `/api/user` answers 500: the query went through `env.HYPERDRIVE` to `localhost:54322`, where nothing was listening — the binding path, exercised. -- CI: `Checks` green on #2, #3, #4 and #5. +- CI: `Checks` green on #2, #3 and #4 (#5 is documentation). - Not verified: an apply of either Terraform root, a `db-migrate` apply, a live deploy and a checkout against a real Stripe account — all need the product linked to an Orun workspace with Supabase and Cloudflare diff --git a/specs/epics/saas-starter/README.md b/specs/epics/saas-starter/README.md index 1eb4f04..ab8e8a4 100644 --- a/specs/epics/saas-starter/README.md +++ b/specs/epics/saas-starter/README.md @@ -8,7 +8,7 @@ The upstream code stays the code: the Drizzle schema and queries, the server act | Field | Value | |-------|-------| -| Status | Draft | +| Status | ✅ Shipped — SA0–SA4 landed (#1–#5); the Supabase and Hyperdrive applies, the db-migrate apply and a live deploy are gated on a linked workspace | | Cluster | **SA** (SA0–SA4) | | Owner(s) | `apps/web` (the app) · `packages/db` (the migrations and their runner) · `tests/web`, `tests/db` · `infra/terraform/supabase`, `infra/terraform/cloudflare-hyperdrive`, `infra/db-migrate` | | Builds on | `lumen` conventions — the `supabase` and `cloudflare-hyperdrive` Terraform roots, `@saas/db` + `db-migrate`, the per-request `postgres` client; `cirrus-baseline` conventions for the repository shape | @@ -16,7 +16,7 @@ The upstream code stays the code: the Drizzle schema and queries, the server act | Changes | Adds the Workers build, the monorepo wrapper, tests, the migrations package, the three infra components and the deploy contract; in the template's code: `lib/db/drizzle.ts` (per-request client), `middleware.ts` → `proxy.ts`, the Stripe client's fetch transport and the webhook's async signature check | | Decisions locked | (1) OpenNext on Workers + Static Assets. (2) Drizzle over a Postgres socket through Hyperdrive, not PostgREST and not D1. (3) A `postgres` client per request — never a module-level pool. (4) `wrangler.jsonc` rendered per environment from the Hyperdrive wiring document; never committed. (5) drizzle-kit stays for local development; the runner applies in CI. (6) `AUTH_SECRET`, `STRIPE_SECRET_KEY`, `STRIPE_WEBHOOK_SECRET` are Worker secrets set once per environment; `BASE_URL` is a wrangler var. | | Gate | SA1 is the first user-visible rung. SA2 and SA3 need a workspace with Supabase and Cloudflare connections to apply; they are verified by `plan` and `terraform validate`. | -| Shipped as | — | +| Shipped as | `main` after [#5](https://github.com/sourceplane/saas-starter/pull/5); verified locally under `wrangler dev` with the fixture config and a throwaway `.dev.vars` | ## Read order diff --git a/specs/epics/saas-starter/epic.yaml b/specs/epics/saas-starter/epic.yaml index 8c9184a..b26b0fd 100644 --- a/specs/epics/saas-starter/epic.yaml +++ b/specs/epics/saas-starter/epic.yaml @@ -9,7 +9,7 @@ metadata: spec: title: "Vercel's Next.js SaaS Starter on Cloudflare Workers with Supabase Postgres through Hyperdrive" summary: "The Next.js SaaS Starter — Postgres through Drizzle, Stripe Checkout, Customer Portal and webhooks, email/password auth with a jose JWT in a cookie, a session-refreshing middleware, teams with roles, invitations and an activity log — runs on Cloudflare Workers + Static Assets through @opennextjs/cloudflare. Its Postgres is the Supabase project's database reached through Cloudflare Hyperdrive, both provisioned by Terraform through Orun (the Lumen baseline's roots), and its schema is applied by Orun's db-migrate component from the drizzle-kit SQL the template ships. The code stays the code: the one departure is the per-request database client the Workers runtime forces." - state: draft + state: completed milestones: - name: "SA0 — the spec" exitCriteria: diff --git a/specs/epics/saas-starter/implementation-plan.md b/specs/epics/saas-starter/implementation-plan.md index b343845..23396ad 100644 --- a/specs/epics/saas-starter/implementation-plan.md +++ b/specs/epics/saas-starter/implementation-plan.md @@ -3,7 +3,7 @@ Milestones land in order; each task is one pull request on an `orun/SA-n-` branch with an `Orun-Task: SA-n` trailer. -## SA0 — the spec +## SA0 — the spec ✅ This doc set, `epic.yaml` and the task contracts, merged to `main`. @@ -11,7 +11,7 @@ This doc set, `epic.yaml` and the task contracts, merged to `main`. - the five documents and `epic.yaml` are on `main` - `tasks/SA-1..SA-5.TaskContract.yaml` exist -## SA1 — the app on Workers +## SA1 — the app on Workers ✅ `apps/web` is the upstream template with the Workers build around it: `lib/db/drizzle.ts` exports `getDb()` (a `postgres` client + Drizzle per @@ -28,7 +28,7 @@ session, the proxy and the webhook route. - `wrangler dev` answers `/` with the marketing page and `/sign-in` with the form, and `/dashboard` with a 307 to `/sign-in` when signed out - the diff against upstream is the forced set and nothing else -## SA2 — the schema through db-migrate +## SA2 — the schema through db-migrate ✅ `packages/db` (`@saas/db`) is Lumen's migration runner with the template's drizzle-kit SQL as `010_saas_starter_schema/up.sql`, listed in @@ -41,7 +41,7 @@ the offline plan. - `node packages/db/dist/runner/cli.js plan --env stage` lists both migrations as pending (offline) - `tests/db` is green; the component's `path` and `dependsOn` are Lumen's -## SA3 — Supabase and Hyperdrive from Terraform +## SA3 — Supabase and Hyperdrive from Terraform ✅ `infra/terraform/supabase` provisions a project per environment and publishes its credentials; `infra/terraform/cloudflare-hyperdrive` creates @@ -55,7 +55,7 @@ the Hyperdrive config over that database and publishes - the component's `secretEnv` keys match the roots' `secretOutputs` - the fixture's wiring keys match the template's tokens (`wire:fixture` renders) -## SA4 — ready to instantiate +## SA4 — ready to instantiate ✅ README (local development with the Supabase CLI or any Postgres, the seed, Stripe, the Worker secrets; test, preview, deploy), `IMPLEMENTATION-STATUS.md`