pedrojimenez.dev

Notes · 2026-07-31

How I eliminated double-bookings in a vacation rental platform

When Cabarete Villas asked me to build their booking platform, they had a specific pain: guests booking the same villa on Airbnb and VRBO because the calendars weren't in sync. That's not a UI problem, it's a data problem. The standard fix is to export an iCal feed from each platform and import the other's, but that creates a race condition if both sides write at the same time.

The trap of trusting iCal timestamps

I made a decision early on: the database would be the single source of truth for availability. iCal exports become a way to push our bookings to Airbnb/VRBO, and iCal imports become a way to ingest their bookings into our system. But that means every change has to flow through my booking engine, and every external change has to be reconciled.

The first version broke when a guest changed their reservation on Airbnb. The iCal feed was updated, but my system only imported new events, not modifications. A cancelled booking stayed in my calendar, blocking a date that was actually free. That's when I learned that iCal events have UIDs and last-modified timestamps, and I had to track those to handle updates properly.

The tradeoff: snapshots, not real-time

I treat iCal feeds as snapshots, not real-time sources. Every hour, I pull all feeds for a property and compare them against my bookings. Any event that doesn't match a known UID gets flagged. For updates, I compare the last-modified timestamp; if Airbnb changed a booking, I update mine. If there's a conflict — say a new external booking overlaps an existing one — I keep the first booking and notify the owner to manually resolve it. That's a deliberate design choice: I'd rather surface a conflict than silently double-book.

The other lesson was about concurrent writes. I added a per-property lock around the sync process so that no local booking can be created while an import is running. That removed the race condition where a guest books locally at the same moment an import tries to write an external booking.

What actually worked

The result: zero double-booking incidents since launch. The whole system runs on Next.js, Firebase, and a PayPal integration — the iCal sync is the heart, not the showpiece. You can read more about the full build in the Cabarete Villas case study.

This is the kind of problem that only shows up when you have real guests and real money on the line. If you're building a booking platform, or just managing a property's calendar, these are the details that separate a demo from a production system.

Building something like this? Tell me what you need and I'll scope it.

Start a project