# Cal.com

> Open source scheduling infrastructure.

- Category: Productivity & Collaboration
- Difficulty: advanced
- Components: cal, postgres, prisma
- Tags: cal, scheduling, calendar, booking
- Source: https://docker.recipes/productivity/cal-com

## Overview

Cal.com is an open-source scheduling infrastructure that emerged as a privacy-focused alternative to proprietary booking platforms like Calendly. Built on Next.js and TypeScript, Cal.com provides comprehensive calendar management, appointment booking, and scheduling automation while maintaining full data ownership and customization control. The platform supports multiple calendar integrations, payment processing, team scheduling, and extensive API capabilities for custom workflows.

This stack combines Cal.com with PostgreSQL and Prisma ORM to create a robust, self-hosted scheduling solution. PostgreSQL serves as the primary database, handling user data, bookings, availability schedules, and calendar integrations with ACID compliance and strong consistency. Prisma acts as the database toolkit and ORM, providing type-safe database access, automated migrations, and seamless schema management that Cal.com relies on for its complex relational data models.

This configuration is ideal for organizations requiring scheduling infrastructure with complete data control, custom branding, and integration flexibility. Businesses can deploy Cal.com privately while leveraging PostgreSQL's enterprise-grade reliability for handling booking data, user authentication, and calendar synchronization. The stack scales from small teams to enterprise deployments, offering API access for custom integrations and webhook support for workflow automation.

## Features

- Multi-calendar integration with Google Calendar, Outlook, and CalDAV providers
- Team scheduling with round-robin, collective, and custom routing algorithms
- Payment integration with Stripe for paid consultations and booking fees
- Webhook system for real-time booking notifications and workflow automation
- REST and GraphQL APIs for custom scheduling applications and integrations
- Video conferencing auto-setup with Zoom, Google Meet, and Microsoft Teams
- PostgreSQL ACID compliance ensuring booking data integrity and consistency
- Prisma type-safe database operations with automated schema migrations

## Use cases

- SaaS companies needing white-label scheduling for customer success teams
- Healthcare practices requiring HIPAA-compliant appointment booking systems
- Consulting firms with complex team scheduling and client management needs
- Educational institutions managing office hours and student consultation bookings
- Service businesses integrating scheduling into existing customer portals
- Enterprises requiring scheduling APIs for internal tools and HR systems
- Development agencies building custom scheduling features for client applications

## Prerequisites

- Minimum 2GB RAM for PostgreSQL database and Cal.com application processes
- Port 3000 available for Cal.com web interface access
- SSL certificate and domain name for production calendar integrations
- SMTP server credentials for booking confirmation and notification emails
- OAuth application credentials for Google, Microsoft, or other calendar providers
- Basic understanding of Prisma migrations and PostgreSQL administration

## docker-compose.yml

```yaml
services:
  cal:
    image: calcom/cal.com:latest
    container_name: calcom
    restart: unless-stopped
    ports:
      - "3000:3000"
    environment:
      DATABASE_URL: postgresql://cal:${DB_PASSWORD}@db:5432/cal
      NEXTAUTH_SECRET: ${NEXTAUTH_SECRET}
      CALENDSO_ENCRYPTION_KEY: ${ENCRYPTION_KEY}
      NEXT_PUBLIC_WEBAPP_URL: http://localhost:3000
    depends_on:
      - db

  db:
    image: postgres:15-alpine
    container_name: calcom-db
    restart: unless-stopped
    environment:
      POSTGRES_USER: cal
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_DB: cal
    volumes:
      - calcom_db:/var/lib/postgresql/data

volumes:
  calcom_db:
```

## .env

```bash
DB_PASSWORD=changeme
NEXTAUTH_SECRET=generate-32-char-secret
ENCRYPTION_KEY=generate-32-char-key
```

## Usage notes

- Docs: https://cal.com/docs
- Access at http://localhost:3000 - create account on first visit
- Set availability schedule and event types
- Integrations: Google Calendar, Outlook, Zoom, Meet, Teams
- Generate secrets: openssl rand -hex 32
- Webhooks and API for custom integrations

## Troubleshooting

- Database connection failed: Verify PostgreSQL container is running and DATABASE_URL environment variable matches database credentials
- Calendar integration not working: Check OAuth redirect URLs match your NEXT_PUBLIC_WEBAPP_URL and calendar provider settings
- Prisma migration errors: Run docker exec calcom npx prisma db push to sync database schema with Prisma models
- NEXTAUTH_SECRET missing error: Generate a 32-character secret with openssl rand -hex 32 and add to environment variables
- Booking confirmations not sending: Configure SMTP settings in Cal.com admin panel and verify email server connectivity
- Database performance issues: Increase PostgreSQL shared_buffers and work_mem settings in custom postgres.conf volume mount

