The Question
FE DesignHigh-Performance Travel Booking Platform Design
Design a frontend architecture for a high-traffic travel booking website like Expedia or Booking.com. Your solution must address critical SEO requirements via Server-Side Rendering, handle complex search filtering state using URL synchronization, and ensure a high-performance listing page through virtualization and intelligent caching. Detail how you would manage a multi-step checkout flow with state persistence and provide a seamless mobile-first user experience while maintaining WCAG accessibility standards.
React
Next.js
TanStack Query
Tailwind CSS
TypeScript
XState
SSR
JSON-LD
Questions & Insights
Clarifying Questions
Scope of Inventory: Is this a multi-vertical platform (Flights, Hotels, Cars) or a single-vertical MVP (e.g., just Hotels)?
Assumption: We will focus on a Hotel Booking MVP to manage complexity while establishing a scalable pattern for other verticals.
SEO Requirements: How critical is organic search traffic for the landing and listing pages?
Assumption: SEO is a tier-1 requirement. We will use Server-Side Rendering (SSR) for Search and Detail pages.
Traffic and Scale: What is the expected scale for concurrent users searching and filtering?
Assumption: We target 1M+ monthly active users, requiring efficient client-side filtering and robust caching.
Booking Flow: Is the payment handled on-platform or via a third-party redirect?
Assumption: On-platform checkout for a seamless user experience, requiring secure PCI-compliant form handling.
Crash Strategy
Core Bottleneck: High-frequency data fetching and filtering on the Search Results page can lead to UI lag and stale data.
Strategy:
URL-Centric State: Drive search and filter states entirely through URL query parameters to enable deep-linking and SSR-friendly data fetching.
Aggressive Data Caching: Implement a stale-while-revalidate strategy for property listings to ensure instant "Back" button navigation.
Atomic Booking Flow: Segregate the booking process into a multi-step form with local persistence to prevent data loss on accidental refreshes.
Performance-First Rendering: Use virtualization for long result lists and progressive image loading for property galleries to maintain high Core Web Vitals.
Elite Bonus Points
Predictive Prefetching: Prefetching the Detail Page data when a user hovers over a search result card to reduce perceived latency to near-zero.
Design System Tokens: Utilizing a token-based theming system to support "White-label" capabilities for future B2B partnerships.
Offline Resilience: Using a Service Worker to cache previously viewed bookings, allowing users to access their itineraries in low-connectivity areas (e.g., airports).
Design Breakdown
Requirements
Functional Requirements:
Search properties by location, date range, and guest count.
Filter and sort results (price, rating, amenities).
Detailed property view (gallery, description, map).
Multi-step checkout (Traveler info, Payment, Confirmation).
Non-Functional Requirements:
Performance: < 1.5s LCP on 4G connections.
SEO: Meta-tags and structured data (JSON-LD) for all public listings.
Accessibility: WCAG 2.1 AA compliance, specifically for date pickers and complex filters.
Responsiveness: Mobile-first approach; high-density touch targets.
Design Summary
Concise Summary: A performance-optimized SSR application leveraging URL-driven state for search and a robust caching layer for inventory management.
Major Components:
App Shell: The persistent layout providing navigation, user identity, and global notifications.
Search Controller: Orchestrates URL synchronization with search inputs and API triggers.
Inventory Cache: A client-side store managing property data, availability, and pricing logic.
Checkout Manager: A state machine-driven component handling the multi-step booking sequence and payment integration.
CUJ Walkthrough:
Search & Discovery: User enters criteria -> URL updates -> SSR fetches results -> Component renders list with virtualization.
Property Evaluation: User clicks card -> Detail page loads (SSR/Prefetched) -> Dynamic pricing calculated based on dates.
Booking: User clicks "Book" -> Multi-step form gathers data -> Encrypted payment submission -> Success redirect.
Simplicity Audit: This architecture avoids complex global state (like Redux) in favor of URL state and specialized data-fetching hooks (TanStack Query), minimizing the "Boilerplate Tax" for the MVP.
Architecture Decision Rationale:
SSR over SPA: Essential for Travel SEO and fast initial time-to-content.
URL as Source of Truth: Simplifies complex filtering logic and enables users to share specific search results easily.
System Diagram
Architecture Deep Dive
Presentation Layer
Component Hierarchy: The
Outter App Shell wraps the Main Layout, which handles responsive containers. Search Page and Property Detail Page are top-level routes. Listing Card is a pure leaf component designed for reusability across search and "Favorites" views.Interaction Layer: Employs "Optimistic UI" for filtering; clicking a filter updates the URL immediately, and the list shows a skeleton state. Accessibility is handled using ARIA live regions for search result counts.
Rendering Layer: Next.js-style SSR for initial loads. Search results use
react-window for virtualization to handle 500+ items without DOM bloat. Images use srcset and lazy-loading.UI Frameworks: React with Tailwind CSS for rapid, low-bundle-size styling. Headless UI for accessible components like modals and dropdowns.
Application Layer
Data Fetching Layer: TanStack Query (React Query) handles deduplication and caching. A
staleTime of 5 minutes is set for inventory to balance freshness and performance.State Management Layer: The URL (via
next/router or similar) is the primary state for search. The Booking State Machine (XState or a custom reducer) manages the checkout flow to ensure users can't skip steps.Routing & Navigation: Nested routes (e.g.,
/search/[region]/[city]) are used to optimize SEO silos. Route guards prevent unauthenticated users from reaching the final checkout step.Domain Layer
Business Rules:
Pricing Logic service handles currency conversion and tax calculations on the client to provide instant feedback before the server validates.Entities / Models:
Inventory Models transform raw API JSON into clean TypeScript interfaces (e.g., mapping amenity_id_3 to Wifi).Inter-layer Contracts: Domain services are injected into Application hooks, ensuring that UI components never call the API Gateway directly.
Infrastructure Layer
API / Network: RESTful endpoints with a GraphQL layer for the Detail page to avoid over-fetching (e.g., only fetching reviews if the user scrolls to that section).
Storage:
localStorage is used to persist "Recently Viewed" properties. sessionStorage temporarily holds checkout form data to survive accidental refreshes without clogging long-term storage.Wrap Up
Wrap-up
Evaluation: This design prioritizes SEO and User Perceived Performance, the two highest-impact factors for travel conversion.
Trade-offs: By using SSR, we increase server costs compared to a pure SPA, but the conversion gain from SEO justifies the expense.
Future Scaling: The architecture is ready for a "Micro-frontend" split if Flights and Hotels teams need to deploy independently, as the
Outter App Shell and Inventory Cache are decoupled.