Slotwise
Open-source booking engine for UK businesses that can't double-book
- Role
- Creator and sole developer
- Dates
- Oct–Nov 2026
- Status
- Live
In short
Booking systems can let two people book the same slot, and they often get the time wrong when the UK clocks change. I built Slotwise, a free, open-source booking system for UK businesses that sell one-to-one appointments, with a booking widget, an owner dashboard and booking emails. When 100 people try to book the same slot at the same moment, exactly 1 gets it, and all 183 automatic tests pass.
The problem
Most booking software checks whether a slot is free and then saves the booking. When the system is busy, that isn't safe. Two people can both see 10:00 as free, and both get booked into it.
UK clock changes cause a second kind of mistake. One night in March has no 01:00–01:59, and one night in October has that hour twice. Badly built systems offer times that don't exist, or book the wrong hour.
What I built
Slotwise is a booking system for UK businesses that sell one-to-one appointments, such as clinics and therapists. Customers pick a time on a small booking form that the business adds to its own website, or on a ready-made booking page.
The owner runs everything from one dashboard: the calendar, bookings, customers, services, staff, weekly hours and time off. Customers get confirmation, reminder and cancellation emails, and a private link to move or cancel their booking.
The system itself refuses any booking that would clash, so a slot can never be sold twice. Available times stay correct on the nights the clocks go forward or back.
My role
I am the creator and sole developer. I made the plan and every design decision, and built the whole thing myself: the booking rules, the owner dashboard, the booking form for websites, the email sender, the automatic checks and the release script.
Results
- 1 of 100 people booking one slot at the same moment gets it; the other 99 are turned away
- 183 automatic tests, all passing on every change
- ~10 ms to find 30 days of free times for one staff member
Slotwise v1.0.0 is free and open source on GitHub under the MIT licence. A public demo clinic resets every hour and never sends real email. All 183 automatic tests pass on every change.
Try the live demo: the demo login (demo@slotwise.example / demo-physio-2026) is filled in for you, so just press "Log in". You can also book as a customer on the demo clinic's booking page.
Key features
- A small booking form any business can add to its own website, plus a ready-made booking page.
- Booking emails with calendar invites attached.
- Each booking email is saved with its booking and retried until it is sent. A crash can delay a booking email or, rarely, send it twice, but it is not dropped.
- Other software can make bookings safely, and a booking sent twice by mistake is only saved once.
- Automatic, signed notices to the business's other systems whenever a booking changes, with a record of each one sent.
- A full history of every change to a booking.
- Customers' personal data can be erased on request, and old data is cleared automatically.
- Each business sees only its own bookings, services and staff.
- A public demo with sign-up switched off and no real emails sent.
How it’s built
Approach
PostgreSQL, not application code, refuses overlapping bookings, through an exclusion constraint on each staff member's blocked time. Bookings are stored as UTC instants and working hours as wall-clock minutes in Europe/London, and every conversion goes through the Temporal API. A booking change and its outbox event commit together, and a separate worker turns events into emails and webhooks. The slot engine is a pure function with no database, clock or I/O, so it is fast and easy to test thoroughly. Every tenant query is scoped to the business taken from the authenticated request, never from the URL or body.
Technical work
- Designed and built the whole system myself: data model, NestJS API, Next.js dashboard, embeddable widget and BullMQ worker.
- Wrote the pure slot engine and its 49 unit tests, covering split shifts, buffers, notice periods, overrides and all four 2026–2027 UK clock changes.
- Built bookings with database-enforced no-overlap, idempotency keys and an audit log.
- Built confirmation, reminder and cancellation emails on an outbox, a separate worker and a send log, plus signed webhooks with SSRF protection.
- Built the REST API with Swagger docs generated from the same Zod schemas that validate requests, API keys with idempotent booking requests, and a webhook delivery log.
- Added a public demo mode (sign-up off, email only to the log), and a deploy script that dumps the database before migrations and rolls back if the health check fails.
- Set up GitHub Actions CI that runs typecheck, lint, tests and build on PostgreSQL 16 and 18.
Architecture
A pnpm and Turborepo monorepo, run on one Linux server with PM2. No Docker.
Slotwise monorepo architecture, run on one Linux server with PM2 and no Docker.
- apps/web: the Next.js dashboard, hosted booking page and customer manage page. It proxies /api/* to the API.
- apps/api: NestJS with Prisma, holding auth and business rules, with Swagger docs generated from Zod. A second entry point in the same codebase runs the BullMQ worker as its own PM2 process.
- PostgreSQL holds the bookings with the exclusion constraint, the outbox, the send log and the audit log.
- Redis holds the BullMQ queues: email (including reminders) and webhooks, plus the 5-second outbox relay, the hourly reminder check, the daily clean-up and the demo reset.
- Shared packages: packages/engine, the pure slot engine on the Temporal API with no I/O and no clock; packages/widget, a Web Component in Shadow DOM of about 5 KB gzipped; and packages/shared, the Zod schemas and types.
- apps/api: NestJS with Prisma on PostgreSQL. All auth, permissions and business rules. Swagger docs come from the same Zod schemas that validate requests. A second entry point runs the BullMQ worker as a separate process.
- apps/web: Next.js dashboard, the hosted booking page and the customer manage page. It only displays data and proxies /api/* to the API.
- packages/engine: the pure slot engine, built on the Temporal API. It does no I/O and reads no clock.
- packages/widget: the booking widget, a Web Component in Shadow DOM, bundled by esbuild into one file of about 5 KB gzipped.
- packages/shared: Zod schemas and types shared by the API, web app and widget.
PostgreSQL holds the bookings (with the exclusion constraint), the outbox, the send log and the audit log. Redis holds the BullMQ queues: emails, reminders, webhooks, a 5-second outbox relay, an hourly reminder check, a daily clean-up and the demo reset.
Key decisions and trade-offs
Chose: a PostgreSQL exclusion constraint on each staff member's blocked time, only for confirmed bookings. Because: check-then-insert in app code isn't safe under load. PostgreSQL 18's UNIQUE … WITHOUT OVERLAPS can't have a WHERE clause, and cancelled bookings must not block the diary. Downside: Prisma can't express it, so it lives in a hand-edited migration that must be protected from drift, and "any staff" bookings need savepoints to survive a clash.
Chose: bookings stored as UTC instants, working hours as wall-clock minutes in Europe/London, and every conversion through the Temporal API inside a pure engine. Because: storing hours in UTC is the classic bug where "09:00" changes meaning twice a year. A pure function is fast to test thoroughly without a database. Downside: every boundary between stored instants and displayed times is a conversion that has to be tested; Temporal still needs a polyfill in some runtimes.
Chose: an outbox committed with each booking change, fixed job ids, a send log and a separate worker. Because: exactly-once delivery to an email server is impossible. This gives at-least-once delivery. A crash can delay a booking email or, rarely, send it twice, but it is not dropped. The fixed job ids and send log stop retries from sending the same email again. Slow email or webhook retries never block an API request. Downside: Redis and the worker are two more processes to run; emails are delivered seconds after the request, not inside it.
Outbox and send log flow.
- An API request makes a booking change.
- One database transaction writes the booking change and an outbox row, then commits.
- On the fast path, the API enqueues a BullMQ job with a fixed, deterministic job id. Every 5 seconds a relay picks up any outbox rows the fast path missed.
- The worker checks the send log, then sends the email or webhook, and the send log records it.
How booking emails survive a crash: if the process crashes after commit, the relay sends the email within 5 seconds. If the fast path and the relay both enqueue, the job id is the same, so the second is a no-op. If a job is retried after a crash, the send log stops a second send. The one remaining gap is a crash between the email server accepting a message and the send log row being written, which sends that email twice. A crash can delay a booking email or, rarely, send it twice, but it is not dropped.
Chose: a Web Component with Shadow DOM for the widget, not an iframe or React. Because: it works on any site with no CSS clashes, and a React bundle is 40+ KB before any of my code. Downside: no React ecosystem inside the widget, so forms, state and accessibility are hand-written.
Hardest problem and how I solved it
Stopping double-bookings under load. Two requests can both read 10:00 as free and both insert, and a row lock can't help because the clashing row doesn't exist yet. So the database refuses the overlap itself, with an exclusion constraint on (staff member, time range including buffers) for confirmed bookings. The '[)' range lets one booking start exactly when the last one ends.
Double-booking proof, in two parts.
- 100 parallel POST /bookings requests for one slot reach a PostgreSQL exclusion constraint on (staff member, time range including buffers), applied only where status is confirmed. The outcome: 1 × 201 Created, 99 × 409 SLOT_TAKEN, and one row in the table.
- One staff member’s diary, using ‘[)’ ranges that include their start but not their end: booking A runs 10:00 to 10:30 and is confirmed; booking B starting exactly at 10:30 is accepted; booking C at 10:15 overlaps A and is refused; a cancelled booking at 11:00 doesn’t block anything.
Prisma can't express the constraint, so it lives in a hand-edited migration, and I checked that Prisma sees no drift, so later migrations never drop it. With Prisma 7, the clash error arrives in a nested driver field; one helper recognises it and returns 409 SLOT_TAKEN. "Any staff" bookings try each eligible person inside a savepoint, so one clash doesn't abort the transaction.
The proof is an integration test against real PostgreSQL: 100 parallel POST /bookings for one slot give exactly 1 × 201, 99 × 409 and one row in the table.
Read more:
Testing and quality
183 tests
- 49 engine unit tests
- 7 web tests
- 127 API integration tests
Run against real PostgreSQL 16 and 18 + Redis, no database mocks.
183 tests, all passing: 49 engine unit tests, 7 web tests and 127 API integration tests (Vitest and Supertest) against real PostgreSQL and Redis, with no database mocks. They cover all four 2026–2027 UK clock changes, 100 concurrent bookings for one slot, "any staff" savepoints, idempotency (including 10 concurrent requests with one key), the outbox relay after a lost fast path, stale reminders, refresh-token reuse, tenant isolation (another business's data returns 404), webhook SSRF checks after DNS lookup and demo-mode limits.
CI (GitHub Actions) runs typecheck, lint, tests and build on PostgreSQL 16 and 18, on every push to main and every pull request. The widget build fails if the bundle goes over 30 KB gzipped.
Evidence in the code (commit 0e5037b):
Engineering highlights
- PostgreSQL exclusion constraint on staff time ranges: 100 parallel bookings for one slot give exactly 1 success and 99 × 409 SLOT_TAKEN.
- UK clock changes handled with the Temporal API: no slots in the missing hour in March, and each local time offered once in October.
- Outbox, separate worker and send log (at-least-once delivery): the email is saved in the same transaction as the booking and retried until sent. A crash can delay a booking email or, rarely, send it twice, but it is not dropped.
- Pure, linear-time slot engine: about 10 ms to find 30 days of slots for one staff member.
- Multi-tenant isolation: another business's bookings, services or staff return 404, never 403.
Stack
- NestJS
- Next.js
- PostgreSQL
- BullMQ
- TypeScript
- Tailwind CSS
- shadcn/ui
- Prisma
- Redis
- Zod
- Temporal
- Vitest
- Supertest
- Turborepo
- GitHub Actions
- PM2
Development timeline
- Foundations
Monorepo, authentication, roles and tenant isolation, with CI running against PostgreSQL 18 and Redis from the start. - Slot engine
Services, staff, weekly hours and date overrides, then the pure slot engine with explicit UK clock-change handling. - Bookings
Bookings with database-enforced no-overlap, idempotency and an audit log; then emails, reminders and the customer manage link. - Widget & API
Embeddable booking widget, hosted booking page, API keys, signed webhooks, customer erasure and the README.
