Back to projects
iOS & Android API

Hotel Booking App — Mobile API

Search, Availability, Booking & Payments for a Hotel Booking Mobile App

LaravelPHP 8.2MySQLSanctumStripeFCMRedis
Platforms
iOS + Android
Auth
Sanctumtokens
Real-time
FCM push
Payments
Stripe
iOS & Android · REST APIUI concept
Hotel Booking App — Mobile API — screenshot

A versioned REST API powering a hotel booking app on iOS and Android. Guests search hotels by location and dates, see live room availability, book and pay in the app, manage their reservations and leave reviews after their stay. Hotel staff use the same backend to manage rooms, rates and bookings.

Architecture & System Design

Laravel API with token authentication via Sanctum. Availability is calculated from a room-night inventory table rather than by scanning bookings, so search stays fast as data grows. Payments run through Stripe PaymentIntents, and booking state changes are pushed to the guest's device with Firebase Cloud Messaging through queued jobs.

Request Flow
Mobile App
Sanctum Auth
Search & Availability
Booking Hold
Stripe PaymentIntent
Webhook Confirmation
FCM Notification
  • Room-night inventory model makes date-range availability queries simple and indexable
  • Short-lived booking holds stop two guests paying for the same room at the same time
  • Stripe webhooks are the single source of truth for marking a booking as paid
  • API resources and versioned routes (/api/v1) keep mobile releases backward compatible

Engineering Challenges

Preventing Double Bookings

Problem

Two guests could select the last available room at the same moment, and both reach the payment step.

Solution

Wrapped availability check and hold creation in a database transaction with row-level locks on the affected room-nights, and gave each hold an expiry so abandoned checkouts release the room automatically.

Result

Only one guest can hold a given room-night, and unpaid holds free themselves without manual clean-up.

Reliable Payment Confirmation

Problem

Mobile networks drop mid-checkout, so the app can't always tell the server whether a payment succeeded.

Solution

Moved confirmation to Stripe webhooks with idempotent handlers; the app simply polls the booking status after returning from the payment sheet.

Result

Bookings are confirmed even when the app loses connection right after paying.

Core Features

Search & Filters

Search by city or area and dates, filter by price, rating and amenities, with paginated results tuned for mobile scrolling.

Clean Code

BookingService.php
1public function hold(Room $room, CarbonPeriod $nights, User $guest): Booking
2{
3 return DB::transaction(function () use ($room, $nights, $guest) {
4 $taken = RoomNight::where('room_id', $room->id)
5 ->whereBetween('date', [$nights->start, $nights->end])
6 ->whereNotNull('booking_id')
7 ->lockForUpdate()
8 ->exists();
9
10 if ($taken) {
11 throw new RoomUnavailableException();
12 }
13
14 $booking = $guest->bookings()->create([
15 'room_id' => $room->id,
16 'status' => 'held',
17 'expires_at' => now()->addMinutes(15),
18 ]);
19
20 RoomNight::where('room_id', $room->id)
21 ->whereBetween('date', [$nights->start, $nights->end])
22 ->update(['booking_id' => $booking->id]);
23
24 return $booking;
25 });
26}

Want something like this for your business?

I design and build full stack products end to end. Tell me about your idea and I'll get back to you with a plan.