Know when websites change.
WatchThat is a website change monitoring tool. Paste a URL, WatchThat takes a snapshot of the page content, and barks when something changes.
- Next.js 15 — App Router, React Server Components
- TypeScript — strict mode
- Tailwind CSS — utility-first styling + CSS variable theming
- Jest + React Testing Library — TDD enforced via
prebuildhook - Playwright — browser-driven e2e against Vercel previews and prod
- pnpm — package manager
- Supabase — Postgres + Auth + Storage (local via
supabaseCLI, prod on Supabase Cloud) - Sentry — error monitoring, tracing, session replay, and AI span capture for Anthropic calls
- Vercel — zero-config deployment
Prerequisites: Node 20+, pnpm, Docker Desktop, and the Supabase CLI.
pnpm install
cp .env.example .env.local # then fill in your API keys (see below)
supabase start # boots local Postgres + Auth + Storage (Docker)
pnpm dev # http://localhost:3000Copy .env.example to .env.local and fill in:
| Var | Where to get it |
|---|---|
FIRECRAWL_API_KEY |
firecrawl.dev |
ANTHROPIC_API_KEY |
console.anthropic.com |
NEXT_PUBLIC_SUPABASE_URL |
supabase start prints it (local: http://127.0.0.1:54321) |
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY |
supabase start prints it (client-safe) |
SUPABASE_SECRET_KEY |
supabase start prints it (server-only, bypasses RLS — do NOT commit) |
CRON_SECRET |
Random string used to authenticate /api/cron/scrape calls from Supabase pg_cron. Must match the cron_secret entry in Supabase Vault. Generate with openssl rand -hex 32. |
NEXT_PUBLIC_APP_URL |
Optional. Override for the canonical share-link base URL used in OG metadata. Auto-detected from Vercel envs (VERCEL_URL on preview deploys, VERCEL_PROJECT_PRODUCTION_URL on prod), so you typically don't need to set this. Only useful when a custom proxy sits in front of Vercel. |
LANGFUSE_PUBLIC_KEY / LANGFUSE_SECRET_KEY |
Optional. Enable Langfuse LLM observability. Get keys at cloud.langfuse.com. When both are set, every Claude call (describe-change + analyze) is sent as a Langfuse trace with input/output/usage; swipe-dismiss in the UI records a -1 user-dismissed score against the same trace. With either var unset, lib/observability no-ops and nothing leaves the server. |
LANGFUSE_BASE_URL |
Optional. Override the Langfuse endpoint. Defaults to https://us.cloud.langfuse.com. Set to https://cloud.langfuse.com for the EU region or to your self-hosted URL. |
.env.local is git-ignored. For production, set these in Vercel → Project Settings → Environment Variables using your cloud values instead.
Daily dev loop:
supabase start # once per boot — migrations auto-apply
supabase db reset # after editing a migration file
supabase stop # when you're doneStudio (DB browser + SQL editor): http://127.0.0.1:54323
Migrations live in supabase/migrations/. Create a new one with supabase migration new <name>.
| Command | Description |
|---|---|
pnpm dev |
Start dev server |
pnpm build |
Run tests, then production build |
pnpm test |
Run tests in watch mode |
pnpm test:ci |
Run tests once (CI) |
pnpm start |
Start production server |
pnpm e2e:install |
Download Playwright's Chromium (one-time) |
pnpm e2e:smoke |
Run smoke specs against local dev server |
pnpm e2e:full |
Run full specs against local dev server |
pnpm eval |
Run the lib/describe-change prompt eval suite (promptfoo). Uses ANTHROPIC_API_KEY from .env.local. |
pnpm eval:view |
Open the promptfoo result viewer in a browser |
pnpm buildrunsjest --cifirst viaprebuild. A failing test blocks the build.Note for CI/CD: Both
prebuildandtest:ciexplicitly setNODE_ENV=test. This is required because Vercel (and most CI environments) setNODE_ENV=productionbefore the build step, which causes React to load its production bundle — a bundle that doesn't supportact()and will fail all RTL tests.
Tests live in __tests__/ alongside each component. Every component has a corresponding test file. Write tests before (or alongside) new components.
pnpm test # watch mode — runs on file change
pnpm test:ci # single run, exits with codeWhen adding a new component:
- Create
__tests__/MyComponent.test.tsxfirst - Write failing tests for the expected behavior
- Implement the component until tests pass
pnpm buildwill verify tests pass before shipping
Browser-driven tests live in e2e/. Two suites:
smoke/— read-only-ish checks runnable against prod. CI runs them after every production deploy via.github/workflows/e2e-prod-smoke.yml.full/— full mutating suite runnable against a Vercel preview. Firecrawl + Anthropic are stubbed viaE2E_MOCK=1(seelib/firecrawl.tsandlib/anthropic.ts); deterministic page fixtures live behind/api/test-fixture/[v].
Local:
pnpm e2e:install # one-time Chromium download
pnpm e2e:smoke # boots `next dev` with E2E_MOCK=1 and runs @smoke specsPoint at a deployed URL by setting E2E_BASE_URL and dropping the PLAYWRIGHT_LOCAL=1 env (CI does this automatically):
E2E_BASE_URL=https://your-preview.vercel.app pnpm exec playwright test --grep @smokeSee e2e/README.md for the full layout and plans/ for the phased migration plan.
Regression suite for lib/describe-change lives in evals/. Each test case feeds inputs into the real production function (via a custom provider that requires lib/describe-change directly), then asserts on the parsed result — so it exercises prompt construction + Claude's response + our JSON parser as one unit.
pnpm eval # runs locally, ~$0.02/run via Anthropic
pnpm eval:view # opens the promptfoo result viewerCI runs the same suite via .github/workflows/prompt-evals.yml, path-filtered to PRs that touch lib/describe-change.ts, lib/parse-json-response.ts, the fact extractor, the matcher, or evals/**. The workflow needs an ANTHROPIC_API_KEY repo secret.
Adding a case = one entry in evals/promptfooconfig.yaml. The curation rule: every test corresponds to a real failure we've seen. See evals/README.md.
watchthat/
├── app/
│ ├── api/ # Route handlers (scrape, analyze, describe-change, …)
│ ├── developers/ # /developers — platform pitch (devs, agent builders, investors)
│ ├── layout.tsx # Root layout, metadata
│ ├── page.tsx # Home page
│ └── globals.css # CSS variables + Tailwind base
├── components/ # UI components (see files for details)
├── lib/ # App logic (storage, hashing, fixtures)
├── utils/supabase/ # Supabase client factories (browser, server, middleware, service-role)
├── middleware.ts # Refreshes Supabase sessions on every request
├── supabase/
│ ├── config.toml # Supabase CLI config
│ └── migrations/ # Versioned SQL migrations
├── __tests__/ # Component + route tests (Jest + RTL)
├── __mocks__/ # Jest module mocks
├── jest.config.js
├── jest.setup.ts
├── tailwind.config.ts
├── next.config.ts
└── tsconfig.json
Dark/light mode is handled automatically via prefers-color-scheme and CSS custom properties defined in globals.css. No JavaScript required.
See watchthat-prd-trd.md for the full product and technical spec. Short version:
- V1.1 — Labels, URL validation, error retry, favicons
- V1.2 — Browser push notifications, service worker polling
- V2.0 — Backend API, database, automated polling, email/webhook alerts
- V2.1 — CSS selector targeting, Playwright rendering, screenshot diffs
- V2.2 — Tags/folders, bulk import, change history, share links
- V3.0 — Multi-tenant, team workspaces, API access, integrations
Connect the GitHub repo in the Vercel dashboard or run:
npx vercelSet these env vars in Project Settings → Environment Variables (Production): FIRECRAWL_API_KEY, ANTHROPIC_API_KEY, NEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY, SUPABASE_SECRET_KEY — using your cloud Supabase values, not the local ones. Also set:
SENTRY_AUTH_TOKEN(from sentry.io/settings/auth-tokens,project:releases+org:readscopes) so production builds upload source maps.CRON_SECRET— must match the value of thecron_secretentry stored in Supabase Vault (see the auto-refresh setup below). Generate withopenssl rand -hex 32.
First-time setup for your cloud project:
supabase login
supabase link --project-ref <your-project-ref> # from the Supabase dashboard URL
supabase db push # applies all migrations to cloudRe-run supabase db push after creating a new migration. Cloud URL + keys live in Supabase Dashboard → Project Settings → API.
If
supabase db pushreports success but the migration's changes don't actually appear in the cloud DB, the migration tracker may have a stale entry for that file. Force re-application of every migration with:supabase db push --include-allThis bypasses the tracker and re-runs every migration in lexicographic order. Migrations are written to be idempotent (
create or replace,alter table … add column if not exists), so re-running them is safe.
Watched pages are re-scraped in the background on each user's chosen interval (default 24h, floor 1h). The scheduler is a Supabase pg_cron job that fires HTTP POSTs at /api/cron/scrape; that route delegates to /api/scrape so the existing hash / fact-extract / describe-change pipeline handles every refresh identically to a manual ↻ click.
One-time setup after the first supabase db push:
- Generate a secret and store it in Supabase Vault (SQL editor):
select vault.create_secret('<openssl rand -hex 32 output>', 'cron_secret'); select vault.create_secret('https://<your-prod-host>', 'cron_base_url');
vault.create_secret(value, name)— values are encrypted at rest. To rotate later:select vault.update_secret(id, new_value, name)whereidcomes fromselect id from vault.secrets where name = 'cron_secret'. - Set
CRON_SECRETin Vercel → Environment Variables to the same value as thecron_secretVault entry. - (If Vercel Deployment Protection is on) Vercel → Project Settings → Deployment Protection → "Protection Bypass for Automation" → generate a token, then:
The cron function sends this in
select vault.create_secret('<bypass token>', 'vercel_bypass');
x-vercel-protection-bypassso Vercel lets the request through to/api/cron/scrape. Skip if Deployment Protection is off — the function will send an empty header and Vercel will ignore it.
Until both Vault entries exist, the cron function logs a warning and no-ops on every tick — safe to apply the migration before populating Vault.
How it works:
watches.refresh_interval_seconds— per-user choice (default 86400). DB CHECK constraint enforces a 1h floor.pages.next_due_at— when the cron should next scrape this page, maintained by triggers onsnapshots(insert) andwatches(insert/update/delete). NULL when the page has no active watchers.- pg_cron job
refresh-due-pagesruns every 5 minutes. It picks up to 25 due pages (next_due_at <= now()), claims each by pushingnext_due_atforward 10 min (built-in retry window), and firespg_net.http_postto${cron_base_url}/api/cron/scrapewithX-Cron-Secret: ${cron_secret}andx-vercel-protection-bypass: ${vercel_bypass}headers. - The Vercel route validates the secret against
CRON_SECRET(accepts either theX-Cron-Secretheader orAuthorization: Bearer …), looks up the page's URL, and calls/api/scrapeinternally. The snapshot-insert trigger then writes a freshnext_due_atbased onmin(refresh_interval_seconds)across watchers.
Useful diagnostic queries (Supabase SQL editor):
-- Recent cron runs (one row per 5-minute tick)
select jobname, start_time, end_time, status from cron.job_run_details
order by start_time desc limit 10;
-- Recent HTTP POSTs to /api/cron/scrape
select id, status_code, content, created from net._http_response
order by created desc limit 10;
-- Pages currently overdue
select id, url, next_due_at from pages
where next_due_at <= now() order by next_due_at limit 20;Source-available, all rights reserved. The code in this repository is published
for reference, review, and pull-request contribution only — it is not open
source and may not be used, copied, modified, redistributed, hosted as a
service, or trained on without prior written permission. See LICENSE for
the full notice.