Demo site¶
The invite-only demo at wfheaven.app is a Cloudflare Worker with static
pages, in the demo/ folder
(ADR 0011). Phases 1 to
3 are live since 2026-12-05
(Demo site plan):
- Upload and feedback. A tester opens a personal invite link, uploads a CV, and gets Claude's draft profile, remarks, and questions.
- Sign-up and daily picks. The tester chooses countries, AI-training gigs, and a minimum salary, confirms an email address, and gets daily picks from the daily run, with an unsubscribe link in every email (ADR 0013).
- The follow-up chat. On the feedback screen, the tester answers Claude's questions and tunes the profile before signing up (ADR 0014).
What's in the folder¶
| Path | What it does |
|---|---|
public/ |
The screens: index.html holds landing and upload, feedback with the character sheet, sign-up, and the inbox screen. confirm.html and leave.html are the pages the email links open. Plain HTML, CSS, and JavaScript, with self-hosted fonts and security headers in _headers. countries.json lists the countries the ranker knows, made from collector/places.py. |
src/index.ts |
The Worker: answers /api/* and /leave, and serves public/ for everything else |
src/signup.ts |
Sign-up, sending the link again, confirming, and unsubscribing |
src/email.ts, src/tokens.ts |
The confirmation email, sent with Resend; random tokens, hashes, and the signed unsubscribe link |
src/access.ts |
Who may upload, and how many. The only place that reads INVITE_REQUIRED. |
src/claude.ts |
The call to Claude that drafts the profile, with the prompt in profiler/prompt.json |
src/chat.ts |
The follow-up chat: the message counter, the call to Claude with profiler/chat_prompt.json, and the "Sheet updated" lines |
src/cv.ts, src/docx.ts |
Turn the upload into a content block: a PDF as a document, a .docx or .txt file as text |
src/turnstile.ts |
Checks the bot-check token with Cloudflare |
migrations/ |
The D1 tables: invite codes and upload counters (0001); testers and the jobs sent to them (0002); chat message counters (0003) |
scripts/create-invites.ts |
Creates invite codes and prints the links |
test/ |
Tests, with fakes for D1, Claude, Turnstile, and Resend |
The prompt, the JSON schema, the model, and the token limit are in
profiler/prompt.json, which the
CV prototype reads too. Both always ask Claude the same
thing. The chat's prompt, schema, and model are in
profiler/chat_prompt.json, next to it.
How a CV is handled¶
The Worker answers two requests:
POST /api/accesswith{"invite": "CODE"}: whether the page shows the upload card. It's a POST, so the code stays out of the request address, which Cloudflare's logs record.POST /api/draft: the CV, the consent box, the invite code, and the Turnstile token, as a form.
For each upload, /api/draft checks, in this order, and stops at the first
problem:
- The demo is open (
DEMO_OPEN), and every secret is set. - The consent box is ticked.
- Turnstile's token is valid.
- The file is a PDF,
.docx, or.txtfile of at most 5 MB, and has text. - The limits: 30 CVs a day in total, and 3 per invite code. Each counter goes up in one database statement that fails at its limit, so two uploads at once can't pass it.
Only then does it call Claude. If the call fails before Claude answers, the upload is given back. A refusal keeps it counted.
The CV is read into the request's memory, sent to Claude, and dropped when the request ends. Nothing writes it to D1, a file, or a log. The log has one line per upload, with counts and an error code only:
{"event":"draft","ok":true,"mode":"invite","ms":1661}
How the chat works¶
With the draft, /api/draft returns a random chat token. The page shows
Claude's first question in the Tune your profile chat. Each message,
typed or a suggested answer, sends POST /api/chat with the token, the
current draft, the conversation so far, and the message, as JSON. The
Worker checks, in this order, and stops at the first problem:
- The demo is open, and every secret is set.
- The request is at most 64 KB, the message 1 to 500 characters, and the draft has at least one target title.
- The chat token is known and less than a day old.
- The draft has messages left:
CHAT_MESSAGES_PER_PROFILE, 20.
Only then does it call Claude, with claude-haiku-5-5. Claude gets the
profile, the questions, the last 40 turns, and the message, never the CV.
It answers with the whole profile after its changes, a reply, the next
question, and up to three suggested answers. The Worker keeps only the
fields the sheet shows (target roles, skills, languages, the words under
Never show me, and years of experience), cleans them like the first draft, and lists the
changes for the Sheet updated note. If the call fails before Claude
answers, the message is given back.
The page keeps the conversation in memory only. Undo puts the sheet back as it was before the latest change, without calling Claude, and the next message tells Claude about it. The updated profile is what sign-up sends.
D1 stores one row per draft, in the chats table: the SHA-256 hash of the
token, the message count, and an expiry. Expired rows are deleted at the
next upload. The log has counts only:
{"event":"chat","ok":true,"changes":1,"ms":1840}
How sign-up works¶
The sign-up screen sends POST /api/signup with the draft profile, the
countries, the AI-training choice, the minimum salary, the email address,
the consent box, the invite code, and a Turnstile token, as JSON. The Worker
checks, in this order:
- The demo is open, and Resend's key (or
MOCK_EMAIL) and every other secret are set. - The consent box is ticked, and the Turnstile token is valid.
- The profile: 1 to 10 countries from
countries.json, anai_trainingvalue, and a salary from 0 to 10 million. The draft is cleaned the same way as Claude's answer, and stored in the profile format that the ranker reads. - The email address looks like one.
- If the address is already active, it answers as if it worked and sends nothing, so nobody can find out who is a tester.
- At most
MAX_TESTERStesters, pending and active together. - The limit:
SIGNUP_EMAILS_PER_CODEconfirmation emails per invite code, and only for a code that has drafted a profile. In public mode, the same number per visitor a day.
Then it stores the tester as pending, with the SHA-256 hash of a random
confirmation token, and sends the confirmation email. If Resend fails, the
email is given back to the limit. An unconfirmed sign-up is deleted after 7
days.
The email links work like this (ADR 0013):
| Request | What it does |
|---|---|
POST /api/resend |
"Send it again" on the inbox screen: a new link, counted against the same limit |
GET /confirm#TOKEN |
A page with a Confirm my email button. Opening it changes nothing. |
POST /api/confirm |
The button: makes the tester active, within 24 hours |
GET /leave#ID.SIGNATURE |
A page that unsubscribes as it opens |
POST /api/leave |
Deletes the tester and the jobs sent to them |
POST /leave?t=ID.SIGNATURE |
The same, for the mail app's one-click unsubscribe button (RFC 8058) |
Tokens are in the part after #, which browsers never send, so they stay
out of Cloudflare's request logs. The unsubscribe link works even when the
demo is closed. Every request writes one log line with counts and an error
code only, never an email address, token, or profile:
{"event":"signup","ok":true,"ms":30}
Settings¶
In wrangler.jsonc, under vars:
| Setting | Default | What it does |
|---|---|---|
INVITE_REQUIRED |
true |
true: an invite code is needed. Anything but exactly false keeps the check on. See Going public. |
DEMO_OPEN |
true |
false closes uploads, without a deploy |
CVS_PER_CODE |
3 |
CVs per invite code |
CVS_PER_DAY |
30 |
CVs a day, across all codes |
CVS_PER_IP |
3 |
CVs a day per visitor, only when INVITE_REQUIRED is false |
MAX_UPLOAD_BYTES |
5242880 |
5 MB |
MOCK_CLAUDE |
false |
true returns a fictional draft, and fictional chat answers, instead of calling Claude |
CHAT_MESSAGES_PER_PROFILE |
20 |
Chat messages per draft profile. The page says 20, so change the text with it. |
TURNSTILE_SITE_KEY |
empty | Turnstile's public site key. Empty keeps the demo closed. |
SIGNUP_EMAILS_PER_CODE |
3 |
Confirmation emails per invite code, or per visitor a day in public mode |
MAX_TESTERS |
20 |
Testers, pending and active together |
EMAIL_FROM |
WFHeaven <picks@wfheaven.app> |
The confirmation email's sender |
SITE_URL |
https://wfheaven.app |
The address in the email's links |
MOCK_EMAIL |
false |
true prints the confirmation link in the log instead of sending the email. For the local preview only. |
Secrets, set with npx wrangler secret put NAME, never in a file in git:
| Secret | What it is |
|---|---|
ANTHROPIC_API_KEY |
A key from the wfheaven-demo workspace, which has a USD 5 monthly spend limit |
TURNSTILE_SECRET_KEY |
The Turnstile widget's secret key |
IP_HASH_KEY |
Only when INVITE_REQUIRED is false: a random string for the per-visitor counter |
RESEND_API_KEY |
A Resend key with sending access, limited to the wfheaven.app domain |
UNSUBSCRIBE_KEY |
A random string that signs unsubscribe links. The GitHub secret of the same name must hold the same value. |
If a secret is missing, the demo stays closed instead of running without it.
Preview the site locally¶
You need Node.js. No Cloudflare account, API key, or internet connection to Claude is needed: the preview uses a fictional draft and Turnstile's test keys.
-
Install the packages and copy the local settings:
cd demo npm install cp .dev.vars.example .dev.vars -
Create the local database and an invite link:
npm run db:local npm run invite -- --local -
Start the preview, and open the link the script printed:
npm run dev
The Turnstile box shows a "For testing only" label: that's the test key, and it always passes.
To try sign-up, apply the migrations with npm run db:local again after
pulling Phase 2. With MOCK_EMAIL=true, no email is sent: the terminal
running npm run dev prints the confirmation link instead. To make an
unsubscribe link for a local tester, use leave_token in
daily/daily_run.py with local-preview-only, the key in
.dev.vars.example.
To try real Claude locally, set MOCK_CLAUDE=false in .dev.vars, and
paste the demo workspace's key after ANTHROPIC_API_KEY= yourself. Git
ignores .dev.vars, and the pre-commit hook blocks it. Each upload then
costs about USD 0.03.
Create invite links¶
npm run invite -- --remote --count 5
The script makes random 12-character codes, stores only their SHA-256
hashes in D1, and prints one link per code, such as
https://wfheaven.app/?invite=K7QM-2XRP-9TWD. Copy the links then: they
can't be shown again. Options: --days (30), --max (3 CVs), and --note,
a label for you, never a tester's name.
A link that's unknown, expired, or used up shows the same note as no link: "WFHeaven is in a private demo. Ask Gergely for an invite link."
Deploy¶
Do these steps yourself, once:
- Sign in:
npx wrangler login. It opens a browser. -
Create the database in the EU. The jurisdiction can't be changed later:
npx wrangler d1 create wfheaven-demo --jurisdiction euPut the
database_idit prints intowrangler.jsonc. It isn't a secret. -
Create the tables:
npx wrangler d1 migrations apply DB --remote. - In the Cloudflare dashboard, add a Turnstile widget for
wfheaven.app. Put its site key intoTURNSTILE_SITE_KEYinwrangler.jsonc. The site key is public. The widget's secret key is a separate value, shown on the widget's settings page; you need it in step 6. - Create the Anthropic API key. In the Claude Console, at
platform.claude.com, go to Settings > API keys > Create key, and choose:- Workspace:
wfheaven-demo, the workspace with the spend limit - Expiry: a custom date about 90 days ahead
- Linked account: yourself. When you rotate the key, a service account is an option instead.
- Workspace:
-
Set the secrets. Each command asks for the value, so it never appears in the shell history:
npx wrangler secret put ANTHROPIC_API_KEY npx wrangler secret put TURNSTILE_SECRET_KEYPaste a secret only at the prompt
Paste a secret only at the
wrangler secret putprompt: never in a chat, a file, or a commit. If a secret lands anywhere else, revoke it and create a new one. -
Deploy:
npx wrangler deploy. It attacheswfheaven.appas a custom domain and creates its DNS record. The domain must have no otherA,AAAA, orCNAMErecord at its root. - Create invite links with
--remote, and test with a fictional CV on a computer and a phone. - In the dashboard, check the Worker's CPU time for an upload. The free plan allows 10 ms; waiting for Claude doesn't count.
Measured on the live site on 2026-12-05, with npx wrangler tail: an upload
used 7 ms of CPU time, but the first upload after the deploy used 18 ms. The
whole upload took about 8 seconds, almost all of it waiting for Claude.
Cloudflare doesn't stop every request that goes over 10 ms, but at that level
an upload can fail with error 1102
(An upload fails with error 1102). If
testers report that something went wrong, check the Worker's errors in the
dashboard first. The fix is the Workers Paid
plan, USD 5 a month, or less work in the Worker.
Deploy Phase 2¶
Do these steps yourself, in this order:
- In Resend, verify
wfheaven.app(done on 2026-12-05), and create two keys with Sending access limited to that domain: one for the Worker and one for GitHub. - Make two random strings, for example with
openssl rand -hex 32: one forUNSUBSCRIBE_KEYand one forWFHEAVEN_HASH_KEY. Keep them in your password manager. - In Cloudflare, create an API token with the D1 Edit permission for your account, for the daily run. Your account ID is on the Workers overview page.
- Create a free Himalayas API key at himalayas.app.
-
Set the Worker's secrets:
npx wrangler secret put RESEND_API_KEY npx wrangler secret put UNSUBSCRIBE_KEY -
Set the repository's secrets for the daily run. Each command asks for the value:
gh secret set RESEND_API_KEY gh secret set UNSUBSCRIBE_KEY gh secret set WFHEAVEN_HASH_KEY gh secret set CLOUDFLARE_API_TOKEN gh secret set CLOUDFLARE_ACCOUNT_ID gh secret set HIMALAYAS_API_KEYUNSUBSCRIBE_KEYmust be the same value as the Worker's.RESEND_API_KEYreplaces the old key, which could only send to your own address. -
Apply the new tables:
npx wrangler d1 migrations apply DB --remote. - Deploy:
npx wrangler deploy. -
Add yourself as the first tester, from the repository's root:
python3 daily/add_tester.py --remoteIt asks for your email address, so it never appears in the shell history, and stores
profiles/gergely.yamlas an active tester with themaintainerrole. Run it again after you change the profile. -
On GitHub, run Daily collection in
test emailmode. Check that the email arrives frompicks@wfheaven.app, with an unsubscribe link at the bottom. Don't click the link: it deletes your tester row at once. Run step 9 again if you do. - Delete the old
WFHEAVEN_TO_EMAILsecret:gh secret delete WFHEAVEN_TO_EMAIL. - Try a sign-up with a second address of your own, confirm it, and unsubscribe.
Deploy Phase 3¶
- Apply the new table:
npx wrangler d1 migrations apply DB --remote. - Deploy:
npx wrangler deploy. No new secret is needed: the chat usesANTHROPIC_API_KEY. - With your own invite link, upload a fictional CV and send a few chat
messages: an answer, a suggested answer, Skip, and a change such as
add Notion to my skills. Check that each change shows on the sheet, and that Undo works. - Measure the CPU time of a chat message, like Phase 1's upload: run
npx wrangler tail --format jsonwhile you send a message, and read thecpuTimeof the/api/chatrequest. The free plan allows 10 ms; waiting for Claude doesn't count. - In the Claude Console, check the usage of one message against ADR 0014's estimate.
Measured on the live site on 2026-12-05, with npx wrangler tail: two chat
messages used 5 ms and 2 ms of CPU time, well under the 10 ms limit. Each
took 4 to 5 seconds, almost all of it waiting for Claude. The upload before
them, the first after the deploy, used 16 ms, like Phase 1's first upload,
so the upload stays the request to watch.
Going public¶
The demo can become a public site by changing one setting,
INVITE_REQUIRED, to false, and setting the IP_HASH_KEY secret. Then:
- No invite code is needed, and the page shows the upload card to everyone.
- Each visitor gets
CVS_PER_IPCVs a day instead ofCVS_PER_CODEper code. The IP address is stored only as an HMAC withIP_HASH_KEY, and rows from earlier days are deleted. - The
CVS_PER_DAYcap and the Anthropic spend limit stay. - Confirmation emails are limited per visitor instead of per code, with
the same
SIGNUP_EMAILS_PER_CODEnumber.
Before switching, follow Milestone 3 in the roadmap: the privacy notice and every source's terms need a review for a public service.
Run the tests¶
cd demo
npm run typecheck
npm test
The tests use Node's built-in SQLite with the real migrations for D1, a fake Claude client, and a fake Turnstile. They never call Claude or Cloudflare. They check, among others, that:
- the limits hold: 3 CVs per code, 30 a day, and per visitor in public mode
- every refusal stops before Claude is called
- the database holds no CV text, and the log holds no CV, invite code, or IP address
- the request to Claude uses the shared prompt file
- the invite script stores only hashes, and its links work with the Worker
- sign-up refuses a missing box, a bad profile, and a used-up limit before any email is sent, and gives the limit back when Resend fails
- a confirmation link works once and only within 24 hours, an unsubscribe link with a wrong signature does nothing, and unsubscribing deletes the tester and the jobs sent to them
- an unsubscribe link made by the daily run's Python code works in the Worker
- the chat allows 20 messages per draft, refuses an unknown, expired, or malformed request before Claude is called, and gives a message back when the call fails
- the chat never sends the CV, stores and logs no message or profile, and can change only the fields the sheet shows
CI runs them on every pull request, in the demo job of tests.yml.