calcom/cal.com
Calendar models (Selected and Destination)
Two complementary Prisma models that wire users to their calendars.
SelectedCalendar — what to read from
A SelectedCalendar row says "include this external calendar when computing busy times for this user." A user can have many. They are configured in the dashboard's calendar settings and managed by packages/features/selectedCalendar.
Schema highlights:
userId→Userintegration(e.g.,google_calendar)externalId— the calendar's vendor-side ID (Google calendar ID, Microsoft folder ID, ...)credentialId?→CredentialeventTypeId?— when set, this selection only applies to one event type (use-event-level-selected-calendars feature)
DestinationCalendar — what to write to
A DestinationCalendar row says "write confirmed bookings to this calendar." A user has at most one default; an event type can override with its own.
Schema highlights:
userId?→UsereventTypeId?→EventType(per-event override)integration,externalId,nameprimaryEmailcredentialId?→Credential
Relationship
graph LR
User --> SelectedCalendar
EventType --> DestinationCalendar
User --> DestinationCalendar
SelectedCalendar --> Credential
DestinationCalendar --> CredentialHow they're used
- SelectedCalendar is read by
packages/features/busyTimesto know which calendars to query for free/busy. - DestinationCalendar is read by
packages/features/bookings/lib/EventManager.tsat booking time to choose where the calendar event lands.
The split makes it possible to say "merge availability from my work + personal calendars, but only book to my work calendar" — a common requirement that single-calendar systems don't handle well.
Where the code lives
| Concern | File |
|---|---|
| Selected calendars domain | packages/features/selectedCalendar |
| Destination calendar domain | packages/features/calendars (alongside the wider calendar federation) |
| Settings UI | apps/web/modules/settings/.../calendars and packages/platform/atoms/calendar-settings/, selected-calendars/, destination-calendar/ |
| API v2 modules | apps/api/v2/src/modules/selected-calendars, apps/api/v2/src/modules/destination-calendars, apps/api/v2/src/modules/cal-unified-calendars |
Related pages
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.