Meeting Scheduler: low-level design

Design a meeting scheduler. Users invite others to a meeting at a time, the system books a free room, handles accept and decline, and avoids double booking people or rooms.

Stage 1: Time, users, calendars and rooms

Model who and when.

Everything depends on whether two time ranges overlap. `TimeRange.overlaps` is the one place that answers it. Users and rooms each own a `Calendar` that can say whether a range is free. Users and rooms are booked the same way, so the same calendar code serves both. A list scan per calendar is fine for a day's meetings. A sorted tree is the upgrade when a calendar holds thousands.

Stage 2: The meeting and the scheduler

Book a meeting if everyone and a room are free.

Nothing owns the booking flow: check people, find a room, save. `Scheduler.book` checks every attendee's calendar, picks a room, and adds the meeting to all calendars as one step. A single entry point means the 'free for everyone' rule is enforced once. Adding to several calendars must be all-or-nothing, so lock the calendars in a fixed order to avoid deadlock.

Stage 3: Choosing a room: Strategy

Make room selection swappable.

Some teams want the smallest room that fits, others the closest. A `RoomPicker` interface; `SmallestRoom` implements it and the scheduler asks it. A new policy is a new class (**Strategy**) and booking code is unchanged. The picker only suggests. The final booking still re-checks the room, because it may have been taken meanwhile.

Stage 4: Invites, reminders and repeats

React to changes and support recurrence.

People are not told about meetings, and weekly meetings need 52 separate bookings. `MeetingListener`s are called on create and cancel (`EmailNotifier` sends the invite). `RecurringMeeting` stores a rule and produces occurrences when needed. Notification is separate from booking (**Observer**). A rule stored once replaces thousands of rows. Expand occurrences lazily for a window (the next 3 months) and re-check conflicts for each.