Frontend School

Design a Real-time Multi-user Appointment Scheduling Widget

System Design
medium

Design a Real-time Multi-user Appointment Scheduling Widget

Medium
Frontend System Design
Calendar
Scheduling
Real-time
UI/UX
State Management
Performance

Overview

Nykaa frequently manages appointments for beauty consultations, store events, or internal meetings. We need a modern, responsive, and intuitive web-based calendar widget that allows users (e.g., beauty advisors, store managers) to view, create, and manage appointments efficiently. This problem focuses on the frontend system design of such a widget, emphasizing user experience, performance, and scalability for a multi-user environment.

What you need to do / Task

  1. Design the core UI components for a calendar view (monthly, weekly, daily).
  2. Outline the client-side data flow and state management for events and user interactions.
  3. Propose an API interaction strategy for fetching and updating appointment data.
  4. Address performance considerations for rendering a large number of events.
  5. Discuss how real-time updates for concurrent users would be handled on the frontend.

Scenario

Imagine a beauty advisor needs to schedule appointments with customers. They should be able to quickly see their availability, book new slots, and view details of existing appointments. Multiple advisors might be managing their own calendars, and a store manager might need an aggregated view. The system should feel responsive and reflect changes promptly across all active users.

Constraints

Constraints & assumptions

  • Users: Up to 100 concurrent users (beauty advisors, managers) actively using the widget.
  • Events: A user might have up to 50 appointments per week, with peak days having 15-20 appointments. A month view might display hundreds of events across all users being viewed.
  • Timeframe: Focus on a typical 3-month rolling window (past month, current month, next month) for data fetching.
  • Environment: Modern web browsers (Chrome, Firefox, Safari, Edge).
  • Backend: Assume a RESTful API for CRUD operations on appointments and a WebSocket-based service for real-time updates.
  • Responsiveness: The UI should be highly responsive, with interactions completed within 100-200ms.
  • Data Structure: An appointment object will typically include id, title, description, startTime, endTime, attendees (array of user IDs), creatorId, location.

Out of scope

  • Authentication and Authorization system design.
  • Detailed backend API implementation (focus on frontend interaction).
  • Deep integration with external calendar services (Google Calendar, Outlook).
  • Complex recurrence rules for appointments (simple recurring events are fine, but not advanced patterns).
  • Notification system for reminders.

What interviewers evaluate

  • Ability to break down the problem into logical frontend components and manage their state.
  • Understanding of data fetching strategies and API interaction for a dynamic UI.
  • Consideration of performance and user experience for a data-intensive application.
  • Approach to handling real-time updates and concurrent modifications.

Requirements

1.

Design a component hierarchy for monthly, weekly, and daily calendar views.

2.

Propose a state management strategy for appointment data, user selections, and view settings.

3.

Outline the client-side data fetching logic, including initial load and navigation.

4.

Describe how CRUD operations on appointments will interact with the backend API.

5.

Explain the mechanism for receiving and applying real-time updates from a WebSocket service.

6.

Detail at least two specific performance optimization techniques for rendering many events.

7.

Discuss how to handle potential data conflicts or race conditions between user actions and real-time updates.

Design Brief

You are tasked with designing the frontend system for a real-time multi-user appointment scheduling widget for Nykaa. This widget will be integrated into an internal portal used by beauty advisors and store managers.

Core Functionality

The widget needs to provide the following capabilities:

  1. Calendar Views: Display appointments in monthly, weekly, and daily views.
  2. Appointment Management: Users should be able to:
    • View existing appointments (title, time, attendees).
    • Create new appointments by selecting a time slot.
    • Edit existing appointment details (title, time, attendees, description).
    • Delete appointments.
  3. Real-time Updates: When an appointment is created, updated, or deleted by one user, other active users viewing the affected calendar period should see the changes reflected almost immediately.
  4. Multi-user Support: The widget should support displaying appointments for multiple users (e.g., a manager viewing multiple advisors' calendars) or filtering to a single user's calendar.

Design Considerations

1. UI Component Design

  • Calendar Grid: How would you structure the core calendar grid (month/week/day)? What components would you identify (e.g., CalendarDay, CalendarWeek, EventCard)?
  • Event Representation: How would individual appointments be rendered? What information is crucial at a glance, and what requires a detailed view?
  • Interaction: Consider drag-and-drop for rescheduling, click-to-edit, time slot selection for new appointments.

2. State Management

  • How would you manage the application's state on the frontend (e.g., current view, selected date, loaded events, user filters)?
  • What data structures would you use to store events efficiently for quick lookup and rendering across different views?
  • How would you handle local state vs. server-side state?

3. Data Fetching & API Interaction

  • Initial Load: Describe the API calls required to load the initial set of appointments for a given view (e.g., a month).
  • Pagination/Lazy Loading: How would you handle fetching data as the user navigates through time (e.g., clicking "next month") to avoid overwhelming the client or server?
  • Mutations: How would you send create, update, and delete requests to the backend API? What feedback mechanisms would you provide to the user during these operations?
  • Error Handling: How would you handle API errors gracefully?

4. Real-time Updates

  • Assuming a WebSocket connection is available, how would the frontend listen for and process real-time updates for appointments?
  • When a real-time update arrives, how would you ensure the UI is efficiently re-rendered without causing performance issues or flickers?
  • Consider potential race conditions between user actions (e.g., editing an event) and real-time updates for the same event.

5. Performance & Scalability

  • Rendering Performance: How would you optimize rendering for a calendar view potentially showing hundreds of events (e.g., virtualized lists, debouncing, memoization)?
  • Network Performance: Strategies for minimizing API calls and payload sizes.
  • Concurrency: How would your design handle multiple users interacting with the same appointment data simultaneously, specifically from the frontend perspective (e.g., optimistic updates, conflict resolution feedback)?

Deliverables

Please present your system design by focusing on:

  1. High-level Architecture Diagram: Illustrate the main frontend components, data flow, and interaction with backend services (API, WebSockets).
  2. Key UI Components: Describe the structure and responsibilities of core UI components.
  3. State Management Strategy: Detail how application state will be managed.
  4. API Interaction & Data Flow: Explain the lifecycle of fetching, creating, updating, and receiving real-time updates for appointments.
  5. Performance & Real-time Update Handling: Discuss specific techniques to ensure a smooth, responsive, and up-to-date user experience.

Loading editor...