Gaari - Case Study
Building Bangladesh's first comprehensive car rental and travel platform required solving multiple complex challenges simultaneously. The platform needed to handle three distinct service types (Car Rental, Travel Packages, Activities) with different booking parameters, pricing models, and availability constraints. The core challenge was creating a unified booking system that could manage real-time availability across hundreds of vehicles and services while preventing double bookings during high-traffic periods. Additionally, the system needed to support dynamic pricing algorithms that adjust based on demand, duration, and seasonality—all while maintaining sub-second response times for search queries. Payment integration presented another layer of complexity, requiring seamless integration with both Stripe (international) and Bkash (local) payment gateways, each with different webhook structures and security requirements. The geographic services component needed to support 500+ landmarks and provide route optimization for travel planning.
I architected a unified booking engine using Next.js 14's App Router with Server Components for optimal performance. The solution involved three core layers: **State Management Layer**: Created a centralized booking state manager using React Context API and custom hooks that handles multi-step booking flows, cross-service availability checks, and real-time price calculations. **Real-Time Availability Layer**: Implemented Supabase Realtime subscriptions with PostgreSQL triggers to maintain live availability counts. The system uses optimistic UI updates with backend confirmation to handle race conditions when multiple users book simultaneously. **Dynamic Pricing Engine**: Built a server-side pricing calculator that considers base rates, duration multipliers, seasonal demand factors, promotional discounts, and last-minute booking premiums. All calculations are cached in Redis for performance. For payment integration, I created a unified abstraction layer that handles both Stripe and Bkash webhooks with idempotency checks to prevent duplicate charges. The geographic services component uses geocoding APIs with route optimization algorithms.