Frontend System Design17 min readPremium

Design Airbnb – Frontend System Design

Design Airbnb - Frontend System Design
In this guide, we design Airbnb from the frontend side: the listings grid, per-tile image carousels, data fetching, and the performance work that keeps it fast on mobile.

Problem Statement

Build the frontend for a hotel booking website.

Requirements:

  • Display a grid of hotels or houses available for booking
  • Each grid tile should show a slideshow of images (image carousel), the property title, and the price per night
  • The layout should be fully responsive and look good on both desktop and mobile devices
  • Users should be able to scroll within each property’s images to view a slideshow

Describe your approach to component structure, implementing the image carousel, fetching data for hotels and images, and any optimizations you’d consider for performance and user experience.


Clarifying Questions

# Question Interviewer’s Answer
1 Where is the hotel data coming from? Can you describe the API? Please design the API.
2 How many images per property? Should we optimize for many or few? You should design that for optimal performance.
3 Should the image carousel auto-play, or only allow manual scrolling? Manual.
4 Any requirements for accessibility? (e.g., keyboard navigation, ARIA) Yes, keep it accessible.
5 Should the grid use pagination, infinite scrolling, or show all at once? Yes, pagination.
6 Should users be able to filter or sort hotel listings? No need for filters right now.
7 Preferred technology stack or CSS framework? Up to you, but let’s focus on React.
8 Any performance or scalability constraints? Yes, please consider performance and scale.
9 Should we show loading or error states? Graceful loading is always good.
10 Should we support localization/multi-currency for price display? Yes, you can talk about localization.
11 Any offline support needed? Out of scope.

Requirements

Functional Requirements

  • Display a paginated, responsive grid of hotel/house listings
  • Each tile includes a manual image carousel, property title, and price per night
  • Images for each property should be viewable by scrolling/swiping within the tile
  • Data is fetched from an API you design
  • Site is accessible (keyboard navigation, ARIA labels, etc.)
  • Graceful loading states and error handling for data fetching
  • Price supports localization/multi-currency

Non-Functional Requirements

  • Fast load times and smooth scrolling, even with many properties
  • Scales to support large numbers of users and listings
  • Fully responsive design (works well on desktop, tablet, and mobile)
  • Designed with accessibility standards (WCAG) in mind
  • Good performance: optimized image loading, lazy loading for images/carousels
  • SEO-friendly markup where applicable
  • No offline support required

Napkin Math (Estimations)

Assume a medium-sized site for initial design:

Metric Estimate / Calculation
Daily Active Users 100,000 users/day
Listings per Page 20 (typical grid pagination size)
Avg. Images/Listing 5
Total Daily Pageviews 500,000 pageviews/day (average five pages/user)
Images Loaded/Day 500,000 pages × 20 listings × 5 images = 50,000,000
Peak QPS (500,000 ÷ 24 ÷ 3600) × 2 ≈ 12 requests/sec (per API)

API throughput: At peak, expect to serve up to ~12 grid pages per second (likely higher with bursts; design for 5x overhead, so aim for 60 QPS).


Architecture / Component Design

Airbnb Frontend System Design Architecture

User, Router, and Routing

Everything starts when the user enters the app. At its core, React Router handles navigation between pages, such as the main bookings list and, in the future, more routes like a property details page or user account section. Right now, the router primarily directs users to the bookings grid. Suppose you need to support more routes down the line. In that case, React Router’s configuration can be easily extended by adding new route definitions, and the router will handle navigation between them without any significant architectural changes.

Routing like this keeps the UI fast and modern. Users can move between pages without waiting for full reloads, which feels much smoother and more like a native app.


SSR vs CSR (Server-Side Rendering vs Client-Side Rendering)

For this hotel booking frontend, it’s essential to consider how and where our pages are rendered.

  • Server-Side Rendering (SSR): The HTML for each page is generated on the server and sent to the client. This means the first load is fast, SEO is better, and users see content more quickly, even before all JavaScript is loaded.
  • Client-Side Rendering (CSR): The server sends a minimal HTML shell, and the browser downloads JavaScript, fetches data, and renders everything on the client. This can be great for fast, app-like navigation and complex interactions after the initial load.

A standard, scalable approach is SSR for the initial page load (so users and search engines get content quickly), and CSR for all interactions (like clicking on a tile to view more images, paginating, or loading more listings).

Here’s a table comparing SSR and CSR for our use case:

Feature SSR (Server-Side Rendering) CSR (Client-Side Rendering)
Initial load speed Fast, since the content is pre-rendered Slower, must fetch and render on the client
SEO Excellent, full HTML sent to the crawler Poor, unless extra work for pre-render
Interactivity Needs hydration, then fast Very fast after JS loads
User experience Content visible quickly A blank or loading spinner at first
Complexity Requires server setup (e.g., Next.js) Simpler static hosting is possible
Best for… Landing/search pages, listings Deeply interactive UIs, dashboards

For this project, SSR will make the booking grid fast and SEO-friendly, while CSR can handle all the snappy UI interactions after the first load.


State Management and Data Flow

State management is a vast topic in frontend architecture, especially for an app like this. The right choice depends on how complex the state gets, how many places need to read or update it, and what kind of performance you need as you scale.

Options for State Management

  • useState
    The simplest state hook in React is great for truly local state (like input fields or the current image index in a tile). It’s not ideal for global app data like the list of hotels or pagination since you’d have to “lift” state up multiple levels, which gets messy fast.
  • useContext
    React’s Context API lets you provide and consume state anywhere in the component tree. It’s solid for global, app-level states like hotel lists, pagination info, or loading status. It’s lightweight and doesn’t require external libraries, so keep your bundle size small and avoid unnecessary performance overhead. useContext is a strong choice for this project because we don’t have complex, deeply nested state or huge cross-component updates.
  • Redux
    Redux is super popular for large apps with many moving parts and strict state transition rules. It’s powerful, but it comes with a cost: extra boilerplate, a learning curve, and sometimes performance hits due to how Redux triggers updates across the app. Redux is overkill for a focused booking site like this and may slow things down if you’re not careful about structuring selectors and reducers.
  • Zustand, Recoil, Jotai, etc.
    There’s a wave of modern, minimal state management libraries that solve pain points in Redux and Context. Zustand, for example, gives you simple state containers with good performance and less boilerplate. If you ever outgrow Context or want fancier state control, these are worth exploring. For now, though, Context will keep things simple and readable.

Scoped State per Tile

Beyond the global state, you often need to be “scoped” or local state for components like image slideshows or loading status per hotel card. For instance, if a user scrolls through images in one tile, you don’t want to re-render all tiles or blow away their position just because new data comes in. The solution is to use local state (with useState) inside each tile for things like the active image, loading animations, etc.

When the app fetches new data for a page, you also want to avoid blindly replacing everything and causing UI jumps. You can implement a diff check; if the incoming data for a hotel hasn’t changed, leave the tile alone. Only update those with new info (like price changes, new images, etc.). This is both a performance win and a better user experience.

Why useContext for This Project?

For this app, React Context strikes the right balance between simplicity, performance, and scalability:

  • It keeps the global state in one place and is easily accessible across the app.
  • It avoids Redux’s overhead and complexity.
  • It works well with the View Model pattern, allowing you to separate business logic and data transformation from your UI components.
  • You can mix it with local state, especially for interactive components like carousels.
Option Pros Cons Best Use Case
useState Simple, built-in, great for local state Not scalable for global state Image index in a tile
useContext Global state, minimal boilerplate Unintended re-renders for large trees Hotel list, pagination
Redux Powerful, time-travel/debugging Boilerplate, performance cost Huge, complex apps
Zustand/etc. Simple, fast, modern API Less standard, another dependency Growing apps, fine control

Overall, go with useContext for the main store, and use local state for per-tile interactions. If the app grows into something more complex, migrating to a modern state lib is always an option, but starting simple is almost always the best move.


Bookings List Component Structure

The BookingsListContainer is the hotel grid page’s main “container” component. It calls useViewModel() to get the current data. Inside, it renders a BookingsListContainerView, which maps over hotel data and renders a BookingsList.

Each hotel/house gets its BookingsCard, which shows the title, price, and image slideshow. The ImageSlideShow component handles scrolling/swiping through images within each tile, keeping things interactive and visually appealing.

The component structure looks like:


<BookingsListContainer>
  <BookingsListContainerView>
    <BookingsList>
      <BookingsCard>
        <ImageSlideShow />
      </BookingsCard>
    </BookingsList>
  </BookingsListContainerView>
</BookingsListContainer>

The core of this UI is a series of reusable, focused components that build up the hotel grid in a predictable, scalable way. Each layer has a clear responsibility, and the structure makes testing, extending, and keeping your code clean easy.


BookingsListContainer

This is the “smart” container at the top of the grid page. It handles data flow and passes everything down to child components. It calls useViewModel() to get the latest state (hotel list, loading status, pagination, etc.), and it might trigger data fetching when you hit a new page. BookingsListContainer doesn’t worry about layout details or how hotels are rendered; it handles the data and coordination.

BookingsListContainerView

This main “view” layer handles conditional rendering based on state. For example, depending on the situation, it can display a loading spinner, an error message, or the BookingsList itself. This keeps business logic and UI state (like loading or error states) out of your main grid component, making everything cleaner.

  • Shows a loading indicator while data is being fetched
  • Renders an error message if there’s a fetch problem
  • Otherwise, renders the BookingsList with actual hotel data

BookingsList

This component takes an array of hotel/property objects and maps over them to render a grid. You can easily style it with CSS Grid or Flexbox for a responsive layout. This component doesn’t know about pagination or API fetching, just how to lay out several hotel cards.

  • Handles the visual grid
  • Keeps hotel tiles consistent in size and alignment
  • Renders one BookingsCard per hotel

BookingsCard

The BookingsCard is responsible for each hotel’s tile. It receives props like the hotel title, price, and image array. All presentation logic for a single hotel goes here. This is also where you can integrate click handlers, hover states, or even “favorite” buttons in the future.

  • Renders the title and price
  • Hosts the ImageSlideShow for the property
  • Handles any per-tile local state (like current image index)

ImageSlideShow

This interactive piece lets users scroll or swipe through images for each hotel/house. It should be accessible (keyboard navigable, screen-reader friendly), touch-friendly for mobile, and lightweight so that you don’t load all images simultaneously unless needed (think lazy loading or prefetching the next/previous image).

  • Accepts an array of image URLs
  • Handles manual navigation (left/right arrows, swipe, or scroll)
  • Maintains local state for the current image index
  • Optimizes image loading for performance

Component Relationship Table

Component Responsibility Receives Data From Passes Data To
BookingsListContainer Fetches/holds state, calls useViewModel useViewModel BookingsListContainerView
BookingsListContainerView Handles loading/error/success display BookingsListContainer BookingsList
BookingsList Maps hotels into a visual grid BookingsListContainerView BookingsCard
BookingsCard Displays hotel info and image slideshow BookingsList ImageSlideShow
ImageSlideShow Renders and manages a slideshow for property images BookingsCard (internal, manages itself)

This approach separates data logic, state, and UI, making everything more maintainable. You can drop in new features, tweak layouts, or change the data flow without refactoring your entire app. If you need to add modals, tooltips, or even A/B test a new tile design, this structure makes those changes painless.


Networking and Data Fetching

A Network Manager handles all API communication (fetching the hotel list, handling pagination, etc.). Instead of components making API calls directly, they go through the Network Manager, which can handle retries, caching, and logging out of the box.

The Network Manager talks to a blackbox server (the API backend you’ll design), grabs the latest hotel data, and pipes it into the Store/View Model for the UI.


Image Management and Caching

A key performance area is image loading. The Img Manager is responsible for fetching and displaying images, so the UI isn’t bogged down by network latency. An Image Cache sits between the Img Manager and the network to provide fast image loads and reduce redundant network traffic. This caches recently viewed images in memory or IndexedDB, so images load instantly if a user scrolls back or reloads.

There’s also an image service, which you can use as the gateway to your image CDN or asset pipeline. The Img Manager requests images from the Image Service, which can handle transformations, resizing, and format negotiation.

A basic image flow:

  1. User scrolls to a new hotel tile.
  2. Img Manager checks the image cache.
  3. If cached, serve immediately. If not, fetch from the Image Service, then cache it.

Component and Data Relationships (Table)

Here’s a quick table summarizing how pieces talk to each other:

Layer/Component Role Talks To
React Router Handles navigation/routing User, BookingsListContainer
BookingsListContainer Entry point for the hotel list grid View Model, UI components
View Model Business logic/data transformation Store, Network Manager, UI
Store (useContext) Holds global app state View Model
Network Manager Handles API/data fetching View Model, Server
Img Manager Handles image fetch/display Image Cache, Image Service
Image Cache Speeds up repeat image loads Img Manager
Image Service Backend for image assets Img Manager
BookingsCard, ImageSlideShow UI for each hotel/property BookingsListContainer

Scalability and Extensibility

This setup is designed for scale. Network and image logic are centralized so you can swap in more advanced caching, logging, or prefetching strategies later. The View Model means business logic doesn’t leak into the UI, keeping components easy to test and refactor.

If you want to add infinite scroll, filters, or favorites, expand the View Model and Store, and most of the UI can stay unchanged. Accessibility is also easier to enforce, since the ImageSlideShow and Cards can be built with semantic markup and ARIA attributes up front.


API Design

The API will use RESTful design principles over HTTPS for our hotel booking app to ensure that all data sent between client and server is secure and standard. All endpoints return JSON. REST is familiar to front-end developers and works well with frameworks like React, so it’s a natural fit.

Authentication & Headers

We require all API requests to include an Authorization: Bearer <token> header for authenticated endpoints. Public endpoints, such as hotel listings, can be accessed without authentication, but user-specific or booking actions would require a valid token. For localization and currency, clients can send a Accept-Language or X-Currency header.

  • Authorization: Bearer token for user auth (JWT or similar)
  • Accept-Language: e.g., en-US for localization
  • X-Currency: e.g., USD, EUR

Pagination: Page-Based vs Cursor-Based

There are two main styles for paginating API results:

  • Page-Based: Uses page numbers (page=1&pageSize=20). Simple to use, easy to cache, but can be inconsistent if data changes rapidly. Suitable for user-facing grids and non-realtime data.
  • Cursor-Based: Uses a cursor or token to fetch the next set (cursor=abc123). Handles real-time data well and prevents duplicates or missing data when listings change during pagination. More complex for basic UIs, but needed for feeds or chats.

For our hotel listing, page-based pagination is enough because listings don’t change rapidly, and users expect to click through pages.


API Endpoint Design & Client Data Model

Here are the core endpoints, shown as TypeScript response types so you can see the shape of the server’s JSON output.

You can also use this for your client data model for your useContext.


// --- Shared Types ---

export type User = {
  id: string;
  name: string;
  avatarUrl?: string;
};

export type Hotel = {
  id: string;
  title: string;
  pricePerNight: number;
  currency: string;     // ISO code, e.g., "USD"
  images: string[];
  location: string;
  rating: number;
};

// --- API: Get Hotels (public endpoint) ---
// GET /api/hotels?page=1&pageSize=20

// Request headers (for authenticated user, optional for this endpoint):
// Authorization: Bearer <JWT>
// Accept-Language: en-US
// X-Currency: USD

export type GetHotelsResponse = {
  hotels: Hotel[];
  page: number;
  pageSize: number;
  total: number;
};

// --- API: Get Hotel Details (public endpoint) ---
// GET /api/hotels/:id

// Request headers (optional):
// Authorization: Bearer <JWT>
// Accept-Language: en-US
// X-Currency: USD

export type Review = {
  user: User;
  comment: string;
  rating: number;
};

export type GetHotelDetailResponse = Hotel & {
  description: string;
  amenities: string[];
  address: string;
  reviews: Review[];
};

// --- Error Response (all endpoints) ---
export type ErrorResponse = {
  error: string;
  message: string;
  status: number;
};

Explanation

  • GET /api/hotels: Returns a paginated list of hotels or houses. Each hotel object includes core fields and a set of image URLs for the slideshow. Pagination is done via page and pageSize query params. You can pass Accept-Language or X-Currency headers for localized/currency-aware pricing.
  • GET /api/hotels/:idReturns detailed info for a single hotel. This expands the listing data and adds amenities, address, and reviews.
  • Error responses: All errors return a JSON object with an error string, a human-readable message, and a status code.

In production, you’ll also want to protect POST/PUT/DELETE endpoints with authentication. Hotel lists and details fetches can be public for our use case, but booking or user info would require a Bearer token.


Image Slider Design for Each Tile

Each tile features an interactive image slider for a modern hotel grid that lets users scroll or swipe through property photos. This is a critical component for user experience and conversion, so it needs to be fast, touch-friendly, and visually smooth.

Component Structure

Here’s how the component tree looks for a single tile with an image slider:


<BookingsCard>
  <ImageSlider images=[...] />
</BookingsCard>

BookingsCard handles the property’s details and hosts the ImageSlider component manages image navigation, touch events, and progressive image loading.

Libraries vs Custom Implementation

  • Using a library:
    There are many well-tested React image carousel libraries like react-slick, swiper.js, and keen-slider. These offer built-in touch, swipe, keyboard, and lazy-loading support.

    • Pros: Quick setup, polished UX, accessible, responsive out of the box, battle-tested for edge cases.
    • Cons: Adds to bundle size, less flexibility for deep customization, sometimes overkill for basic sliders.
  • Custom build:
    You can build your slider with React, using React useState for the index, and CSS for transitions.

    • Pros: Minimal code, complete control, can be tiny for simple use cases.
    • The cons: You must handle accessibility, swipe gestures, and performance optimizations yourself, which takes extra time and can introduce bugs.

For production, using a well-known library like swiper.js or It react-slick is usually the best bet, they’re optimized, accessible, and you avoid reinventing the wheel.

Performance Best Practices

  • Memoize the ImageSlider:
    Use React.memo or useMemo So the slider doesn’t re-render unless its props (the images) change. This is especially important in a grid where dozens of sliders are visible at once.
  • Prevent unnecessary image fetches:
    Only fetch images that haven’t already been loaded. Use browser caching or a custom image cache to avoid redundant network requests.
  • Lazy load images:
    By default, only load the first image. When a user clicks or swipes to the next image, fetch and render it just in time.
  • Prefetch on desktop hover:
    If a user hovers over a desktop tile, start prefetching the next image or two in the background. This makes navigation instant when the user clicks next.
  • Progressive image loading:
    Start with a low-res placeholder or blurred version, then swap in the full-res image when it finishes loading. Libraries like react-lazyload or native <img loading="lazy"> can help here.

Using a battle-tested library and layering on bright lazy loading and caching gives you a smooth, responsive slider without hammering bandwidth or sacrificing UX.


Optimizations: Graceful Loading, Failures, and More

For a hotel grid like this, the user experience is defined not just by fast loading, but by how gracefully the UI handles slow networks, image errors, and partial loads. Here’s how to design robust, resilient image and tile loading.

Graceful Loading States

  • Image Loading Indicators:
    Show a spinner, skeleton, or blurred placeholder while an image loads. The onLoad event on the <img> lets you trigger the swap to the real image when it’s ready.
  • Tile Placeholders:
    While hotel data is being fetched, render card skeletons or shimmer placeholders. This prevents layout shift and keeps the grid visually stable as content comes in.
  • Lazy Loading Tiles and Images:
    Use <img loading="lazy"> Or intersection observers to load images only when a tile is about to scroll into view. React’s lazy() and Suspense Let you defer loading heavy components until needed.

Error Handling and Smart Retry Logic

  • onError Handling:
    If an image fails to load, show a fallback image, a “broken” icon, or a user-friendly message. Never leave a blank space or broken UI.
  • Smart Retries:
    Automatically retry loading failed images a few times with a delay, then fall back to a static error image. Use exponential backoff for retries to avoid hammering the server.
  • Graceful Failures:
    If a tile’s data can’t be fetched (due to network or server error), display a card-level error message with a “retry” button, not just a blank space.
  • CDN Delivery:
    Host images and static assets on a Content Delivery Network (CDN) for lower latency and higher availability. This means images still load quickly even if your main API is slow.

Other Key Optimizations When You Design Airbnb

  • Progressive Image Loading:
    Load a tiny, blurred version first and fade in the high-res image for a smoother effect.
  • Resource Preloading:
    Use <link rel="preload"> for above-the-fold images and critical resources. On desktop, prefetch images on hover.
  • Component Memoization:
    Use React.memo and useMemo to prevent unnecessary re-renders, especially for image sliders and hotel cards that receive the same props.
  • Minimize Layout Shift:
    Always set explicit image width and height in Core Web Vitals to avoid Cumulative Layout Shift (CLS) penalties.
  • Accessibility:
    Make sure fallback images have alt text, and use ARIA labels for loading states so screen readers aren’t left out.
  • Cache Control:
    Set appropriate cache headers for API responses and images to reduce load times on repeat visits.

With these optimizations in place, your frontend will stay fast, reliable, and smooth, even on slow networks or partial failures. Users will never see a broken experience, and your grid will always feel modern and responsive.


Accessibility and Security

Accessibility (a11y)

  • Keyboard Navigation:
    All interactive elements (image sliders, buttons, tiles) should be fully navigable with the keyboard. Use tabIndex for custom components and ensure focus styles are visible.
  • Screen Reader Support:
    Use semantic HTML and ARIA roles/labels to describe tiles, images, buttons, and loading states. Each hotel card should have descriptive alt text for images, and the slider controls should be announced as previous/next image buttons.
  • Color Contrast:
    Make sure text and controls meet minimum contrast ratios for readability, even in low-vision or high-contrast mode.
  • Accessible Loading/Error States:
    Loading spinners and error messages should be labeled with aria-live so screen readers announce changes in real time.
  • Touch and Pointer Support:
    Sliders and buttons should respond to both mouse and touch events, making the app usable on any device.

Security

  • XSS (Cross-Site Scripting) Protection:
    Never render raw HTML from user-generated content. Always sanitize or escape text. Use React’s default escaping for text content, and if you ever use dangerouslySetInnerHTML, sanitize first.
  • CORS (Cross-Origin Resource Sharing):
    Set up your backend API and CDN with appropriate CORS headers to restrict which domains can access your resources. Only allow trusted origins (your frontend domain).
  • HTTPS Everywhere:
    Serve your site and APIs over HTTPS to protect data in transit, including authentication tokens and personal info.
  • Authentication:
    Use secure tokens (like JWT) for user authentication. Store them in HTTP-only cookies or secure storage to prevent access from JavaScript.
  • Rate Limiting & Abuse Prevention:
    Throttle API requests per user/IP to prevent brute force and abuse. Add backend validation on all inputs.
  • Content Security Policy (CSP):
    Use CSP headers to limit where scripts and resources can load from. This mitigates XSS risks even if something gets past your frontend.

By focusing on accessibility from the start and locking down security with best practices, you make your booking app usable for everyone and protect your users and data from common web threats.