MultiView Calendar Health Care Appointment Management System – Next.js, Postgresql FullStack Project (Role Based Access Control Admin Panel, Doctor & Patient Portal with Appointment Booking with Time Slot, Invitation System)
A modern, full-featured calendar and appointment management web application built with Next.js, React, and PostgreSQL. Perfect for healthcare, clinics, and organizations needing robust scheduling, filtering, and client management with multiple calendar views, instant search, advanced filtering, and a clean, responsive UI.
Live Demo: https://doctor-patient-calendar-appointment.vercel.app/

📋 Table of Contents
🎯 Project Overview
This is a comprehensive appointment management system designed for healthcare providers, clinics, and service businesses. It provides a complete solution for scheduling, managing appointments, handling invitations, and controlling access permissions. The application features three different calendar views (List, Week, Month), real-time filtering, search functionality, and a robust permission system.
Key Highlights
- Multi-View Calendar: Switch between List, Week, and Month views
- Real-time Search: Instant search across all appointment fields
- Advanced Filtering: Filter by category, patient, date, and status
- Invitation System: Send and manage appointment/dashboard invitations
- Permission Management: Role-based access control (owner, full, write, read)
- Responsive Design: Works seamlessly on desktop, tablet, and mobile
- Type-Safe: Built with TypeScript for better developer experience
- Modern UI: Clean interface using Tailwind CSS and shadcn/ui components
✨ Features
Calendar Views
- List View: Appointments grouped by date in a scrollable list format
- Week View: Weekly calendar grid showing appointments in time slots
- Month View: Monthly calendar grid with appointment indicators
Appointment Management
- Create, read, update, and delete appointments
- Add attachments, notes, activities, and assignees
- Set categories, locations, and status (done, pending, alert)
- Link appointments to patients and relatives
Search & Filtering
- Real-time search across title, notes, location, and patient information
- Filter by category, patient, date range, and status
- Combine multiple filters for precise results
Invitation System
- Send invitations for appointment access
- Send invitations for dashboard access
- Email notifications with secure token-based links
- Track invitation status (pending, accepted, declined)
Permission System
- Owner: Full control (creator of appointment)
- Full: Read, write, and delete access
- Write: Read and modify access
- Read: View-only access
User Management
- Secure authentication with custom JWT-based system
- Email verification required
- User profile management
- Session-based authentication with secure cookies
🛠️ Tech Stack
Frontend
- Next.js 15.4.10: React framework with App Router
- React 18.3.1: UI library
- TypeScript 5: Type-safe development
- Tailwind CSS 4: Utility-first CSS framework
- shadcn/ui: High-quality component library
- Radix UI: Accessible component primitives
- date-fns: Date manipulation and formatting
- Lucide React: Icon library
Backend & Database
- PostgreSQL: Self-hosted PostgreSQL database
- Direct database connection via
pg library
- Custom JWT-based authentication system
- Server-side permission validation
- Vercel Blob storage for attachments
Additional Libraries
- Nodemailer: Email sending functionality
- UUID: Secure token generation
- Redoc: API documentation
Development Tools
- ESLint: Code linting
- Turbopack: Fast bundler (Next.js)
- TypeScript: Static type checking
📁 Project Structure
multiview-calender-appointment/
├── public/ # Static assets
│ ├── favicon.ico # Site icon
│ └── redoc.html # API documentation
├── src/
│ ├── app/ # Next.js App Router
│ │ ├── api/ # API routes
│ │ │ ├── appointments/ # Appointment endpoints
│ │ │ │ ├── [id]/ # Dynamic route for specific appointment
│ │ │ │ │ ├── route.ts # GET, PUT, PATCH, DELETE
│ │ │ │ │ └── permissions/ # Permission endpoints
│ │ │ │ ├── route.ts # GET (list), POST (create)
│ │ │ │ └── search/ # Search endpoint
│ │ │ ├── invitations/ # Invitation endpoints
│ │ │ │ ├── accept/ # Accept invitation
│ │ │ │ └── route.ts # GET, POST invitations
│ │ │ ├── users/ # User search
│ │ │ ├── dashboard/ # Dashboard permissions
│ │ │ └── openapi/ # OpenAPI specification
│ │ ├── accept-invitation/ # Invitation acceptance page
│ │ ├── api-docs/ # API documentation page
│ │ ├── api-status/ # API health check page
│ │ ├── control-panel/ # Permission management
│ │ ├── login/ # Login page
│ │ ├── logout/ # Logout page
│ │ ├── register/ # Registration page
│ │ ├── layout.tsx # Root layout with metadata
│ │ ├── page.tsx # Home page (calendar)
│ │ └── AuthLayout.tsx # Authentication-based layout
│ ├── components/ # React components
│ │ ├── calendar/ # Calendar-related components
│ │ │ ├── AppointmentDialog.tsx # Create/edit appointment
│ │ │ ├── AppointmentList.tsx # List view
│ │ │ ├── CalendarHeader.tsx # View switcher & navigation
│ │ │ ├── MonthView.tsx # Month calendar view
│ │ │ ├── WeekView.tsx # Week calendar view
│ │ │ ├── Filters.tsx # Filter controls
│ │ │ ├── SearchBar.tsx # Search input
│ │ │ └── AppointmentHoverCard.tsx # Appointment preview
│ │ ├── control-panel/ # Permission management
│ │ │ ├── AppointmentAccessPermission.tsx
│ │ │ ├── UserAccessPermission.tsx
│ │ │ └── InvitationList.tsx
│ │ ├── ui/ # Reusable UI primitives
│ │ │ ├── button.tsx
│ │ │ ├── dialog.tsx
│ │ │ ├── input.tsx
│ │ │ ├── select.tsx
│ │ │ └── ...
│ │ ├── AuthGuard.tsx # Route protection
│ │ ├── login/ # Login component
│ │ ├── register/ # Registration component
│ │ └── navbar/ # Navigation bar
│ ├── context/ # React Context providers
│ │ ├── DateContext.tsx # Global date state
│ │ └── AppointmentColorContext.tsx # Color management
│ ├── lib/ # Utility libraries
│ │ ├── postgresClient.ts # PostgreSQL database client
│ │ ├── auth.ts # Custom JWT authentication
│ │ ├── vercelBlob.ts # Vercel Blob storage client
│ │ ├── session.ts # Session management
│ │ ├── email.ts # Email sending
│ │ ├── permissions.ts # Permission checking
│ │ └── utils.ts # General utilities
│ ├── types/ # TypeScript type definitions
│ │ ├── types.ts # Main types
│ │ └── invitation.ts # Invitation types
│ └── styles/
│ └── globals.css # Global styles
├── migrations/ # Database migration SQL files
│ ├── 001_initial_schema.sql # Initial database schema
│ ├── 002_add_password_to_users.sql # Password authentication support
│ └── 003_add_performance_indexes.sql # Performance optimizations
├── scripts/ # Database utility scripts
│ ├── migrate.ts # Run database migrations
│ ├── seed.ts # Seed database from CSV files
│ ├── check-users.ts # List all users in database
│ └── manage-user.ts # Manage user verification/passwords
├── package.json # Dependencies
├── tsconfig.json # TypeScript config
├── next.config.ts # Next.js config
├── tailwind.config.ts # Tailwind config
└── README.md # This file
🚀 Getting Started
Prerequisites
Before you begin, ensure you have the following installed:
- Node.js 18.x or higher
- npm or yarn or pnpm package manager
- Git for version control
- A PostgreSQL database (self-hosted or cloud provider)
- A Vercel account (for Vercel Blob storage, free tier works)
🔐 Environment Variables
Create a .env.local file in the root directory with the following variables:
Required Environment Variables
# PostgreSQL Database Configuration
# Format: postgresql://username:password@host:port/database
DATABASE_URL=postgresql://username:password@host:port/database
# Authentication Secret (JWT)
# Generate with: openssl rand -base64 32
AUTH_SECRET=your-jwt-secret-key-here
# Application Base URL
# For local development: http://localhost:3000
# For production: https://your-domain.com
NEXT_PUBLIC_BASE_URL=http://localhost:3000
# Vercel Blob Storage
# Get from Vercel Dashboard → Storage → Blob
BLOB_READ_WRITE_TOKEN=vercel_blob_rw_xxxxxxxxxxxxx
# Email Configuration (Gmail SMTP)
# For Gmail, you'll need to:
# 1. Enable 2-Factor Authentication
# 2. Generate an "App Password" in Google Account settings
EMAIL_USER=your-email@gmail.com
EMAIL_PASS=your-app-password
How to Get Database Credentials
- Set Up PostgreSQL Database:
- Use a self-hosted PostgreSQL instance, or
- Use a cloud provider (AWS RDS, DigitalOcean, Hetzner, etc.)
- Create Database and User:
- Create a database for the project
- Create a user with appropriate permissions
- Note the connection details (host, port, database name, username, password)
- Format Connection String:
- Use format:
postgresql://username:password@host:port/database
- Example:
postgresql://myuser:mypass@localhost:5432/myapp_db
How to Get Vercel Blob Token
- Create Vercel Account: Go to vercel.com and sign up
- Create a Blob Store:
- Go to your Vercel project dashboard
- Navigate to Storage → Blob
- Click "Create Database" (if first time) or "Create Blob Store"
- Give it a name (e.g., "appointments-attachments")