- 🔐 Google OAuth Authentication with NextAuth.js
- 📅 Calendar Event Management
- Create, read, update, and delete calendar events
- Split-view interface for efficient event management
- Real-time updates using React Query
- ⏰ Automated Call Alerts
- Twilio integration for phone calls
- Configurable notification timing
- Reliable delivery system
- Phone number verification with OTP
- 🔄 Robust Cron System
- Concurrent execution prevention
- Error handling and retries
- Performance monitoring
- 📊 Admin Dashboard
- Monitor cron job status
- View system performance
- Access error logs
- 🎨 Modern UI Components
- Built with Tailwind CSS and Shadcn UI
- Responsive design
- Accessible components
- OTP input with auto-focus
A Next.js 13 application that integrates with Google Calendar to manage events and provide automated call alerts through Twilio. Built with modern web technologies and focusing on reliability and performance.
This application provides a comprehensive solution for managing Google Calendar events with automated phone call notifications. It features a modern UI, efficient state management, and a robust background processing system.
- 🔐 Google OAuth Authentication using NextAuth
- 📅 Calendar Event Management (CRUD operations)
- ⏰ Automated Call Alerts using Twilio
- 🔄 Reliable Cron Job System
- 📊 Admin Dashboard for Monitoring
- 🎨 Modern UI with Tailwind CSS
/
- Landing page with authentication options/login
- OAuth login page
/calendar
- Calendar management with split view- Left panel: Create/Edit event form
- Right panel: Event list with edit/delete options
/admin
- Admin dashboard for monitoring cron jobs and system performance/profile
- User profile and preferences
GET/POST /api/auth/[...nextauth]
- NextAuth.js authentication endpoints
GET /api/calendar-events
- List calendar eventsPOST /api/calendar-events
- Create new eventPUT /api/calendar-events/[eventId]
- Update existing eventDELETE /api/calendar-events/[eventId]
- Delete event
GET /api/profile
- Get user profilePATCH /api/profile
- Update user profilePOST /api/otp/send
- Send OTP to phone numberPOST /api/otp/verify
- Verify OTP code
GET /api/notification-worker?action=status
- Get cron job statusGET /api/notification-worker?action=trigger
- Manually trigger cron jobGET /api/notification-worker?action=restart
- Restart cron jobGET /api/notification-worker?action=stop
- Stop cron job
src/
├── app/ # Next.js 13 App Router
│ ├── (protected)/ # Protected routes
│ │ ├── admin/ # Admin dashboard
│ │ ├── calendar/ # Calendar management
│ │ └── profile/ # User profile
│ ├── api/ # API routes
│ │ ├── auth/ # Authentication endpoints
│ │ ├── calendar-events/# Calendar CRUD operations
│ │ └── notification-worker/ # Cron job endpoints
├── components/ # React components
│ ├── ui/ # UI components
│ ├── AdminDashboard.tsx # Admin interface
│ ├── CalendarEvents.tsx # Events list
│ └── CreateEvent.tsx # Event form
├── lib/ # Core utilities
│ ├── callNotification.ts# Notification logic
│ ├── google.ts # Google Calendar integration
│ └── twilio.ts # Twilio integration
├── workers/ # Background workers
│ └── cronWorker.ts # Cron job implementation
└── types/ # TypeScript definitions
The cron system uses node-cron with the following features:
// Concurrent execution prevention
let isProcessing = false;
async function runNotificationJob() {
if (isProcessing) {
console.log('Previous job still running, skipping...');
return;
}
try {
isProcessing = true;
await processAllUsersNotifications();
} finally {
isProcessing = false;
}
}
// Scheduled execution
cron.schedule('*/5 * * * *', runNotificationJob);
-
Token Management
- Automatic refresh of expired tokens
- Graceful handling of auth failures
- Token caching for performance
-
Job Processing
- Individual user isolation
- Batch processing with limits
- Automatic retries for failed operations
-
Monitoring
- Detailed error logging
- Performance metrics collection
- Alert system for critical failures
The admin dashboard provides:
- Real-time cron job status
- Error logs and statistics
- Performance metrics
- Manual trigger option
-
React Query Implementation
- Efficient cache management
- Automatic background refetching
- Optimistic updates for better UX
-
API Optimization
- Pagination for event lists
- Debounced API calls
- Proper error boundary implementation
-
Component Architecture
- Lazy loading for route components
- Memoization of expensive computations
- Efficient re-render prevention
-
Database Queries
- Indexed fields for faster lookups
- Optimized MongoDB queries
- Connection pooling
Required environment variables:
# Authentication
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
NEXTAUTH_URL=
NEXTAUTH_SECRET=
# Database & Cache
MONGODB_URI=
REDIS_URL=
REDIS_TOKEN=
# Twilio Configuration
TWILIO_PHONE_NUMBER=
TWILIO_SID=
TWILIO_AUTH_TOKEN=
# Application Settings
ADMIN_EMAIL=
OTP_EXPIRY_SECONDS=30
Development:
npm install
npm run dev
Production:
npm run build
npm start
-
Frontend
- Next.js 13 (App Router)
- React 18
- TypeScript
- Tailwind CSS
- Shadcn UI
- Input OTP Component
- Radix UI Icons & Components
-
State Management
- React Query (TanStack Query)
- React Hook Form
- Zod Validation
- NextAuth Session Management
-
Backend & Data
- Next.js API Routes
- MongoDB with Mongoose
- Redis with Upstash
- Google Calendar API
- Twilio API
- node-cron
-
Development Tools
- ESLint
- Prettier
- TypeScript
- Turbopack (Development)
- Environment Validation (Zod)
-
Caching Strategy
- Use Edge caching for static assets
- Enable ISR for semi-static pages
-
Database Optimization
- Regular index maintenance
- Implement data archiving strategy
- Monitor query performance
-
API Enhancement
- Implement rate limiting
- Add request caching
- Use WebSocket for real-time updates
-
Monitoring
- Set up error tracking (e.g., Sentry)
- Implement performance monitoring
- Add automated alerts for system issues