How this site's AI works
The chat on this site is a small production system built with the same patterns I use for client work, running on Cloudflare's edge.
What happens when you send a message
-
Human check
Cloudflare Turnstile runs once; the Worker then issues a signed two-hour session token.
-
Guards
Rate limits per session and IP, per-session and daily LLM budgets, and input size caps.
-
Router
A fast Gemini Flash-Lite call classifies intent and catches off-topic or prompt-injection attempts. Off-topic questions get a canned reply without a big-model call.
-
Agent
Gemini with tools, streamed through the Vercel AI SDK. Tools return data from the same content files that build this site, so tables and timelines can't be invented.
-
Telemetry
Structured logs, Analytics Engine metrics, AI Gateway cost tracking, and transcripts with contact details redacted, kept for 30 days.
What happens when you share your details
-
Validate
One zod schema checks the form in your browser and again on the server, alongside Turnstile, a honeypot and duplicate detection.
-
Store
The lead lands in D1 and a Cloudflare Workflow takes over with durable, individually retried steps.
-
Understand
Gemini summarizes the request and scores fit against my real experience, treating your text as data, never as instructions.
-
Reply
Resend emails you a summary and emails me a brief with a draft reply. Idempotency keys prevent double sends; a budget guard respects the free tier.
-
Measure
GA4 receives a server-side qualify_lead event with no personal data, so I can see which pages lead to real conversations.
How I know it behaves
An eval harness replays 45 golden conversations against the live model with deterministic checks and an LLM judge. Off-topic handling, prompt injection, client confidentiality and hallucination traps must pass 100% before a release. The Worker itself has its own test suite for validation, rate limits, sessions and the lead workflow.
Built with
- Astro
- React
- Tailwind
- Motion
- Cloudflare Workers
- D1
- Workflows
- AI Gateway
- Analytics Engine
- Gemini
- Vercel AI SDK
- Resend
- Turnstile
- GA4