Skip to content

Latest commit

 

History

History
28 lines (23 loc) · 1.2 KB

File metadata and controls

28 lines (23 loc) · 1.2 KB

Here's what I built

Here's a breakdown of the cool stuff in this project, explained simply.

The "Race Condition"

The main point of this project was to solve the "double booking" problem. Imagine this:

  1. Two people see the last available slot for 8 PM.
  2. They both click "Book" at the exact same time.
  3. Without protection, the database might let both of them book it. That's bad.

How I Fixed It (RedLocks in redis)

I used something called redis distributed Locks (specifically redlock). Here's what happens when you click "Book":

  1. the server tries to "lock" that specific time slot in Redis.
  2. if it gets the lock, it checks if the slot is still empty.
  3. if it is, it books it and then unlocks.
  4. 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!

Other Stuff

  • 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.