Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ jobs:
echo "── $t"
bash "testing/$t.test.sh"
done
# Every component's docs/{overview,architecture,runbook}.md is generated
# from what the component declares (its manifest, Worker config,
# Terraform, migrations, package scripts). A pull request that changes
# one of those facts without regenerating the pages fails here.
- name: Component docs match their manifests
run: python3 tooling/catalog/gen-component-docs.py --check

# Tier 1. THE BLUEPRINT, READ AND PLACED BY THE BINARY A BOOTSTRAP RUNS.
#
Expand Down
41 changes: 41 additions & 0 deletions ai/context/current.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# supabase-starter β€” where this repository stands

The entry page for anyone (or any agent) picking this repository up. It is
this repository's own state and does not ship to a product built from it; the
two pages that do are [operations.md](operations.md) and
[deployment.md](deployment.md).

## What it is

Vercel's Next.js and Supabase Starter on Cloudflare Workers + Static Assets
(`@opennextjs/cloudflare`), its Supabase project per environment provisioned
by Terraform through Orun, packaged as an Orun baseline: `orun new --blueprint
repo-blueprint.yaml` builds a new product in its own repository and takes it
to live on stage and prod in one landing (`01-product`: supabase β†’ web per
environment), then records what went live (`02-docs`).

## Release

| | |
|---|---|
| Latest tag | `baseline-v2` (SS5 β€” the product's own origin); `baseline-v1` is SS4 |
| On `main` since | SS6 β€” the cirrus standard (no kiox, generated component docs, this context pack) |
| Proven live | No. Nothing has been applied against a real Supabase organization: no Terraform apply, no live deploy, no live bootstrap (risk SS-I). Everything short of the platform is proven offline in Baseline CI, against a local Supabase stand-in |

## Where to read

| Question | Page |
|---|---|
| What shipped, and every departure from upstream | `specs/epics/supabase-starter/IMPLEMENTATION-STATUS.md` |
| Why it is built this way | [decisions.md](decisions.md), then `specs/epics/supabase-starter/design.md` |
| What could still go wrong | [open-risks.md](open-risks.md), then `specs/epics/supabase-starter/risks-and-open-questions.md` |
| How to instantiate it | `BOOTSTRAP.md`, `docs/phases/` |
| What each component is | `apps/web/docs/`, `infra/terraform/supabase/docs/`, `tests/web/docs/` (generated; `python3 tooling/catalog/gen-component-docs.py`) |

## Next

1. Bootstrap one product from the next tag against a workspace with a
Supabase connection, and record its timings β€” the apply, the brokered
token's reach to the API-keys and Auth-config endpoints, a sign-up on the
first deploy (closes SS-I).
2. Cut the next `baseline-vN` with `tag.yml` so the registry can pin SS6.
20 changes: 20 additions & 0 deletions ai/context/decisions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# supabase-starter β€” decisions

The choices that shape this repository, one line each, with where the full
reasoning lives. Superseded decisions stay listed, marked, so the history
reads in order.

| # | Decision | Why | Source |
|---|---|---|---|
| 1 | OpenNext on Workers + Static Assets (`cloudflare-workers-assets-turbo`), no Hyperdrive | The template's SSR, `proxy.ts` and route handlers run in one Worker; it never opens a Postgres connection β€” it speaks PostgREST and GoTrue over HTTPS | `specs/epics/supabase-starter/design.md` Β§2, risk SS-A |
| 2 | The publishable key is a wrangler var, not a secret | It ships to every browser by design; row-level security is the boundary | risk SS-B |
| 3 | `wrangler.jsonc` committed as the fixture render; stage and prod re-render it from `WIRING_SUPABASE_<ENV>`, and `next build` reads the project from it | The composition checks the file exists before the build, and the browser bundle and the Worker must name one project (SS4; SS1 git-ignored it, SS2 fed the build two more secrets) | risks SS-E, SS-F |
| 4 | Terraform points each project's Auth at its Worker, email confirmation off until the project has SMTP | A fresh project emails only its organization, so nobody else could sign up | risks SS-C, SS-G |
| 5 | supabase β†’ web, enforced on a push to `main`, advisory on a pull request; the wiring documents are `optionalSecretEnv` | One convergence provisions then deploys per environment; stage must not wait on prod's document | IMPLEMENTATION-STATUS (SS4), risk SS-H |
| 6 | The tutorial's `notes` table under row-level security keyed on `auth.uid()` | Upstream created it open and then suggested a public-read policy | risk SS-J |
| 7 | One landing (`01-product`) then the record (`02-docs`) | A landing has a fixed cost; the plan, not the phases, carries deploy order (cirrus-baseline since baseline-v22) | `repo-blueprint.yaml`, IMPLEMENTATION-STATUS (SS4) |
| 8 | The origin is baked in at build (`NEXT_PUBLIC_SITE_URL`), and `SITE_URL` is the one setting for the app's links and Auth's Site URL | The pages are prerendered; upstream's `VERCEL_URL` gave `localhost:3000` image links on Cloudflare | IMPLEMENTATION-STATUS (SS5), risk SS-L |
| 9 | `ci.yml` plans nothing while `intent.yaml` names `ws_CHANGE_ME` (its `linked` step), not an `ORUN_CI` repository variable | A bootstrap cannot set a repository variable | IMPLEMENTATION-STATUS (SS4), `.github/workflows/ci.yml` |
| 10 | stack-tectonic 0.19.0, not 0.20.0 | 0.20.0's lane-scoped install is refused by Turbopack | IMPLEMENTATION-STATUS (SS4) |
| 11 | orun is pinned only where it runs (the `orun-action` `version:` in each workflow); no kiox | `kiox.yaml` pinned a version nothing ran | IMPLEMENTATION-STATUS (SS6) |
| 12 | Component docs are generated from the manifests and checked in CI | A hand-written copy of the dependency graph, bindings and published outputs drifts silently | `tooling/catalog/gen-component-docs.py` |
15 changes: 15 additions & 0 deletions ai/context/open-risks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# supabase-starter β€” open risks

What is not yet proven or not yet decided. The full write-up of every risk,
including the accepted and resolved ones, is
`specs/epics/supabase-starter/risks-and-open-questions.md`; this page lists
only what is still live, so it should be short.

| ID | Risk | State | What closes it |
|---|---|---|---|
| SS-I | Unproven against a real organization: no Terraform apply, live deploy or live bootstrap yet β€” so whether the brokered Supabase token reaches the API-keys and Auth-config endpoints, whether a new project still returns a legacy anon key, and the wall-clock are all unknown | OPEN | One bootstrap from a tag against a workspace with a Supabase connection |
| SS-A | `cacheComponents` on OpenNext: the prerendered shells are served from the read-only static-assets cache; a later Next or OpenNext could break the combination | WATCH (mitigated) | Holds while nothing revalidates; dropping `cacheComponents` is the one-line fallback |

Accepted, and worth knowing before you change them: SS-K (the bootstrap floor,
orun v2.58.11, plans `modeRules` as enforced; the product's lane pin reads
them). Settled: SS-D (Node β‰₯ 25 `localStorage` stub; CI builds on Node 22).
27 changes: 27 additions & 0 deletions apps/web/docs/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# web β€” architecture

Built by the turbo pipeline from `apps/web` and deployed with wrangler.

| | |
| ------------------- | ----------------------------------------------- |
| Worker config | `apps/web/wrangler.template.jsonc` |
| Entry | `.open-next/worker.js` |
| Compatibility date | `2026-10-01` |
| Compatibility flags | `nodejs_compat`, `global_fetch_strictly_public` |

## Bindings

| Binding | Kind | Source |
| -------- | ------------- | ------------------- |
| `ASSETS` | Static assets | `.open-next/assets` |

## Variables

`NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY`, `NEXT_PUBLIC_SUPABASE_URL`.

## Wiring

Resolved at deploy time from secrets the infrastructure lanes publish (names only):

- `WIRING_SUPABASE_PROD` (optional)
- `WIRING_SUPABASE_STAGE` (optional)
20 changes: 20 additions & 0 deletions apps/web/docs/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# web

The Next.js + Supabase starter (Next.js on Cloudflare Workers + Static Assets via @opennextjs/cloudflare, per environment)

A Cloudflare Worker with Static Assets (server rendering plus static files), deployed per environment by its CI lane.

| | |
| ------------ | ------------------------------------------------------------------------------------------------------------------ |
| Type | `cloudflare-workers-assets-turbo` |
| Source | `apps/web` |
| Package | `@app/web` |
| Environments | `dev`: `verify` Β· `stage`: `verify`, `deploy` on a push to `main` Β· `prod`: `verify`, `deploy` on a push to `main` |

## Depends on

- **supabase** β€” Provisions Supabase projects for stage and prod, points their Auth at the app, and wires the URL and keys into orun secrets

## Depended on by

- (none)
40 changes: 40 additions & 0 deletions apps/web/docs/runbook.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# web β€” runbook

## How it runs

Pull requests verify it; a merge to `main` deploys it to `stage`, `prod`.
CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`;
the plan orders a component after everything it depends on.

## Local commands

```bash
pnpm --filter @app/web dev
pnpm --filter @app/web build
pnpm --filter @app/web typecheck
pnpm --filter @app/web lint
pnpm --filter @app/web preview
```

## Verify

After a deploy the lane runs this smoke against the environment it
deployed (`ORUN_ENVIRONMENT`); `DEPLOYED_URL` overrides the URL:

```bash
html=$(curl -sfL "${DEPLOYED_URL}/") && echo "${html}" | grep -q 'href="/auth/sign-up"' && health=$(curl -sf "${DEPLOYED_URL}/api/health") && echo "${health}" | grep -q '"ok":true'
```

## Rollback

Revert the commit on `main`. The next convergence applies the previous desired
state; nothing was changed out of band, so there is nothing else to undo.

## Common failures

- **A `WIRING_*` secret is missing at deploy**: an infrastructure lane upstream
has not applied for this environment yet. Within one convergence the plan
runs it first; on its own, re-run that lane.
- **The smoke fails right after a first deploy**: a new workers.dev route can
answer 4xx for a few seconds and the lane retries. A failure that persists
is a regression in the deployed code.
34 changes: 34 additions & 0 deletions infra/terraform/supabase/docs/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# supabase β€” architecture

A `terraform` root at `infra/terraform/supabase/terraform`.

- **State** lives in the Orun Cloud HTTP state backend β€” no local state and
no state bucket to manage.
- **Credentials are brokered per run** from the workspace's provider
connections and resolved by name; none is stored in this repository.
- **Adoption** (`adopt.tf`): when state is empty but the resource already
exists, plan-time import adopts it instead of failing.

## Resources

- `random_password.db_password`
- `supabase_project.this`
- `terraform_data.project_ready`
- `supabase_settings.this`

## Published outputs

Written as job-output secrets on each environment after an apply; deploy
lanes downstream resolve them by name.

| Secret | Terraform output |
| ---------------------- | ------------------- |
| `SUPABASE_PROJECT_REF` | `project_ref` |
| `SUPABASE_DB_PASSWORD` | `database_password` |
| `SUPABASE_DB_URL` | `connection_uri` |
| `WIRING_SUPABASE` | `wiring` |

## Resolved at run time (names only)

- `SUPABASE_ACCESS_TOKEN`
- `TF_VAR_supabaseOrgId`
19 changes: 19 additions & 0 deletions infra/terraform/supabase/docs/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# supabase

Provisions Supabase projects for stage and prod, points their Auth at the app, and wires the URL and keys into orun secrets

Terraform-managed infrastructure, planned and applied per environment by its CI lane.

| | |
| ------------ | ---------------------------------------------------------------------------------------------------- |
| Type | `terraform` |
| Source | `infra/terraform/supabase` |
| Environments | `stage`: `plan-only`, `apply` on a push to `main` Β· `prod`: `plan-only`, `apply` on a push to `main` |

## Depends on

- (none)

## Depended on by

- **web** β€” The Next.js + Supabase starter (Next.js on Cloudflare Workers + Static Assets via @opennextjs/cloudflare, per environment)
20 changes: 20 additions & 0 deletions infra/terraform/supabase/docs/runbook.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# supabase β€” runbook

## How it runs

Pull requests plan it; a merge to `main` applies it to `stage`, `prod`.
CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`;
the plan orders a component after everything it depends on.

## Rollback

Revert the commit on `main`. The next convergence applies the previous desired
state; nothing was changed out of band, so there is nothing else to undo.

## Common failures

- **Provider authentication fails**: the workspace's provider connection is
missing or revoked. Reconnect it in the console; credentials are brokered
from it per run.
- **"Already exists" on a first apply**: state is empty but the resource is
not. `adopt.tf` imports it at plan time; if it still fails, the resource was renamed outside Terraform.
11 changes: 0 additions & 11 deletions kiox.lock

This file was deleted.

6 changes: 0 additions & 6 deletions kiox.yaml

This file was deleted.

12 changes: 1 addition & 11 deletions repo-blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,6 @@ modules:
source: baseline
from: turbo.json
to: turbo.json
- name: root-kiox
mode: copy
source: baseline
from: kiox.yaml
to: kiox.yaml
- name: root-kiox-lock
mode: copy
source: baseline
from: kiox.lock
to: kiox.lock
- name: root-gitignore
mode: copy
source: baseline
Expand Down Expand Up @@ -417,7 +407,7 @@ phases:
await: "One convergence is running per environment: the Supabase project first (five to seven minutes to come up), its Auth pointed at the app, then the app. Nothing is stuck."
done: "{{ .inputs.reponame }} is live on stage and prod β€” {{ .meta.files }} files on main, branded as {{ .inputs.productname }}, sign-up open on its own Supabase project. That took {{ .meta.elapsed }}."
failed: "The product did not come up. The failing lane above names the component β€” supabase or web β€” and the provider's own error is in its log; whatever was provisioned is still there."
modules: [ai-deployment, ai-operations, discovery-roots, github-workflows, rebrand-values, root-gitignore, root-intent, root-kiox, root-kiox-lock, root-package-json, root-pnpm-lock, root-pnpm-workspace, root-readme, root-turbo, supabase, tooling-eslint, tooling-tsconfig, tooling-wire, vscode, web, web-tests]
modules: [ai-deployment, ai-operations, discovery-roots, github-workflows, rebrand-values, root-gitignore, root-intent, root-package-json, root-pnpm-lock, root-pnpm-workspace, root-readme, root-turbo, supabase, tooling-eslint, tooling-tsconfig, tooling-wire, vscode, web, web-tests]
# THE PLATFORM MUST BE ABLE TO SEE THE REPOSITORY BEFORE IT EXISTS. Every
# phase lands a pull request that files under its task, and the platform
# learns of a PR only through the GitHub App installation on the account
Expand Down
2 changes: 1 addition & 1 deletion specs/epics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ folder is the adoption; the merge creates the epic in the workspace.

| Epic | Cluster | Status | What it is |
|------|---------|--------|------------|
| [`supabase-starter/`](./supabase-starter/) | **SS** | πŸ”„ SS5 in review | Vercel's Next.js and Supabase Starter, equivalent in code and function, on Cloudflare Workers with the Supabase project provisioned by Orun β€” and an Orun baseline that instantiates it in one landing (SS4, `baseline-v1`) |
| [`supabase-starter/`](./supabase-starter/) | **SS** | βœ… Shipped (`baseline-v2`); live bootstrap pending | Vercel's Next.js and Supabase Starter, equivalent in code and function, on Cloudflare Workers with the Supabase project provisioned by Orun β€” and an Orun baseline that instantiates it in one landing (SS4, `baseline-v1`) |

As-built β‰  intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`.
Loading
Loading