LEARNING

A lead-capture site for a study-abroad consultancy

A mail outage can't lose a lead.

Role
Sole developer (10 of 10 commits), freelance client project
Context
Client
When
Jun-Nov 2026
Status
Live on the client's domain, checked 26 Nov 2026
Reading time
3 min read

a study-abroad consultancy

Details anonymised

Mine: Started from a scaffold tool; then content, lead pipeline, admin and deploy.

Built with: React 19, TypeScript, Vite, Tailwind CSS, Supabase (Postgres), Resend, Cloudflare Workers

A study-abroad consultancy's contact page: a large heading offering free counselling for a medical degree, the line under it blurred, above an enquiry form filled with fixture data.

At a glance

  • The lead is saved and emailed at the same time, so either path alone keeps it.
  • The visitor is asked to retry only when both paths fail, with the form still filled in.
  • A scheduled insert every two days keeps the free database from pausing.

The problem

The consultancy helps Indian students apply for medical degrees abroad. Its website has one job: turn a visit into an enquiry the team can call back. A lost enquiry is a student who may not try again. The database runs on a free tier that pauses after seven days without activity, and the email service can fail on its own.

What I built

The site started from a scaffold tool. From there I handled the content and the university listings, built the enquiry pipeline and an admin page for working through enquiries, and deployed it on Cloudflare Workers.

The enquiry form checks every field in the browser with a Zod schema and shows each error beside its field. A destination card can open the form with its university already chosen. On submit, two things start at once: the lead is saved to Postgres, and a server function emails it to the consultancy through Resend. Each has its own timeout, 10 seconds for the save and 15 for the email, so a hung service cannot leave the form stuck on “Submitting”.

Study-abroad site: how a lead is kept. The lead is saved and emailed at the same time, so either path alone keeps it. The visitor is asked to retry only when both fail.

Solid: rules · Dashed fence: model · Diamond: gate · Cyan: data

How it flows

  1. A visitor fills in the enquiry form, and its fields are checked in the browser before anything is sent.
  2. The lead is saved to Postgres and emailed to the consultancy at the same time. Neither waits for the other.
  3. Each path has its own timeout, so a hung service cannot leave the form stuck on its sending state.
  4. If either path lands, the visitor is thanked. A mail outage alone never loses the lead.
  5. Only when both paths fail is the visitor asked to try again, with everything they typed still in the form.
The enquiry form on a desktop screen, filled with fixture data: name, email, phone, city, destination, university and a message. The line under the button is blurred out.
Fixture data

The admin email escapes every field the visitor typed. When a send fails, the browser gets a short reason code, never the mail provider’s own error.

Key decisions

Save and email at the same time

Alternative rejected
Save first, then send the email in the background (the first version)
Why
In the first version the email went out only after a successful save, so a paused or failing database lost the enquiry outright. Side by side, either path alone keeps it.

Ask for a retry only when both paths fail

Alternative rejected
Show an error whenever either path fails
Why
If the save worked but the email did not, the enquiry is already safe. An error would invite a second, duplicate submission.

Keep the free database awake on a schedule

Alternative rejected
A paid plan, or hoping for steady traffic
Why
A free project pauses after seven days without activity. A GitHub Actions job inserts one row every two days, so even two missed runs stay under the limit.

How it was proven

The failure case is the one that matters. For this write-up the site ran locally with fixture data and no mail key, so the email step failed on every submit, while a stand-in database answered the save. The visitor still saw the thank-you message and the form reset, as the phone screenshot shows.

On a phone, the thank-you message above the cleared form, after a fixture enquiry sent with the email step failing and the save answered by a stand-in database.
Fixture data

When both paths fail, the code stops before clearing the form, so the visitor keeps what they typed and is asked to try again. The keep-alive job has succeeded on every run since it was added on 11 Nov 2026 (checked 26 Nov 2026). The repository has no automated tests, so the rest was checked by hand.

Outcomes

The site is live on the client’s domain (checked 26 Nov 2026). Since 11 Nov 2026, an outage of the email step alone, or of the database alone, no longer loses an enquiry. Enquiry numbers belong to the client, so none are shown here.

Limitations and what I’d change

  • A failed email is not sent again. When the save works and the email does not, the enquiry waits on the admin page until someone checks it. I would add a second attempt for the email step.
  • There are no automated tests, so the enquiry path is checked by hand after each change. I would add a browser test for each failure case.
  • An enquiry saved only by email never reaches the admin page, so after a database outage the team works from two places. A small retry that writes it back would close that gap.

Credits and permissions

A freelance project, shown with the client’s brand cropped out of every screenshot. Client name withheld.

No public links or sources: the code and the live site belong to the client.

Contact

Have a project?

Open to a small amount of freelance work: AI features, internal tools and web apps for small teams. Tell me what you're building, who it's for and when you need it.

Write to me →