Skip to main content

Design a Meeting Scheduler System

Problem Statement

Design a meeting scheduler system that allows users to create meetings, invite participants, and check availability before confirming a meeting. The system should prevent overlapping meetings for any participant and should maintain a schedule for each user.


Functional Requirements

  • Users should be able to schedule meetings with a start and end time
  • System should prevent overlapping meetings for any participant
  • Users can invite multiple participants to a meeting
  • Each user should maintain their own meeting calendar
  • System should allow cancellation of meetings
  • Cancelled meetings should free up participant schedules

Objects Required

  • User
  • Meeting
  • Calendar
  • TimeSlot
  • MeetingSchedulerService

TimeSlot Class


public class TimeSlot {

    private String startTime;
    private String endTime;

    public TimeSlot(String startTime, String endTime) {
        this.startTime = startTime;
        this.endTime = endTime;
    }

    public boolean overlaps(TimeSlot other) {

        return !(this.endTime.compareTo(other.startTime) <= 0 ||
                 this.startTime.compareTo(other.endTime) >= 0);
    }
}

The constructor initializes a time slot with a start and end time, which represents a scheduled interval for a meeting.

The overlaps() method checks whether two time intervals conflict. It ensures that no two meetings can occupy the same time window for a user, which is the core rule of the scheduler.


Meeting Class


import java.util.*;

public class Meeting {

    private String meetingId;
    private TimeSlot timeSlot;
    private List participants;

    public Meeting(String meetingId, TimeSlot timeSlot, List participants) {
        this.meetingId = meetingId;
        this.timeSlot = timeSlot;
        this.participants = participants;
    }

    public TimeSlot getTimeSlot() {
        return timeSlot;
    }

    public List getParticipants() {
        return participants;
    }
}

The constructor creates a meeting with a time slot and a list of participants.

The getTimeSlot() method exposes the scheduled time so it can be validated against user calendars.

The getParticipants() method returns all invited users so their calendars can be updated consistently.


Calendar Class


import java.util.*;

public class Calendar {

    private List meetings = new ArrayList<>();

    public boolean canSchedule(TimeSlot slot) {

        for (Meeting meeting : meetings) {
            if (meeting.getTimeSlot().overlaps(slot)) {
                return false;
            }
        }
        return true;
    }

    public void addMeeting(Meeting meeting) {
        meetings.add(meeting);
    }

    public void removeMeeting(Meeting meeting) {
        meetings.remove(meeting);
    }
}

The constructor initializes an empty calendar for each user.

The canSchedule() method ensures that a new meeting does not conflict with existing meetings. This is the core validation step that prevents double-booking.

The addMeeting() method adds a confirmed meeting to the user’s calendar.

The removeMeeting() method removes a meeting when it is cancelled, freeing up the time slot.


User Class


public class User {

    private String userId;
    private String name;
    private Calendar calendar;

    public User(String userId, String name) {
        this.userId = userId;
        this.name = name;
        this.calendar = new Calendar();
    }

    public Calendar getCalendar() {
        return calendar;
    }
}

The constructor initializes a user along with their personal calendar, which stores all their scheduled meetings.

The getCalendar() method allows the scheduler service to check availability and update meetings for that user.


MeetingSchedulerService Class


import java.util.*;

public class MeetingSchedulerService {

    public Meeting scheduleMeeting(String meetingId,
                                   TimeSlot slot,
                                   List users) {

        for (User user : users) {
            if (!user.getCalendar().canSchedule(slot)) {
                System.out.println("User not available: " + user);
                return null;
            }
        }

        Meeting meeting = new Meeting(meetingId, slot, users);

        for (User user : users) {
            user.getCalendar().addMeeting(meeting);
        }

        return meeting;
    }

    public void cancelMeeting(Meeting meeting) {

        for (User user : meeting.getParticipants()) {
            user.getCalendar().removeMeeting(meeting);
        }

        System.out.println("Meeting cancelled successfully");
    }
}

The constructor is implicit since this service does not maintain state and only coordinates scheduling logic.

The scheduleMeeting() method first validates availability for all participants. If even one user is busy, the meeting is rejected to maintain consistency across calendars. If all users are free, the meeting is created and added to every participant’s calendar.

The cancelMeeting() method removes the meeting from all participant calendars, ensuring the time slot becomes available again.


Main Class


import java.util.*;

public class Main {

    public static void main(String[] args) {

        User u1 = new User("U1", "Alice");
        User u2 = new User("U2", "Bob");

        TimeSlot slot = new TimeSlot("10:00", "11:00");

        MeetingSchedulerService service = new MeetingSchedulerService();

        Meeting meeting = service.scheduleMeeting(
                "M1",
                slot,
                Arrays.asList(u1, u2)
        );

        if (meeting != null) {
            System.out.println("Meeting scheduled successfully");
        }

        service.cancelMeeting(meeting);
    }
}

The main method demonstrates a full scheduling flow starting from user creation to meeting scheduling and cancellation.

It shows how the system ensures no overlapping meetings while keeping all participant calendars in sync.


Class Diagram

UseruserId : Stringname : Stringcalendar : CalendarCalendarmeetings : List<Meeting>canSchedule(slot) : booleanaddMeeting(meeting) : voidremoveMeeting(meeting) : voidMeetingmeetingId : StringtimeSlot : TimeSlotparticipants : List<User>getTimeSlot() : TimeSlotgetParticipants() : List<User>TimeSlotstartTime : StringendTime : Stringoverlaps(slot : TimeSlot) : booleanMeetingSchedulerServicescheduleMeeting(id, slot, users) : MeetingcancelMeeting(meeting : Meeting) : void

Comments

Popular posts from this blog

Most Frequently Asked Low Level Design(LLD) Interview Questions

Below are the curated list of most commonly asked Low Level Design (LLD) interview problems. Each problem includes a short description and a link to the complete solution with code and class diagrams. Design Parking Lot System The system should handle parking for different vehicle types such as bikes, cars, and trucks. It should manage slot allocation, availability tracking, and entry/exit flow. The design also ensures efficient usage of parking space under varying load conditions. View Solution Design Elevator / Lift System The system should support multiple elevators operating across floors with request handling logic. It focuses on scheduling algorithms to minimize wait time and optimize movement. It also manages direction control and concurrent floor requests. View Solution Design Movie Ticket Booking System The system should allow users to browse movies, select shows, and book seats. It handles seat ...

Designing a Parking Lot - Low Level Design

Problem Statement Design a parking lot that can handle vehicles entering and leaving while managing parking across multiple floors. Each vehicle should be assigned a suitable parking spot based on its type, and the spot should be freed once the vehicle exits. The design should also support generating a ticket at entry and optionally calculating the parking fee based on the duration of stay. Asked In Companies Amazon Google Microsoft Uber Walmart Flipkart Meta PayPal Oracle Salesforce Adobe Apple Intuit LinkedIn Atlassian Functional Requirements The design should support multiple vehicle types such as bikes, cars, and trucks A vehicle must be assigned a parking spot compatible with its type A parking spot cannot be assigned to more than one vehicle at a time The parking lot should support multiple levels (floors) The design should search and allocate an availa...

Design an AI Agent Tool Execution Coordinator

Problem Statement Design an autonomous AI Agent Tool Execution Coordinator (similar to the orchestration cores of LangChain, Semantic Kernel, or Claude Desktop agent runtimes). The engine must coordinate agents by parsing structured tool call requests emitted by a Language Model (LLM), invoking corresponding local Java code methods dynamically by name using reflection, appending execution outputs back to the context history, and driving the agentic loop iteratively until a final synthesized text answer is generated. Additionally, to prevent token limit errors in long-running sessions, the engine must perform proactive context-window pruning, dropping the oldest historical messages while strictly preserving the system instructions template at the head of the context. Asked In Companies OpenAI Anthropic Google Microsoft Design Decisions & Patterns Used Modern agentic AI systems use dynamic tool execution to interact with external databas...