A comprehensive Learning Management System with integrated MasterClass functionality, built with Next.js 15, Sanity CMS, Clerk authentication, and multi-provider payment processing. Features real-time content updates, course progress tracking, live session management, and professional admin interface.
- Access to comprehensive course content
- Real-time progress tracking
- Lesson completion system
- Module-based learning paths
- Multiple video player integrations (YouTube, Vimeo, Loom)
- Secure course purchases
- Mobile-friendly learning experience
- Course progress synchronization
- Live MasterClass enrollment and participation
- Automatic calendar invites for sessions
- Multi-payment method support (M-Pesa, Credit Cards)
- Rich content management with Sanity CMS
- Student progress monitoring
- Course analytics
- Customizable course structure
- Multiple video hosting options
- Real-time content updates
- Mobile-optimized content delivery
- Google Calendar integration for MasterClasses
- Automated session management
- Revenue tracking and analytics
- Professional admin interface via Sanity Studio
- Real-time analytics and performance monitoring
- MasterClass pricing and configuration management
- System health monitoring with alerts
- Payment method distribution tracking
- Revenue analytics by month and session
- Webhook performance monitoring
- User enrollment management
- Server Components & Server Actions
- Authentication with Clerk (modal-based sign-in)
- Multi-provider payment processing (IntaSend M-Pesa, Stripe)
- Content management with Sanity CMS
- Google Calendar API integration
- Modern UI with Tailwind CSS and shadcn/ui
- Responsive design
- Real-time content updates
- Protected routes and content
- Dark mode support
- Webhook processing for payment confirmation
- Email automation for session invites
- Performance monitoring and analytics
- Modern, clean interface
- Consistent design system using shadcn/ui
- Accessible components
- Smooth transitions and animations
- Responsive across all devices
- Loading states with skeleton loaders
- Micro-interactions for better engagement
- Dark/Light mode toggle
- Node.js 18+
- npm/yarn/pnpm
- Stripe Account
- IntaSend Account (for M-Pesa payments)
- Clerk Account
- Sanity Account
- Google Cloud Project (for Calendar API)
- Google Calendar
Create a .env.local file with:
# Sanity
NEXT_PUBLIC_SANITY_PROJECT_ID=your-project-id
NEXT_PUBLIC_SANITY_DATASET=production
# Read Token
SANITY_API_TOKEN=your-sanity-read-token
# Full Access Admin Token
SANITY_API_ADMIN_TOKEN=your-sanity-admin-token
# For Sanity Studio to read
SANITY_STUDIO_PROJECT_ID=your-project-id
SANITY_STUDIO_DATASET=production
# Next.js
NEXT_PUBLIC_BASE_URL=http://localhost:3000
# Stripe
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=your-stripe-publishable-key
STRIPE_SECRET_KEY=your-stripe-secret-key
STRIPE_WEBHOOK_SECRET=your-stripe-webhook-secret
# Clerk
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your-clerk-publishable-key
CLERK_SECRET_KEY=your-clerk-secret-key
# IntaSend (M-Pesa Payments)
INSTASEND_API_KEY=your-intasend-api-key
INSTASEND_PUBLISHABLE_KEY=your-intasend-publishable-key
INSTASEND_WEBHOOK_SECRET=your-intasend-webhook-secret
# Google Calendar API
GOOGLE_PROJECT_ID=your-google-project-id
GOOGLE_SERVICE_ACCOUNT_EMAIL=your-service-account@your-project.iam.gserviceaccount.com
GOOGLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYour-Private-Key\n-----END PRIVATE KEY-----"
GOOGLE_CALENDAR_ID=your-calendar-id@group.calendar.google.com
# Email Configuration
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-app-password# Clone the repository
git clone https://github.com/frankkinuthian/ndihub-v2
# Install dependencies
pnpm install
# Start the development server
pnpm dev
# In a separate terminal, start Sanity Studio
pnpm sanity:dev
# Access Sanity Studio admin interface
# Visit: http://localhost:3000/studio- Create a Sanity account
- Create a new project
- Install the Sanity CLI:
npm install -g @sanity/cli
- Initialize Sanity in your project:
sanity init
- Deploy Sanity Studio:
sanity deploy
- Create a Clerk application
- Configure authentication providers
- Set up redirect URLs
- Add environment variables
- Create a Stripe account
- Set up webhook endpoints:
/api/stripe/webhook - Configure payment settings
- Set up webhook forwarding for local development:
stripe listen --forward-to localhost:3000/api/stripe/webhook
- Create an IntaSend account
- Get API credentials from dashboard
- Configure webhook URL:
/api/intasend/webhook - For local development, use ngrok:
ngrok http 3000 # Use the https URL for webhook configuration
- Create a Google Cloud Project
- Enable Google Calendar API
- Create a service account
- Download service account key (JSON)
- Share your Google Calendar with the service account email
- Grant "Make changes to events" permission
- Extract credentials for environment variables
- Courses: Title, Description, Price, Image, Modules, Instructor, Category
- Modules: Title, Lessons, Order
- Lessons: Title, Description, Video URL, Content (Rich Text), Completion Status
- Students: Profile Information, Enrolled Courses, Progress Data
- Instructors: Name, Bio, Photo, Courses
- MasterClass Enrollments: Student, Session, Payment Details, Status
- MasterClass Analytics: Revenue tracking, Enrollment metrics, Performance data
- MasterClass Settings: System configuration, Pricing defaults, Email templates
- Performance Monitoring: System health, Webhook performance, Payment analytics
- Categories: Course categorization and organization
- Content creation and organization
- Module and lesson structuring
- Rich text editing
- Media integration
- Google Calendar integration for session scheduling
- Real-time enrollment tracking
- Automated email invitations
- Multi-currency pricing support
- Lesson completion
- Course progress calculation
- Module progress visualization
- Multi-provider support (IntaSend M-Pesa, Stripe)
- Secure checkout flows
- Webhook-based enrollment confirmation
- Real-time payment status updates
- Clerk authentication with modal sign-in
- Protected routes and content
- Role-based access control
- Sanity Studio-based admin panel
- Real-time analytics and monitoring
- System health tracking
- Performance metrics dashboard
- Access Sanity Studio at
/studio - Create course structure with modules and lessons
- Add content and media
- Publish course
- Create events in Google Calendar with "MasterClass" in the title
- Add pricing information in event description (Price: KES 2500, Premium)
- Include instructor and participant limit details
- Events automatically appear on the platform
- Browse available courses and MasterClasses
- Purchase and enroll using M-Pesa or credit card
- Receive automatic calendar invites for MasterClasses
- Access course content and track progress
- Mark lessons as complete
- View completion certificates
- Access admin interface at
/studio - Monitor system performance and analytics
- Track revenue and enrollment metrics
- Manage MasterClass pricing and settings
- View system health and webhook performance
/app # Next.js app directory
/(dashboard) # Dashboard routes
/(user) # User routes
/api # API routes
/components # React components
/sanity # Sanity configuration
/lib # Sanity utility functions
/schemas # Content schemas
/lib # Utility functions
- Frontend: Next.js 15, TypeScript, Tailwind CSS, shadcn/ui
- Backend: Next.js API Routes, Server Actions
- Database: Sanity CMS
- Authentication: Clerk
- Payments: Stripe (Credit Cards), IntaSend (M-Pesa)
- Calendar: Google Calendar API
- Email: Nodemailer with SMTP
- UI Components: Radix UI, Lucide Icons
- Development: ESLint, TypeScript, Hot Reload
- Flexible course structure with modules and lessons
- Rich text editor for lesson content
- Support for multiple video providers
- Course pricing and enrollment management
- Google Calendar integration for session scheduling
- Real-time enrollment with payment confirmation
- Automated email invitations with calendar attachments
- Multi-currency pricing (KES for M-Pesa, USD/EUR for Stripe)
- Live session management and participant tracking
- Progress tracking across all enrolled courses
- Lesson completion status
- Continue where you left off
- Course navigation with sidebar
- MasterClass enrollment history and upcoming sessions
- Multi-provider support (IntaSend M-Pesa, Stripe Credit Cards)
- Secure checkout flows with real-time confirmation
- Webhook-based enrollment processing
- Payment retry logic and error handling
- Revenue tracking and analytics
- Professional Sanity Studio-based admin panel
- Real-time analytics dashboard
- System performance monitoring
- MasterClass pricing management
- User enrollment tracking
- Revenue analytics by month and session
- Clerk authentication with modal sign-in
- Protected course content and MasterClass access
- Role-based access control
- Secure session management
- Webhook processing for payment confirmation
- Google Calendar API integration
- Email automation with SMTP
- Performance monitoring and alerting
- Error handling and graceful degradation
This project is licensed under the MIT License - see the LICENSE.md file for details
# Test Google Calendar integration
pnpm test:calendar-setup
# Test enrollment functionality
pnpm test:enrollment-debug
# Test webhook processing
pnpm test:webhook-debug
# Test MasterClass title fetching
pnpm test:event-titles
# Test admin permissions
pnpm test:admin-permissions
# Test analytics generation
pnpm test:analytics- Install dependencies:
pnpm install - Configure environment variables in
.env.local - Set up ngrok for webhook testing:
ngrok http 3000 - Configure payment provider webhooks with ngrok URL
- Start development server:
pnpm dev - Access admin interface:
http://localhost:3000/studio
Built with Next.js 15, Sanity CMS, Clerk Authentication, IntaSend, Stripe, and Google Calendar API