Here's a breakdown of the cool stuff in this project, explained simply.
The main point of this project was to solve the "double booking" problem. Imagine this:
- Two people see the last available slot for 8 PM.
- They both click "Book" at the exact same time.
- Without protection, the database might let both of them book it. That's bad.
I used something called redis distributed Locks (specifically redlock). Here's what happens when you click "Book":
- the server tries to "lock" that specific time slot in Redis.
- if it gets the lock, it checks if the slot is still empty.
- if it is, it books it and then unlocks.
- if someone else tries to book while it's locked, they get an error saying "Slot is being booked".
It's like a bathroom door - only one person can go in at a time!
- role-based access:
- providers (like a Salon) can create services and slots.
- customers can just book them.
- real-time availability(no web sockets tho):
- if you book a slot, it instantly shows as "booked" for you (and disabled).
- for others, the "slots left" count goes down.