Katkat

Design a multi-device calendar application

OpenAISoftware Engineer · Technical Screen

Last updated

This question tests the ability to design a distributed calendar system focusing on synchronization, conflict resolution for overlapping time slots, and efficient storage of recurring events.

Design a Multi-Device Calendar Application

Design the backend architecture for a calendar application (similar to Google Calendar) that supports multiple devices per user. The system must handle real-time sync, offline-first interactions, and recurring events.

Functional Requirements

  • Users can create, update, and delete calendar events.
  • Events support recurrence rules (e.g., "every Monday").
  • Users can view events within a specific time range (e.g., the current week).
  • Changes must be synced across multiple devices owned by the same user.

Non-Functional Requirements

  • High availability and consistency.
  • Low latency for fetching events.
  • Offline support: Users should be able to make changes offline, which sync when the connection is restored.

Requirements for your response:

  1. Data Model: Define the schema for events, including how to handle recurring rules and time zones.
  2. API Design: Define the primary REST or gRPC endpoints.
  3. Conflict Resolution: Propose a strategy for handling concurrent modifications when multiple devices update the same event while offline.
  4. Scalability: Describe how you would handle query-heavy loads, especially for "viewing" the calendar.

Example Constraints

  • 10 million daily active users.
  • Assume users have an average of 50 events per month.
  • Provide a high-level architecture diagram or description, focusing on the database choice and caching layers.

Hints

Hint 1

Consider using an expansion strategy for recurring events, but weigh the trade-offs of storing individual instances versus storing a rule string.

Hint 2

For offline synchronization, look into 'Vector Clocks' or 'Last-Write-Wins' (LWW) alongside a versioning system for event objects.

Hint 3

Think about how to use a caching layer like Redis to store the 'user view' for the current month to speed up read-heavy requests.

Follow-up questions

  • How would you implement 'shared calendars' where one user grants read or write access to another user?
  • If a user changes their time zone setting, how do you handle the potential shift in all historical and future event times?
  • How would you ensure the database remains performant when a user deletes a single instance of a recurring event series (an 'exception')?