Skip to content

07

TL;DRDouble bookings and unpaid no-shows from DMs → a PostgreSQL exclusion constraint and prepaid holds → double bookings impossible at the schema level.

Role
Full-Stack Engineer
Client
Vysota 890 · Carpathians
Year
2024
Stack
Next.js, TypeScript, PostgreSQL, Payment gateway
FIG. 06EXCLUSION CONSTRAINTMOTUWETHFRSASU12345678910111213141516171819202122232425262728conflicting key (room, daterange)EXCLUDE USING gist (room_id WITH =, stay WITH &&)UNPAID HOLDS RELEASE AUTOMATICALLY · OWNER NOTIFIED IN TELEGRAM
Architecture
CALENDARavailability01HOLDttl · prepay02POSTGRESQLEXCLUDE gist03GATEWAYprepayment04TELEGRAMowner05BUILT / OWNED BY MEINTEGRATED

In one paragraph

The database itself makes a double booking impossible. Bookings moved from DMs to the site and the owner manages availability from one calendar.

Context

The lodge took bookings through phone calls and DMs. Double bookings happened and unpaid no-shows cost real money.

Problem

No single source of truth for availability, and nothing was prepaid.

What I did

  1. 01

    Exclusion constraints

    Bookings stored as date ranges with a PostgreSQL exclusion constraint — overlaps are rejected by the database, not by hope.

  2. 02

    Prepayment holds

    A reservation is confirmed by online prepayment; unpaid holds release automatically after a timeout.

  3. 03

    Owner in the loop

    Every confirmed booking lands in the owner's Telegram with dates, guest contact and payment status.

Results

  • 0

    double bookings possible at the schema level

  • 100%

    of confirmed reservations are prepaid

Stack

  • Next.js
  • TypeScript
  • PostgreSQL
  • Payment gateway
  • Telegram Bot API
Similar project?Book a call about a similar project →30 minutes, video. You'll leave with a rough plan and a price range.Hiring?Read the CV →Questions about this case?Contact me →
Next · 08Game keys store →