$ show calcom/cal.diy
Cal.diy is a fully open-source, MIT-licensed fork of Cal.com, providing a self-hostable scheduling platform. It is a large monorepo containing a Next.js web application (apps/web) for booking pages, settings, and admin, a NestJS API (apps/api/v2) for platform REST endpoints, and extensive packages for business logic (packages/features), integrations (packages/app-store with 50+ apps), embeddable booking widgets (packages/embeds), and reusable React atoms (packages/platform/atoms). The architecture uses tRPC for client-server communication, Prisma ORM with PostgreSQL, Redis caching, and a custom dependency injection system (ioctopus) alongside NestJS DI. Key patterns include a tasker abstraction for async/sync background jobs (webhooks, emails, calendar sync), a versioned webhook payload builder factory, repository pattern over Prisma, and a consistent app-store integration structure. The platform exposes a public API with OAuth2, webhooks, and embeddable components for third-party developers. The codebase is actively maintained with frequent schema migrations and CI/CD pipelines, but exhibits some technical drift due to dual API surfaces (tRPC vs REST), stub implementations for enterprise features, and generated files that require regeneration.
The LLM identified 4 files worth highlighting for reuse:
Provides an abstract Tasker class with sync and async execution variants (e.g., BookingEmailAndSmsTasker, CalendarsTasker, WebhookTasker). Uses a DI container to inject task implementations and supports fallback between direct execution and Trigger.dev tasks. This pattern is reusable for any background job system and demonstrates clean separation of concerns.
Implements a factory for versioned webhook payload builders (e.g., v2021-10-20). Each builder (booking, payment, recording, OOO) extends a base class and implements canHandle/fetchEventData. The factory selects the correct builder based on event type and version. This pattern is reusable for any event-driven webhook system and handles backward compatibility cleanly.
A set of React hooks and UI components (e.g., useBooking, useEventType, useAtomUpdateSchedule, BookerEmbed) that wrap the platform API v2 endpoints. They provide a clean, typed interface for external consumers to embed scheduling functionality. The hooks use TanStack Query for caching and state management, and are designed to be extracted and used in any React application.
A factory that creates singleton adapters for calendar subscription providers (Google Calendar, Office365). It includes logic to filter out generic calendar suffixes (holidays, contacts, etc.) from subscriptions. The DefaultAdapterFactory uses lazy initialization and a get() method, making it easy to extend with new providers. This pattern is reusable for any multi-provider adapter system.