A static portfolio.
A working backend.
This portfolio serves static HTML from Cloudflare Pages and sends project inquiries to a separate Cloudflare Worker. The Worker validates requests and stores accepted inquiries in a D1 database.
Portfolio of Mohammad Saif Khan · Technical notes prepared with AI assistance from the repository implementation. This article describes the code, not a performance benchmark.
From contact form to stored inquiry
- The visitor enters their name, email, budget and project brief and gives consent.
- The browser sends the inquiry and a Turnstile verification token to the Worker.
- The Worker checks the permitted origin, request fields, rate limit and verification result.
- An accepted inquiry is written to D1 using parameterized SQL. The API returns a reference to the browser.
The static website does not hold database credentials or the admin key. Public browser configuration contains only the API address and public verification site key.
Validation belongs on the server
Browser validation helps visitors fill the form, but the Worker also checks field lengths, email format, consent and a honeypot field. Turnstile verification happens server-side and checks the hostname and inquiry action. CORS limits browser access to configured origins; it is not a replacement for authentication or spam protection.
Handling retries without duplicate inquiries
The request includes a unique submission reference. The Worker stores a fingerprint of the submitted fields alongside that reference. A retry with the same reference and content returns the existing result. Reusing the reference with different content returns a conflict, rather than silently accepting a changed request.
A small, private inquiry dashboard
The admin API requires an admin token. It lists inquiries in pages and supports new, contacted and completed statuses. The dashboard can update a status or delete an inquiry. Reply links open an email application; this system does not automatically send email notifications.
The decisions and their limits
- Separate frontend and API: static content can deploy independently, but allowed origins and verification hostnames must match the actual site.
- Simple admin authentication: a shared admin token keeps the dashboard small. It does not provide individual staff accounts or role-based permissions.
- Serverless storage: D1 stores inquiries without a dedicated application server. Service quotas and operational monitoring still matter.
- Explicit failure states: rejected or unavailable submissions should offer a useful error and an alternative contact method. A successful browser interaction alone does not prove database delivery.
Inspect the implementation
The public repository contains the Worker, SQL migration and automated backend tests. Screenshots of private inquiries and credentials are intentionally excluded from these notes.
Discuss a web application ↗