Skip to content
All work

01Booking platform

Meridian

Meridian books appointments for a fictional clinic with three practitioners, four services and variable durations. Service, practitioner, date and time are four steps and four URLs, so the back button works and a slot can be sent to somebody in a link. The interesting part is not the flow. It is what happens when two people want the same 09:30, and what the screen is allowed to say when the database goes away mid-write.

Measured on the finished build

Tests
69 passing, 8 files, 0 skipped
Database down
9 page routes render real content, none reached the framework handler
JavaScript off
9 of 9 page routes render, 308–511 characters each
Axe violations
0 at 1280 and at 360, 8 routes
Contrast
25 pairings against WCAG 2.2, all holding
CLS
0.0000 on 8 routes across 40 runs
Lighthouse
99 / 100 / 100 / 100 / 100, mobile, lowest of five runs

The hard part

Two people, one 09:30

Every booking system has the same race in it. Two requests read an empty slot, both find it free, and both write. Checking for a conflict in application code narrows the window without closing it — between the read and the write there is always room for the other request.

The second, less obvious version of the problem is the failure that lands in the middle. If the connection dies while COMMIT is in flight, the appointment either exists or it does not, and nothing running in the web process can know which. Telling somebody “nothing happened” is the sentence that makes them book twice.

What I did

Make it something the table cannot hold

Overlapping appointments are refused by a Postgres exclusion constraint — EXCLUDE USING gist over practitioner and time range. A retry that discovers the first write landed is refused by the database and comes back as slot_taken. Two confirmed appointments in one slot is not a thing the application avoids; it is a thing the schema makes impossible, and the concurrency test proves it against a real Postgres rather than a mock.

That constraint is also what lets the error copy be honest. The write path splits three ways — before the insert, at the insert, and after it — and each one says only what is true at that point. The middle case says plainly that it is not clear whether the appointment was made, gives a check that works in this build (a confirmed booking removes its time from the grid), and says that booking again is safe. It is safe because of the constraint, not because of the wording.

Decisions, with the price attached

What was chosen, and what it cost

Stated rather than left to be found

Known limits