Full-stack appointment booking system
Can a booking system refuse a clash before it happens?
Booking API for hospital appointments that refuses double bookings and bad data before anything is saved.
- What it is
- Personal project
- My role
- Built solo
- Year
- 2026
- Status
- In development
- TypeScript
- Node.js
- Express
- MongoDB
- Mongoose
- Zod
The problem
Booking systems break on two things: two requests grabbing the same time, and messy input, like a phone number typed five different ways.
How I solved it
- Every request is validated strictly before it reaches business logic.
- The end time is worked out from the service, never taken from the client.
- Clashes are caught twice: an interval-overlap check in code gives a clear error, and a unique index in the database stops two simultaneous requests from both winning.
System design
- TypeScript, Node.js, Express, MongoDB with Mongoose.
- Layered: routes → controllers → services → repositories → models.
- Four resources: customers, providers, services and appointments.
- Zod schemas in strict mode reject unknown fields; phone numbers normalised to 10 digits.
- Partial unique MongoDB index for concurrency safety, plus a test suite across layers.
- Next: a Next.js and PostgreSQL version with role-based access and availability rules.
Trade-offs
- Layered architecture over a flat Express app: each layer testable alone, data access swappable. Cost: more files and boilerplate for a small API.
- Clash check in code and in the database: friendly errors plus race safety. Cost: the rule lives in two places that must change together.
- Strict validation that rejects unknown fields: a tight, predictable API contract. Cost: clients that send extra fields get errors instead of being ignored.