Design a Calendar Application

Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2024-07-01

Problem Statement

Design a Calendar application that allows users to create, view, and manage events, set reminders, and share events with other users. Focus on class design, service interactions, and object-oriented principles.


Functional Requirements (FR)


1.User Management
•Register/login users.
•Manage user profiles (name, email, time zone).
2.Event Management
•Create, update, delete events.
•Event attributes: title, description, start time, end time, location, participants, reminders, recurrence rules.
•Support recurring events (daily, weekly, monthly, yearly).
3.Reminders & Notifications
•Notify users before event start (via email, push, or in-app).
•Customize reminder times per event.
4.Calendar Views
•Day, week, month, and agenda views.
•Filter events by categories, participants, or tags.
5.Sharing & Collaboration
•Invite participants to events.
•Accept/decline event invitations.
•View shared calendars of other users.
6.Time Zone Management
•Support users in different time zones.
•Display events in local time zone.
7.Search & Filters
•Search events by title, participants, or date range.
•Filter by categories or tags.


Non-Functional Requirements (NFR)


•Scalability – Support multiple users with overlapping events.
•Consistency – Ensure accurate event timings and notifications.
•Availability – App should be available 24/7.
•Low Latency – Fetching calendar views or creating events should be fast.
•Thread Safety – Handle concurrent updates to shared events.


Core Entities & Attributes


Entity Key Attributes


User userId, name, email, timeZone, calendarList

Calendar calendarId, ownerId, name, events, sharedWith

Event eventId, title, description, startTime, endTime, location, participants, reminders, recurrence, status

Reminder reminderId, eventId, userId, time, type (email/push/in-app)

Participant userId, eventId, status (accepted/declined/pending)


Service Layer / APIs


UserService


•createUser(name, email, timeZone)
•getUserDetails(userId)


CalendarService


•createCalendar(userId, name)
•shareCalendar(calendarId, participantId)
•getCalendarEvents(userId, calendarId, startDate, endDate)


EventService


•createEvent(calendarId, title, startTime, endTime, participants, recurrence)
•updateEvent(eventId, newDetails)
•deleteEvent(eventId)


ReminderService


•addReminder(eventId, userId, time, type)
•sendReminders()


Expectations in LLD


•Class Diagram – Show User, Calendar, Event, Participant, Reminder with relationships.
•Service Layer – UserService, CalendarService, EventService, ReminderService.
•Design Patterns –
•Observer pattern for sending reminders/notifications.
•Builder pattern for complex event creation (with recurrence and participants).
•Concurrency Considerations –
•Thread-safe updates for shared events.
•Conflict handling for overlapping events.
•Trade-offs –
•Real-time notifications vs batched reminders.
•Recurring events expansion vs storing as recurrence rules.


✅ This LLD problem tests:


•OOP and class design skills
•Service design and interactions
•Handling concurrency, notifications, and recurrence logic


Solution

Comments