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
1 change: 1 addition & 0 deletions specs/epics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ folder is the adoption; the merge creates the epic in the workspace.

| Epic | Cluster | Status | What it is |
|------|---------|--------|------------|
| [`notion-waitlist/`](./notion-waitlist/) | **NW** | In progress (NW0) | Vercel's Next.js Waitlist with Notion CMS — the Next.js waitlist with Notion as CMS — on Cloudflare Workers + Static Assets through OpenNext, with Cloudflare's rate-limit binding for Upstash, Notion's and Resend's keys as Orun secrets, and an Orun baseline that instantiates it (NW2) |

As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`.
11 changes: 11 additions & 0 deletions specs/epics/notion-waitlist/IMPLEMENTATION-STATUS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# notion-waitlist — implementation status

| Milestone | State | Landed |
|---|---|---|
| NW0 — the spec | ✅ | the repository's first commit |
| NW1 — the waitlist on Workers | planned | NW-2 |
| NW2 — a baseline | planned | NW-3 |

## Departures from the upstream template

Recorded as they land, from NW1 on.
35 changes: 35 additions & 0 deletions specs/epics/notion-waitlist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# notion-waitlist — Vercel's Next.js Waitlist with Notion CMS on Cloudflare Workers

**The Next.js waitlist with Notion as CMS built by OpenNext into one
Cloudflare Worker, deployed by Orun to stage and prod on every merge — a
signup saved to a Notion database and welcomed through Resend, rate-limited
per visitor by the Worker's own binding, and a site that serves before its
owner has connected either — and the baseline that makes a copy of it
somebody else's in one landing.**

| | |
|---|---|
| Status | In progress — NW0 on main |
| Upstream | [lakshaybhushan/nextjs-notion-waitlist-template](https://github.com/lakshaybhushan/nextjs-notion-waitlist-template), at `4798588` (2025-06-25) |
| Reference | [portfolio-starter-kit](https://github.com/sourceplane/portfolio-starter-kit) — the same scaffolding, tests and bootstrap; [clerk-auth-starter](https://github.com/sourceplane/clerk-auth-starter) — a SaaS's keys as optional Orun secrets, handed to the Worker by the deploy, and a site that serves before they exist |
| Key | `NW` |

## Read in this order

1. [design.md](design.md) — the template, how each Vercel piece maps to
Cloudflare, the rate limit, the site before Notion and Resend are
connected, the repository and the build, and the alternatives rejected.
2. [implementation-plan.md](implementation-plan.md) — the milestones and
what each one lands.
3. [risks-and-open-questions.md](risks-and-open-questions.md) — what is not
proven, and what was accepted.
4. [IMPLEMENTATION-STATUS.md](IMPLEMENTATION-STATUS.md) — what shipped, and
every departure from the upstream template.

## Milestones

| Milestone | What it lands | Task |
|---|---|---|
| NW0 — the spec | the repository, its intent, CI, tooling and spec index; this doc set | NW-1 |
| NW1 — the waitlist on Workers | the template in `apps/web`, built by OpenNext into one Worker; the rate-limit binding; the Notion and Resend switch; the Worker-secret push; `tests/web` | NW-2 |
| NW2 — a baseline | the console card, the build document, the context pack and the baseline's tests | NW-3 |
90 changes: 90 additions & 0 deletions specs/epics/notion-waitlist/design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# notion-waitlist — design

## The template

[lakshaybhushan/nextjs-notion-waitlist-template](https://github.com/lakshaybhushan/nextjs-notion-waitlist-template)
(`4798588`, the template behind Vercel's "Next.js Waitlist with Notion CMS")
is one Next.js 14 page: a header (a link to a sample Notion database, "Use
this template"), a shimmering "Coming soon!" call to action, a name and
email form, a "Powered by" grid of logos, a footer credit and a canvas of
particles — framer-motion, shadcn/ui, Tailwind 3, sonner toasts. A signup
posts to two route handlers in turn: `/api/mail`, which rate-limits the
visitor's IP with Upstash Redis (two a minute, sliding) and sends a React
Email welcome through Resend, and then `/api/notion`, which adds a page
(`Name`, `Email`) to a Notion database through `@notionhq/client`.

## How each Vercel piece maps to Cloudflare

| Vercel | Cloudflare | Notes |
|---|---|---|
| Next.js on Vercel | `@opennextjs/cloudflare` → one Worker + Static Assets | Next 16.3.8, React 19; `next build --webpack` (Turbopack's per-route server chunks: 2.97 MiB gzipped against Workers Free's 3 MiB; webpack's 1.48 MiB) |
| Upstash Redis `Ratelimit` | Workers Rate Limiting (`SIGNUP_LIMITER` in `wrangler.jsonc`) | Two per sixty seconds per key, a fixed window; both routes; below |
| Project env vars | Orun secrets per environment → Worker secrets | Read per request; below |
| `request.ip` | `CF-Connecting-IP` | Next 15 dropped `request.ip` |
| `next/font/google` | `next/font/local` over `@fontsource-variable/figtree` | Google Fonts at build time fails on GitHub's runners |
| `@vercel/analytics` | — | Vercel-only |
| `app/opengraph-image.png` | the same image in `public/`, named in `metadata` | As a file convention Next compiles each 1.3 MB image into the Worker as a route |

## The rate limit

Upstream limits only `/api/mail`; `/api/notion` writes to the owner's
database for anyone who calls it. Here both routes take the same
`SIGNUP_LIMITER` binding, each with its own count — the key is
`<host>:<route>:<CF-Connecting-IP>` — so one signup (one of each) fits, a
second fits, and a third request to either in a minute is refused (429)
before it reaches Notion or Resend. The host is in the key because a
rate-limit namespace is the account's: two environments, or two products on
one account, never share a visitor's count.

The binding is declared in the committed `wrangler.jsonc`, which the
composition deploys as written (`wrangler deploy --config wrangler.jsonc`);
the lane's own dry run lists it, the end-to-end tier asserts it, and
`/api/health` reports it — so the deploy's smoke fails a Worker that lost it.
Workers Rate Limiting counts per Cloudflare location and is eventually
consistent: a brake on abuse, not an exact quota (risk NW-C).

## Before Notion and Resend are connected

No platform brokers Notion or Resend, so a site is born without them, and
the Resend client the template creates at module load throws without a key —
upstream, every signup would fail. Here each route reads its service's keys
per request (`lib/waitlist.ts`): without them it answers 503 with the names
of the keys it lacks (never a value), and the page's toast says the waitlist
is not connected yet. The page itself never needed them. `/api/health`
reports both, connected or not.

The four keys (`NOTION_SECRET`, `NOTION_DB`, `RESEND_API_KEY`, and
`RESEND_FROM` for the template's hard-coded sender) are optional Orun
secrets the component resolves as `optionalSecretEnv`. The build runs
without them (`env -u`), so no bundle and no build cache holds one, and
`tooling/wire/worker-secrets.mjs` hands those that are set to the Worker as
Worker secrets (`wrangler secret bulk`, the values over stdin) from the
deploy lane only.

The email keeps the template's design and words; what pointed at the
template's author — the sender, the reply-to, the "reply to this email"
mailto and the logo's vercel.app URL — becomes the owner's sender and the
site's own origin.

## The repository and the build

portfolio-starter-kit's shape: `apps/web` (the site), `tests/web` (vitest),
`tooling/` (TypeScript and ESLint configuration, the rename engine, the
bootstrap helpers, the wrangler renderer, the Worker-secret push), one
`intent.yaml` (dev verify-only, stage and prod deployed), `ci.yml` the only
workflow a site carries, and the baseline's own `blueprint.yaml`,
`repo-blueprint.yaml`, `.baseline/`, `testing/` and `baseline.yml`. The
site's name is one seam (`SITE_NAME` in `apps/web/app/site.ts`), its origin
`NEXT_PUBLIC_SITE_URL` per environment.

## Alternatives rejected

- **Keep Upstash Redis as a SaaS.** It would work, and cost a fourth
account and two more secrets for something the Worker's own binding does;
the brief maps it to Workers Rate Limiting.
- **A KV or D1 counter** (ai-emoji-generator's KV counter). Exact across
locations, but a namespace or database to provision for a two-a-minute
brake; the binding needs nothing provisioned.
- **One signup route.** Merging `/api/mail` and `/api/notion` would let one
count cover a signup, but it changes the template's page and its two-step
error messages; two counts keep both.
32 changes: 32 additions & 0 deletions specs/epics/notion-waitlist/epic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# The epic's declaration. metadata.name equals the directory name; metadata.key
# is the task-key prefix this epic reserves (NW → NW-1, NW-2, …). Owner, target
# date and health are the platform's — never written here.
apiVersion: orun.io/v1
kind: Epic
metadata:
name: notion-waitlist
key: NW
spec:
title: "Vercel's Next.js Waitlist with Notion CMS on Cloudflare Workers"
summary: "The Next.js waitlist with Notion as CMS — an animated one-page signup that saves each visitor to a Notion database and sends a React Email welcome through Resend, rate-limited per visitor — runs on Cloudflare Workers + Static Assets through @opennextjs/cloudflare, with Cloudflare's own rate-limit binding for Upstash, Notion's and Resend's keys as Orun secrets and a site that serves before they exist, inside the Cirrus baseline's repository conventions, and becomes an Orun baseline that takes a new site from nothing to live on stage and prod in one landing."
state: started
milestones:
- name: "NW0 — the spec"
exitCriteria:
- "the repository is born with its intent, CI, tooling and spec index, and this doc set and the task contracts are on main"
tasks: [NW-1]
- name: "NW1 — the waitlist on Workers"
exitCriteria:
- "apps/web is the upstream template, built by OpenNext into one Worker with Static Assets"
- "a signup sends the template's welcome through Resend and writes the template's row to Notion; without their keys a signup is told the waitlist is not connected yet and nothing throws"
- "both signup routes take the Worker's own rate-limit binding, two a minute per visitor"
- "no key is in any bundle: the deploy hands them to the Worker as Worker secrets"
- "`pnpm typecheck`, `pnpm lint`, `pnpm test` and `pnpm build` are green, and the Worker fits Workers Free"
- "the README says how to run, test, preview and deploy it, how to connect Notion and Resend, and how every Vercel piece maps to Cloudflare"
tasks: [NW-2]
- name: "NW2 — a baseline"
exitCriteria:
- "blueprint.yaml (the console card) and repo-blueprint.yaml (the build) take a new site from nothing to live on stage and prod in one landing, then record it"
- "a site built from it carries the site only, renamed throughout to its own name, repository and Worker, with the template's credit intact"
- "Baseline CI is green: contract tests, generated component docs, the blueprint read by the pinned orun, the leak gate, the offline bootstrap and the end-to-end tier, not connected and connected to a stand-in of Notion and Resend"
tasks: [NW-3]
48 changes: 48 additions & 0 deletions specs/epics/notion-waitlist/implementation-plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# notion-waitlist — implementation plan

Three milestones, each one reviewed pull request (NW0 is the repository's
first commit), each green before it merges.

## NW0 — the spec (NW-1)

The repository is born: `intent.yaml` with the placeholder workspace
`ws_CHANGE_ME`, `ci.yml` (portfolio-starter-kit's, which plans nothing
until the workspace is set), the shared TypeScript and ESLint configuration,
the spec index, this doc set and the task contracts.

## NW1 — the waitlist on Workers (NW-2)

- The template's `app/`, `components/`, `lib/`, `emails/`, `public/` and
Tailwind configuration in `apps/web`; its dependencies on Next 16.3.8 and
React 19, with `@opennextjs/cloudflare` and `wrangler`; Figtree
self-hosted; the unused and Vercel-only dependencies dropped.
- `next.config.ts` (`output: 'standalone'`, the workspace root, images
unoptimized), `open-next.config.ts` with the static-assets incremental
cache, `wrangler.jsonc` with the `SIGNUP_LIMITER` rate limit, and the
build on webpack.
- `lib/waitlist.ts`: the Notion and Resend switch, the 503 that names what
is missing, the rate-limit key and check; both routes read them;
`/api/health`. The page's toast for a waitlist not connected yet.
- The email: each React Email component from its own package, the sender
`RESEND_FROM`, no reply-to, the logo on the site's origin.
- `SITE_NAME`, `SOURCE_URL` and `SITE_URL` in `app/site.ts`; the metadata
reads them. "Use this template" is the source link.
- `tooling/wire/worker-secrets.mjs`; `component.yaml`: the optional secret
refs, the deploy contract (the origin per environment, the build without
the keys, the secret push) and its smoke. `tests/web`: the identity, the
switch, the rate-limit key, the email, the secret push.
- The README's "How it maps to Vercel".

## NW2 — a baseline (NW-3)

portfolio-starter-kit's machinery, renamed: `blueprint.yaml`,
`repo-blueprint.yaml`, `.baseline/` (identity, the product's README with
"Connect Notion and Resend" and "The rate limit", its `AGENTS.md`, task
contracts), `tooling/rebrand` (the template's repository and demo masked as
credit), `tooling/bootstrap`, `hooks/render-deployment-docs.sh` (probing
`/` and `/api/health`, naming the four keys), `docs/phases/`, the context
pack, `testing/` (the leak and placement gates on this tree's files, the
optional refs and the binding checked in the plan; the e2e tier building and
serving the site not connected, then with made-up keys against a local
stand-in of Notion's and Resend's APIs, then without its binding) and
`baseline.yml` / `tag.yml`.
11 changes: 11 additions & 0 deletions specs/epics/notion-waitlist/risks-and-open-questions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# notion-waitlist — risks and open questions

| ID | Risk | State | Notes |
|---|---|---|---|
| NW-A | `baseline-v1` is not yet proven live | OPEN | Proven offline in Baseline CI: the offline bootstrap with the blueprint's own hooks, the stage lane's own steps in a staged job tree, the site served by `wrangler dev` and smoke-tested with the component's own command — not connected, and connected to a local stand-in. A console bootstrap closes it |
| NW-B | A real signup against Notion and Resend | OPEN | Offline, the stand-in reads back exactly what the two clients send (the page create with the database id, `Name` and `Email`; the email's sender, recipient, subject and HTML), but neither service has answered the Worker, and the first `wrangler secret bulk` on a Worker that does not exist yet has not run live (clerk-auth-starter's CK-B is the same push). Closed by storing the four keys on a live site's stage and signing up once |
| NW-C | Workers Rate Limiting is per location and eventually consistent | ACCEPTED | Cloudflare documents it as permissive: a visitor hitting two locations, or a burst before the count settles, can get past two a minute. Upstash was exact and sliding. For a waitlist it is a brake on abuse; an exact quota would need a KV or D1 counter |
| NW-D | Next 16.3.8, not the template's 14.2.4 | ACCEPTED | OpenNext 1.20 refuses Next 15.5 at build, and every OpenNext starter here is proven on 16.3.8; the template uses nothing Next 14 has that 16 removed but `request.ip` (now `CF-Connecting-IP`) |
| NW-E | No licence file | ACCEPTED | GitHub records none and the repository has no LICENSE; the README's "License" section allows personal and commercial use and modification and asks commercial users to consider supporting the author. The registry lists the row unlisted until its owner decides; the README credits the template by name and link |
| NW-F | `@notionhq/client` 2 bundles node-fetch | WATCH | The client imports node-fetch at load; the routes hand it the Worker's fetch, so node-fetch is never called. The Notion API version stays the client's 2022-06-28, which the template was written against |
| NW-G | The email is in the template author's voice | ACCEPTED | Its words are the template's ("I'm Lakshay…"); the product's README tells the owner to rewrite them. What routed mail to the author (the sender, the reply-to, the mailto) is the owner's now |
15 changes: 15 additions & 0 deletions tasks/NW-1.TaskContract.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: orun.io/v1
kind: TaskContract
metadata:
name: NW-1
title: "The spec"
spec:
goal: The notion-waitlist repository is born with its intent, CI, tooling and spec index, and the notion-waitlist epic — declaration, doc set and task contracts — is on main
affects:
- specs/epics/notion-waitlist
- specs/epics/README.md
- tasks
doneWhen:
- epic.yaml, README, design, implementation plan, risks and status are on main
- the three task contracts exist
gates: []
20 changes: 20 additions & 0 deletions tasks/NW-2.TaskContract.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: orun.io/v1
kind: TaskContract
metadata:
name: NW-2
title: "The waitlist on Workers"
spec:
goal: The Next.js waitlist with Notion as CMS runs on Cloudflare Workers + Static Assets through OpenNext, rate-limits both signup routes with the Worker's own binding, serves before Notion and Resend are connected, keeps their keys out of every bundle, and has its tests and a README that says how it maps to Vercel
affects:
- apps/web
- tests/web
- tooling/wire
- pnpm-lock.yaml
- pnpm-workspace.yaml
- README.md
- .gitignore
doneWhen:
- pnpm typecheck, lint, test and build are green
- wrangler dev serves the page and both routes, without the keys and with them against a stand-in, and refuses a third request a minute
- the Worker is under Workers Free's 3 MiB gzipped
gates: []
29 changes: 29 additions & 0 deletions tasks/NW-3.TaskContract.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: orun.io/v1
kind: TaskContract
metadata:
name: NW-3
title: "notion-waitlist becomes an Orun baseline"
spec:
goal: blueprint.yaml and repo-blueprint.yaml take a new waitlist from nothing to live on stage and prod in one landing, held by Baseline CI
affects:
- blueprint.yaml
- repo-blueprint.yaml
- BOOTSTRAP.md
- .baseline
- .github/workflows/baseline.yml
- .github/workflows/tag.yml
- ai/context
- docs/phases
- hooks
- testing
- tooling/rebrand
- tooling/bootstrap
- tooling/catalog
- apps/web/docs
- tests/web/docs
- specs/epics/notion-waitlist
- README.md
doneWhen:
- every Baseline CI tier is green
- a site placed from it carries the site only, branded, with the template's credit intact
gates: []
Loading