Clinic platform · Booking · CMS
Respiro
A website and booking platform for a medical practice: patients find a free slot and book or cancel on their own; the practice edits its pages visually, runs its schedule and reaches waiting patients, with patient data encrypted at rest.
- 1Worker for pages and API
- 6languages
- AES-GCMpatient data at rest
- Role
- Technical owner · lead engineer
- Period
- Since Aug 2024, now in maintenance · this platform 2026
- Stack
- Astro (SSR), React 19 (the panel), Hono, Cloudflare Workers, D1, Puck, TypeScript
- Languages
- Six, edited in the panel
The platform at scale
Small enough for one practice, built like a product. Every point below is a function, a component or a database table of it, and every thread one of them using another: the patient-facing site and the practice’s panel at one end, the API, the scheduling and the messaging at the other. Names are withheld; the shape is not.
1,300 declarations and 9,528 references, drawn when this page loads.
- 46klines of TypeScript, Astro, CSS and SQL
- 58API routes on one Worker
- 20database tables, 18 migrations
- 15CMS blocks the practice edits by hand
- 6languages, translated in the panel
- 165tests in 35 suites
- 96scheduled runs a day: reminders, outbox, digest
- 0React shipped on public pages
A booking, end to end
A patient picks a slot on a phone; seven steps later the practice has a safe, encrypted appointment and the patient has a message with a way to cancel.
- Free slotsthe weekly schedule, its exceptions, public holidays and the cut-off the evening before
- Requestvalidated, rate-limited, origin-checked; a resent request returns the same booking
- Collisionthe database itself refuses two visits in one slot, whatever two browsers do at once
- Encryptionname, phone and email sealed with AES-GCM before they are stored
- Outboxa confirmation queued, never sent twice, retried with a reason when it fails
- Reminderthe evening before, unless it was booked too late or by the practice for itself
- Cancel linka personal link by email; a freed slot is offered to whoever has waited longest
Every fifteen minutes
A scheduled run that keeps the practice informed without anyone opening the panel.
- Due reminderstomorrow’s visits get their message at six in the evening, Polish time
- Outboxeverything queued goes to the SMS and email providers
- No late messagesnothing goes out after the visit, nothing to a cancelled one
- Healthfailing messages or a low SMS balance warn the practice, at most once a day
- Digestthe next day’s visits by email in the afternoon
The problem
A busy practice needed more than a brochure: real availability, self-service booking and cancellation, a waiting list, and a site the staff can edit without a developer, all while treating patient data as sensitive by default.
What I built
- Server-rendered pages and the API on one Cloudflare Worker with a shared D1 database; public pages ship no React at all.
- A visual CMS with a deliberately small set of blocks, drafts and publishing that goes live on the next page load, without a rebuild.
- A calendar of free slots, an editable weekly schedule with date exceptions, and self-service booking and cancellation; existing calendars come in as encrypted .ics imports into the same schedule and waiting list.
- Static assets served from the edge without touching the database.
- A translation editor for six languages with separate draft and published values.
- Confirmations and reminders through an outbox with retries and operator-side idempotency; manual waiting-list SMS only after a slot and preferences are checked.
Engineering decisions
- Patient data encrypted with AES-GCM and only decrypted after staff sign in; session and cancellation tokens are hashed.
- A per-request CSP nonce, origin checks, rate limiting on sign-in and booking, audited admin operations and revisions against concurrent edits.
- Two visits never share a slot: overlap triggers in D1 refuse it in the database itself, and edits use optimistic locking (compare-and-swap), so two people saving at once never overwrite each other.
- Messages that go out exactly once: idempotent SMS and email outboxes, each message claimed by an atomic lease, retried with exponential backoff, with cut-offs and quiet hours worked out in Warsaw time across daylight-saving changes.
- Zero trust in the panel: Cloudflare Access tokens (RS256) checked against its published keys, rate limits keyed to the client’s IP, a maintenance mode that fails closed and logs with patient data redacted, all verified by integration tests against a local D1.
- Technical SEO built in: canonicals, hreflang, Open Graph and structured data for a medical practice.