From 878c9ad6f86e88bcb37f339aa16d5811226fd8c4 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 28 Oct 2026 23:45:35 +0000 Subject: [PATCH] BA3: ready to instantiate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The README says how to deploy it — link the repository, set the workspace, connect Cloudflare, and every merge applies the database, the namespace and the bucket, migrates and deploys stage then prod — and that nothing needs typing: the auth secret is generated per environment and the sign-in page works without a provider. It says how a custom domain is attached (better-auth follows the request's origin, so sign-in works on it unchanged) and that R2 must be enabled on the account once. The as-built status gains what each claim is proven by. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_019PcpNVpFBcbeiX3EHdXfmn --- README.md | 28 +++++++++++++++++++ specs/epics/README.md | 2 +- .../IMPLEMENTATION-STATUS.md | 15 ++++++++-- specs/epics/better-auth-starter/README.md | 2 +- 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6222793..4afdc12 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,34 @@ pnpm --filter @app/web dev # http://localhost:3000 — the local pnpm --filter @app/web preview # wrangler dev over the built Worker, same local bindings ``` +## Deploying + +The Orun pipeline (`.github/workflows/ci.yml`) plans nothing while +`intent.yaml` names the placeholder workspace `ws_CHANGE_ME`. Link the +repository to an Orun Cloud workspace (`orun cloud link`), set +`execution.state.workspace` to it, connect Cloudflare in the workspace, and +every merge to `main` then applies the D1 database, the KV namespace and the +R2 bucket, migrates the database and deploys `better-auth-starter-web-stage`, +then `-prod`, each smoke-tested on `/api/health`. A pull request verifies the +same lanes and deploys nothing. A manual run of `ci.yml` (Run workflow on +`main`, or Orunbase's Deploy button) redeploys the components it names. + +The deploy needs nothing typed: the auth secret is generated in each +environment's database by the migrations, and the sign-in page works with no +provider. R2 must be enabled on the Cloudflare account once (the dashboard +asks for a payment method even on the free tier); until it is, the R2 root's +apply fails. + +## Custom domain + +The Worker answers on `workers.dev` from its first deploy. To serve it on a +domain of your own, attach the domain to the Worker in Cloudflare (Workers & +Pages → the Worker → Settings → Domains & Routes) and replace +`better-auth-starter.example.com` in `intent.yaml`'s `BASE_DOMAIN`. better-auth +takes the origin each request arrives on, so sign-in works on the new domain +without changing a line; set `BETTER_AUTH_URL` only to pin one origin (an +OAuth app's callback URL must match it). + ## Sign-in providers Anonymous and email-and-password sign-in work with nothing configured. diff --git a/specs/epics/README.md b/specs/epics/README.md index 3a84e2f..15b5a96 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 | |------|---------|--------|------------| -| [`better-auth-starter/`](./better-auth-starter/) | **BA** | In progress (BA2) | zpg6's better-auth-cloudflare OpenNext example — anonymous, email and OAuth sign-in through better-auth, sessions in KV, users in D1, file uploads in R2 — on Cloudflare Workers, and an Orun baseline that instantiates it in one landing | +| [`better-auth-starter/`](./better-auth-starter/) | **BA** | In progress (BA3) | zpg6's better-auth-cloudflare OpenNext example — anonymous, email and OAuth sign-in through better-auth, sessions in KV, users in D1, file uploads in R2 — on Cloudflare Workers, and an Orun baseline that instantiates it in one landing | As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`. diff --git a/specs/epics/better-auth-starter/IMPLEMENTATION-STATUS.md b/specs/epics/better-auth-starter/IMPLEMENTATION-STATUS.md index cb97f34..c08e63c 100644 --- a/specs/epics/better-auth-starter/IMPLEMENTATION-STATUS.md +++ b/specs/epics/better-auth-starter/IMPLEMENTATION-STATUS.md @@ -4,10 +4,21 @@ |---|---|---| | BA0 — the spec | ✅ Shipped | [#1](https://github.com/sourceplane/better-auth-starter/pull/1) | | BA1 — the auth app on Workers | ✅ Shipped | [#2](https://github.com/sourceplane/better-auth-starter/pull/2) | -| BA2 — D1, KV and R2 from Terraform | In progress | | -| BA3 — ready to instantiate | Not started | | +| BA2 — D1, KV and R2 from Terraform | ✅ Shipped | [#3](https://github.com/sourceplane/better-auth-starter/pull/3) | +| BA3 — ready to instantiate | In progress | | | BA4 — a baseline | Not started | | +## What is proven, and how + +| Claim | Proven by | +|---|---| +| The app builds into one Worker within Workers Free's 3 MiB (1,911 KiB gzipped) | `pnpm build` + `wrangler deploy --dry-run` | +| Email sign-up, the session, the redirect to the dashboard, the dashboard, a file through R2 and back, anonymous sign-in | `wrangler dev` over the local D1 after `db:migrate:local` (BA1) | +| The migrations apply into real SQLite through the runner, twice | `tests/db` | +| The providers, the generated secret, the health route, the redirects | `tests/web` | +| The roots are valid Terraform; the plan orders roots → migrations → Worker | `terraform validate`; `orun plan` (BA2) | +| The applies, the migrations and the deploy on a real account | only a live bootstrap (risk BA-F) | + ## Departures from the upstream example 1. **Next.js 16.3.8** (the example: 15.5): the reference starters' toolchain. `middleware.ts` is `proxy.ts` (Next 16's name), its logic unchanged except that it no longer logs each signed-in visitor's city and country. diff --git a/specs/epics/better-auth-starter/README.md b/specs/epics/better-auth-starter/README.md index 656ee28..5030562 100644 --- a/specs/epics/better-auth-starter/README.md +++ b/specs/epics/better-auth-starter/README.md @@ -8,7 +8,7 @@ The port keeps the sign-in page, the dashboard (user, geolocation and file-uploa | Field | Value | |-------|-------| -| Status | In progress — BA0 (#1) and BA1 (#2) shipped, BA2 | +| Status | In progress — BA0 (#1), BA1 (#2) and BA2 (#3) shipped, BA3 | | Cluster | **BA** (BA0–BA4) | | Owner(s) | `apps/web` · `tests/web` · `infra/terraform/cloudflare-{d1,kv,r2}` · `packages/db` + `infra/db-migrate` · `tests/db` | | Builds on | `turso-starter`: its scaffolding, its `cloudflare-d1` root and its migrations runner; `kv-redis-starter`'s `cloudflare-kv` root; `blob-starter`'s `cloudflare-r2` root; `saas-starter`'s generated app secret |