Back to Projects

The Gilded Shear: Premium Barber Shop Booking Platform

A premium barber shop booking platform built with Next.js, featuring real-time availability tracking, Stripe payment integration, FCM push notifications, and timezone-aware scheduling.

Screenshot of The Gilded Shear: Premium Barber Shop Booking Platform

Technologies Used

Next.js 16React 19TypeScriptTailwind CSSFirebaseStripeVercelGoogle Cloud Functions

The Challenge: Precision Booking in a Real-Time World

Building a booking system sounds simple until you factor in timezones, payment processing, and real-time concurrency. The Gilded Shear solves these problems with a robust architecture that handles UTC offsets, prevents double-bookings through mathematical slot calculation, and ensures instant UI updates using optimistic caching.

System Architecture: Serverless & Scalable

The platform leverages a serverless architecture for infinite scalability and zero maintenance. Next.js 14 (App Router) handles the frontend, deployed to Vercel's Edge Network. The backend relies on Firebase Cloud Functions Gen 2 for business logic (payments, notifications) and Firestore for real-time data persistence. Stripe Payment Intents handle secure transactions, while Firebase Cloud Messaging (FCM) keeps admins informed instantly.

Timezone-Aware Scheduling: Solving the UTC Offset

One of the hardest challenges was handling timezones correctly. Users select slots in 'America/Chicago', but Firestore stores UTC. Naive conversions led to 6-hour offset errors. We implemented a robust solution using toLocaleString with explicit timezones to dynamically calculate the correct UTC offset, ensuring that a 4:00 PM booking in Chicago is always stored as the correct UTC timestamp, regardless of Daylight Saving Time.

Duration-Aware Overlap Prevention

To prevent double-bookings, we couldn't just check start times. A 60-minute haircut starting at 4:00 PM must block the 4:30 PM slot too. We implemented a mathematical algorithm that calculates every 30-minute interval covered by a service's duration and blocks all intersecting slots. This ensures complete schedule integrity for services ranging from 25 to 80 minutes.

Real-Time Performance: Optimistic UI & Offline Persistence

Performance is a feature. We achieved instant load times (~20ms on refresh) by enabling Firestore Offline Persistence, which serves data from IndexedDB while syncing in the background. For the calendar, we implemented a Month Pre-fetching Strategy, loading all availability for the month in a single request. This eliminated the 1.5s lag between date clicks, making the booking experience feel native and responsive.

Notification System: Solving the Double-Notification Bug

We encountered a common issue with PWAs where both the browser and service worker would display notifications, leading to duplicates. The solution was to send Data-Only FCM Messages. By omitting the 'notification' payload and sending only 'data', we bypassed the browser's default handler and gave full control to our Service Worker, ensuring a single, consistent, and branded notification experience.

Conclusion: A Production-Grade Booking Solution

The Gilded Shear is more than just a form; it's a complex distributed system that handles money, time, and real-time data with precision. By solving hard problems like timezone math, concurrency, and offline persistence, we delivered a tool that not only looks premium but functions with the reliability a business depends on.