Design Calendar
Difficulty: MEDIUMCategory: HLDFrequency: 1Asked On 2024-11-11
Problem Statement
Designing a Calendar System that allows users to create, manage, and share events. The system must support multiple devices, collaboration features, and real-time synchronization.
The problem is open-ended and can be extended into personal scheduling apps, team calendars, or enterprise collaboration tools.
✅ Functional Requirements
1.User Management
•Users can register, log in, and manage profiles.
•Authentication and authorization required.
2.Event Management
•Create, update, delete events.
•Events contain: (title, description, start_time, end_time, location, attendees, reminders).
•Support recurring events (daily, weekly, monthly).
•Handle overlapping/conflicting events.
3.Notifications & Reminders
•Send reminders via email, push notifications, or SMS.
•Support custom reminder intervals (10 mins before, 1 day before).
4.Collaboration & Sharing
•Users can share calendars with others (view/edit permissions).
•Invite participants to events (RSVP support: accept/decline/tentative).
5.Views & Visualization
•Day, week, month, and agenda views.
•Search events by keyword, time range, or participant.
6.Sync & Integration
•Multi-device synchronization.
•External integrations (e.g., Outlook, Zoom, Slack).
❌ Non-Functional Requirements
•Scalability: Support millions of users and billions of events.
•Low Latency: Real-time sync across devices.
•Consistency: Ensure event updates propagate reliably.
•Availability: High uptime (99.9%+).
•Security & Privacy: Protect personal and enterprise data.
🧱 System Components
1.API Gateway
•Exposes REST/GraphQL APIs for clients.
2.Calendar Service
•Core business logic for event CRUD, conflict detection, sharing.
3.Event Store (Database)
•Event data stored in a scalable DB (SQL for consistency + indexing by user/time).
•Recurring events stored with recurrence rules.
4.Notification Service
•Push reminders via email, SMS, or app push.
•Uses job scheduler (e.g., delayed queue).
5.Sync Service
•Real-time sync via WebSockets or long polling.
•Device synchronization logic.
6.Collaboration Service
•Manages shared calendars, permissions, and event invitations.
🔄 Example Flow
1.User creates event:
•Request: "Meeting with Team" on Aug 30, 10 AM – 11 AM, repeat weekly.
•Stored in DB with recurrence rule.
2.Invite participants:
•System sends invites via email/notifications.
•Attendees RSVP → status updated in DB.
3.Reminders:
•10 min before meeting → Notification Service triggers push/email.
4.Cross-device sync:
•Update on web reflects instantly on mobile app.
⚖️ Trade-offs / Design Considerations
•Recurring Events: Precompute vs. compute on query?
•Conflict Detection: Enforce globally (slow) or per-user calendar (fast)?
•Storage: SQL for transactions vs. NoSQL for scalability.
•Consistency vs. Availability: Event update sync → strong consistency or eventual?
•Multi-Tenancy: Support for both individual users and enterprise orgs.
🧪 Open Discussion Points
•How to handle time zones and daylight savings?
•How to ensure real-time sync at scale (millions of concurrent updates)?
•Should the system allow offline mode with conflict resolution?
•How to design notification service to handle billions of reminders efficiently?
👉 This problem tests system design around scheduling, event storage, notifications, sync, and collaboration.