How to design a calendar (frontend)
The first sections are free. The deep dives, level expectations and quiz are part of Pro.
On this page
- The problem
- Clarifying questions
- The requirements menu
- Non-functional requirements
- Core entities
- The API
- The high-level design
- What breaks first
- The deep dives
- Entity fields
- Events that repeat
- Laying out a busy day
- Editing an event and seeing it at once
- A month with thousands of events
- Variants
- What each level is expected to show
- The 30-second answer
- Quiz
The problem
A web calendar: day, week and month views over events that may repeat without an end date, that several people can edit, and that are read from whatever time zone the viewer is in. The answer turns on one fact: a repeating event may have no last occurrence, so the client keeps the rule and works out occurrences for the dates on screen, and the rest of the design (fetching by range, laying out a crowded day, showing an edit before the server answers) follows from treating the visible range as the unit of work.
Clarifying questions
| Ask | Why it matters | A typical answer |
|---|---|---|
Does the server send repeating events as rules, or already worked out into occurrences? | It decides whether the client needs a rule expander and an exceptions map, or just a list of events per range. Most of the repeating-events discussion depends on this. | Rules. |
How busy is a calendar at the top end? | It sizes the day layout, the month view and the expansion of a repeating event, and tells you which of those is the first to hurt. | Say 50 events in a busy day, 1,000 in a heavy month with several shared calendars on, and a daily event that repeats 36,500 times over 100 years. |
Can two people edit the same event at the same time? | Shared calendars make a conflict possible, which decides whether an edit carries a version and what the person sees when the server refuses it. | Yes. Shared calendars are in scope, so a |
Which time zones matter: the viewer's, the event's, or both? | A series that keeps its local time across daylight saving changes has to be expanded in its own zone, and the viewer's zone is applied afterwards. If the answer is one zone, that work goes away. | Both. Each event carries its zone, and the viewer may be somewhere else; each event must show at the right local time for the viewer, across daylight saving changes. |
Does it have to work offline? | Offline means a local store of record, a queue of edits and a reconciliation step, which is a different question. | No. Working offline is out of scope, as are reminders, room booking and finding a free time for a group. |
Who uses it, and with what input? | Keyboard and screen reader support change the markup of the grid from the first step, rather than being added at the end. | Anyone. The grid must work by keyboard and with a screen reader, and a click or a drag must answer within 200 milliseconds. |
Which views, and which is the widest? | The widest view bounds how many occurrences a rule is expanded into and how large a fetched range gets. | Day, week and month, and the person moves between them. Month is the widest, so a range is a month at most. |
Non-functional requirements
| Requirement | What it forces |
|---|---|
A busy day of 50 events draws without lag, and a drag runs at 60 frames a second | The day layout (sort, group, assign columns) runs once per change of the day's events and is cached, not once per frame. During a drag the moved card is translated with a |
A click or a drag answers within 200 milliseconds | An edit shows on the grid before the server replies: the store is updated at once, the request goes out with the event's version, and the change is reverted with a message if the server refuses. A new event gets a temporary id so it can be drawn and even edited before the server names it. |
Every event shows at the right time in the viewer's time zone, across daylight saving changes | Times are kept as an instant plus the event's zone, not as a bare UTC string. A series is expanded in its own zone so a daily nine o'clock stays at nine o'clock after a daylight saving change, and each occurrence is converted to the viewer's zone afterwards. The day an event lands on is computed in the viewer's zone too, since the UTC date can differ from it. |
The grid works by keyboard and with a screen reader | The calendar is marked up as a grid of rows and cells with the roles assistive technology expects, one tab stop with arrow keys moving between cells, a visible label for the grid, and an announcement when an event is moved or an edit is refused. Dragging has a keyboard equivalent: pick up, move in steps, drop. |
Core entities
| Entity | What it holds |
|---|---|
Calendar | One source of events, shown or hidden as a whole, drawn in its own color. |
Event | A single event, or the head of a series when it carries a repeat rule. |
Exception | One occurrence of a series that differs from what the rule would produce, or has been removed. |
Invitation | One person asked to one event, and what they said. |
Client state | What the page knows right now, kept in one place so views, layout and edits read the same data. |
The API
| Endpoint | Notes |
|---|---|
| The one read. The client asks for the widest range it will show, a month at most, and gets single events, series with their rules and exceptions, each series once. |
| Create, with an optional repeat rule and a guest list. The client draws the event under a temporary id as soon as the form is submitted and swaps in the server's id from the response. |
| Edit. For a series, |
| Delete with the same three scopes: a canceled exception, a series that ends before this occurrence, or the whole series. |
| The viewer's answer to an invitation. Shown at once beside their name and reverted if refused, like any other edit. |
The high-level design
Step 1 of 5
A grid that asks the server for what it shows
Start with the smallest thing that draws a calendar: the grid knows its view and date, asks the server for events in that span, keeps the answer in a client store and draws it. It already shows the shape of the data flow, and it already has the problems the rest of the design answers: moving a week forward asks the server again for days it just had, a repeating event has to arrive as separate events, a crowded day draws cards on top of each other, and nothing changes on screen until the server replies.
What breaks first
The deep dives
Events that repeat. Someone sets up a daily stand-up with no end date, and the next week drags a single occurrence to the afternoon. What does your client store, what does it send, and how does the following Tuesday's stand-up get drawn?
A concept that helps here: Recurrence rules and time zones
A concept that helps here: Client caching and normalized storesLaying out a busy day. A Tuesday holds 50 meetings, many overlapping by a few minutes. How does the day view decide each one's width and left edge, and what happens to that work while one of them is being dragged?
A concept that helps here: Laying out overlapping events in a time grid
A concept that helps here: Drag and drop, and keeping orderA concept that helps here: Accessible widgetsEditing an event and seeing it at once. Someone drags a meeting from 2 PM to 3 PM on a slow connection. What is on their screen during the wait, and what changes when the server answers that someone else edited the meeting first?
A month with thousands of events. Someone turns on five busy shared calendars and the month on screen holds more than a thousand events. What does the page fetch, what does it draw, and what happens when they switch to a week inside that month?
Concepts this guide uses
- Recurrence rules and time zones
- Client caching and normalized stores
- Laying out overlapping events in a time grid
- Drag and drop, and keeping order
- Accessible widgets
- Optimistic updates and rollback
- Conflict resolution on the client
- List virtualization
Sources
- Google Calendar API: Recurring events
- Google Calendar API: Calendars and events (instances and exceptions)
- Google Calendar API: Synchronize resources efficiently
- Google Calendar API: Get specific versions of resources (etags and If-Match)
- Nylas: How the Google Calendar API handles recurring events
- TabMail iOS pull request 569: keep the original end when a recurring series is split
- RFC 5545: Internet Calendaring and Scheduling Core Object Specification (iCalendar)
- icalendar.org: RFC 5545 section 3.8.5.3, Recurrence Rule
- techinterview.org: Design a mobile calendar, sync and recurrence
- Arghya Majumder (dev.to): Google Calendar, Day View
- Arghya Majumder (dev.to): Google Calendar day view HLD
- FullCalendar docs: lazyFetching
- FullCalendar docs: slotEventOverlap
- MDN: ARIA grid role
- web.dev: Web Vitals
- web.dev: Defining the Core Web Vitals metrics thresholds
- web.dev: Stick to compositor-only properties and manage layer count
- TanStack Query docs: Optimistic updates