Scope and Design a Restaurant Scheduling System
Company: Gusto
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Onsite
## Scope and Design a Restaurant Scheduling System
The initial prompt is simply “design a restaurant scheduling system.” Begin by distinguishing three plausible products: employee-shift scheduling, customer table reservations, and publication of restaurant opening hours. State which one you are designing and why its users and invariants differ from the others.
For the remainder of this exercise, design **employee-shift scheduling**. Restaurants publish staffing demand by role and time interval; employees provide availability and role qualifications; managers create, edit, and publish schedules. The system must identify conflicts and preserve an audit trail when a published schedule changes.
### Part 1 — Clarify Scope and Requirements
Identify actors, core workflows, and the questions that separate shift scheduling from reservations or opening-hours management.
#### What This Part Should Cover
- Manager, employee, and administrative responsibilities.
- Recurring availability versus dated exceptions.
- Draft, published, acknowledged, and changed schedule states.
- The meaning of a conflict and which rules are warnings versus hard blocks.
```hint Name the scheduled resource
Employees, tables, and business hours have different capacity, ownership, and conflict rules even though all three use time intervals.
```
### Part 2 — Model Schedules and Enforce Invariants
Propose the main entities and APIs. Explain how interval overlap, role qualification, availability, staffing demand, time zones, and overnight shifts are represented and checked.
#### What This Part Should Cover
- Stable restaurant, employee, role, shift, assignment, and schedule-version identities.
- Half-open time intervals and an explicit restaurant time zone.
- Prevention of overlapping assignments for one employee.
- A distinction between immutable published versions and editable drafts.
```hint Put time semantics in the model
An overnight shift and a daylight-saving transition should not depend on an ambiguous local timestamp string.
```
### Part 3 — Handle Concurrent Editing and Publication
Two managers may edit the same draft while employees update availability. Explain conflict detection, publication, notifications, and how readers obtain a coherent schedule.
#### What This Part Should Cover
- Optimistic version checks or another explicit concurrency strategy.
- A transactional publish boundary for assignments and schedule version.
- Revalidation against current availability before publication.
- Change notifications that are idempotent and traceable.
```hint Give every draft a version
A manager should learn that the draft changed instead of silently overwriting another manager's assignments.
```
### Part 4 — Scale, Test, and Operate the System
Discuss query patterns, storage indexes, background jobs, observability, and tests for scheduling-specific edge cases.
#### What This Part Should Cover
- Queries by restaurant and week, employee and date range, and unfilled demand.
- Indexes aligned with those access paths rather than a generic indexing claim.
- Tests for overlap boundaries, overnight work, time-zone transitions, and concurrent publication.
- Metrics for publish failures, unresolved conflicts, notification lag, and stale acknowledgments.
```hint Design around the weekly views
Start from the manager's restaurant-week view and the employee's personal upcoming-shifts view when choosing keys and indexes.
```
### What a Strong Answer Covers
- Resolves the ambiguity in “restaurant scheduling” before drawing architecture.
- Defines interval, qualification, conflict, and versioning semantics precisely.
- Keeps draft collaboration separate from atomic publication.
- Supports the actual manager and employee query patterns.
- Handles time zones, changes, notifications, and concurrent edits explicitly.
### Follow-up Questions
1. How would the model change if an employee can work at several restaurant locations?
2. What should happen when availability changes after a schedule is published?
3. Which rules belong in a configurable policy layer rather than database constraints?
4. How would you add shift swaps without allowing an unqualified employee to take a role?
Quick Answer: Scope an ambiguous restaurant scheduling prompt, then design an employee-shift system for demand, availability, qualifications, editing, and publication. Address schedule invariants, conflict detection, concurrent changes, audit history, notifications, and operational scale.