A comprehensive Next.js dashboard application for monitoring tutor performance, identifying at-risk tutors, and delivering data-driven interventions. Built with AI-powered pattern discovery, automated email alerts, and A/B testing capabilities.
- Real-time Performance Monitoring: Track tutor engagement, quality scores, and churn risk with live metrics
- Comprehensive Tutor Profiles: Detailed performance analytics, session history, and intervention recommendations
- Multi-Dimensional Analytics: Insights, reliability, engagement, first-session, and performer analysis dashboards
- Customizable Landing Page: Personalized dashboard configuration for different user roles
- AI-Powered Insights: Automated pattern discovery using OpenAI/OpenRouter/Anthropic with confidence scoring
- Automated Alerts: Email notifications for critical issues and engagement opportunities via Resend
- Pattern Discovery: Weekly automated analysis of tutor data to identify trends and anomalies
- Smart Recommendations: Data-driven intervention suggestions based on tutor performance patterns
- Intervention Campaigns: Targeted outreach builder with A/B testing via GrowthBook
- Experiment Tracking: Statistical analysis of intervention effectiveness
- Engagement Timeline: Visual tracking of tutor engagement events and interventions
- Framework: Next.js 16 (App Router)
- Language: TypeScript
- Database: PostgreSQL with Prisma ORM
- UI: shadcn/ui components, Tailwind CSS
- Visualization: Recharts
- AI: OpenAI, OpenRouter, Anthropic
- Email: Resend
- Experimentation: GrowthBook
- Data Generation: Python with pandas, scikit-learn
- Node.js 18+
- PostgreSQL (running locally or remote)
- Python 3.8+ (for data generation)
-
Clone and install dependencies:
npm install
-
Set up environment variables:
cp env.template .env
Edit
.envand configure:DATABASE_URL- PostgreSQL connection string- AI API key (one of):
OPENAI_API_KEY,OPENROUTER_API_KEY, orANTHROPIC_API_KEY RESEND_API_KEY- For email functionalityGROWTHBOOK_CLIENT_KEY- For experimentationNEXT_PUBLIC_APP_URL- Your app URL
-
Set up database:
# Create database createdb tutor_quality # Initialize schema npx prisma db push npx prisma generate
-
Generate and import data:
# Activate Python venv (if using) source venv/bin/activate # Generate synthetic data python tutor_data_gen.py --mode production # Import to database npm run import-data
-
Start development server:
npm run dev
Visit http://localhost:3000 to see the dashboard.
For detailed setup instructions, see QUICKSTART.md.
tutor/
├── app/ # Next.js app directory
│ ├── api/ # API routes
│ │ ├── alerts/ # Alert management
│ │ ├── analytics/ # Analytics endpoints
│ │ ├── cron/ # Scheduled jobs
│ │ ├── dashboard/ # Dashboard data
│ │ ├── email-preview/ # Email template preview
│ │ ├── engagement/ # Engagement tracking
│ │ ├── insights/ # Pattern insights
│ │ └── interventions/ # Intervention campaigns
│ ├── dashboard/ # Dashboard pages
│ │ ├── activation/ # Activation tracking
│ │ ├── alerts/ # Alert management
│ │ ├── engagement/ # Engagement metrics
│ │ ├── first-sessions/ # First session analysis
│ │ ├── insights/ # AI insights dashboard
│ │ ├── interventions/ # Campaign management
│ │ ├── performers/ # Star performer analysis
│ │ ├── reliability/ # Reliability metrics
│ │ └── tutors/ # Tutor profiles
│ └── providers/ # React context providers
├── components/ # React components
│ ├── dashboard/ # Dashboard-specific components
│ ├── landing/ # Landing page components
│ ├── tutor-detail/ # Tutor profile components
│ └── ui/ # shadcn/ui components
├── lib/ # Shared libraries
│ ├── ai/ # AI integration (pattern analysis)
│ ├── alerts/ # Alert generation logic
│ ├── analytics/ # Analytics calculations
│ ├── email/ # Email templates and sending
│ ├── experiments/ # GrowthBook integration
│ └── interventions/ # Intervention builder
├── prisma/ # Database schema
├── scripts/ # Utility scripts
│ ├── import-data.ts # CSV to database importer
│ ├── test-ai-connection.ts # AI API testing
│ └── *.py # Python data generation scripts
├── data/ # CSV data files
├── docs/ # Documentation
│ ├── features/ # Feature documentation
│ ├── implementation/ # Implementation guides
│ ├── integrations/ # Integration guides
│ └── pr/ # Pull request docs
└── public/ # Static assets
npm run dev- Start development servernpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLint
npm run import-data- Import CSV data to databasenpm run import-data:clear- Clear and re-import datanpm run generate-alerts- Generate alerts from tutor datanpm run demo-alerts- Create demo alerts (12 sample alerts)npm run demo-insights- Create demo AI insightsnpm run send-emails- Send pending email alerts
npm run test-ai- Test AI API connectionnpm run test-endpoints- Test API endpoints
- Overview KPI cards (Active Tutors, Churn Risk, Engagement Score, First Session Issues)
- Interactive engagement trends chart (7/14/30 day views)
- Churn risk priority table with filtering and pagination
- Quick access to tutor profiles and alerts
- Comprehensive tutor profile with status and certifications
- 9 performance metric cards with trend indicators
- 30-day performance charts (ratings vs quality scores)
- Session history table (last 50 sessions)
- AI-generated intervention recommendations with priority levels
- AI-discovered patterns and trends
- Pattern confidence scoring
- Actionable recommendations
- Historical insight tracking
- Alert overview by severity (Critical, High, Medium, Low)
- Filterable alert list with search
- Alert acknowledgment workflow
- Direct links to tutor profiles
- Rescheduling rate analysis
- No-show tracking and trends
- Reliability score distributions
- Tutor reliability rankings
- First session performance analysis
- Poor first session flag tracking
- Impact on tutor retention
- Intervention recommendations
- Engagement metrics and trends
- Engagement event timeline
- Engagement score distributions
- Tutor engagement rankings
- Star performer identification
- Performance comparisons
- Best practices analysis
- Recognition opportunities
- Campaign builder interface
- A/B test configuration
- Campaign performance tracking
- Experiment assignment and results
/api/dashboard/metrics- Dashboard KPIs/api/dashboard/tutors- Tutor list with filtering/api/alerts- Alert CRUD operations/api/insights- Pattern insights/api/interventions- Intervention campaigns/api/analytics/*- Various analytics endpoints/api/cron/*- Scheduled background jobs
See docs/implementation/API_ENDPOINTS_IMPLEMENTATION.md for full API documentation.
- QUICKSTART.md - Get started in 5 minutes
- README_SETUP.md - Additional setup information
- FREE_TIER_GUIDE.md - Deploy completely free
- docs/features/EMAIL_ALERTS_README.md - Email alert system
- docs/features/INTERVENTION_CAMPAIGNS_QUICKREF.md - Intervention campaigns
- docs/features/insights-dashboard.md - AI insights dashboard
- docs/features/UI_COMPONENTS_QUICKREF.md - UI components reference
- docs/implementation/API_ENDPOINTS_IMPLEMENTATION.md - API documentation
- docs/PROJECT_STATUS.md - Current project status
- docs/90_DAY_ROADMAP.md - Future development roadmap
- docs/integrations/ - Setup guides for AI, email, GrowthBook
- DEPLOYMENT_GUIDE.md - Step-by-step deployment
- DEPLOYMENT_CHECKLIST.md - Deployment checklist
- DATABASE_SETUP.md - Database configuration
- ENV_VARS_SETUP.md - Environment variables
See env.template for all available environment variables. Key variables:
DATABASE_URL- PostgreSQL connection string (required)OPENAI_API_KEY/OPENROUTER_API_KEY/ANTHROPIC_API_KEY- AI API key (one required)RESEND_API_KEY- Email service API keyGROWTHBOOK_CLIENT_KEY- GrowthBook client keyNEXT_PUBLIC_APP_URL- App URL for email linksCRON_SECRET- Secret for cron job authentication
The application uses PostgreSQL with Prisma ORM. Main models include:
- Tutor: Profile information, experience, subjects, certifications
- Session: Individual session records with quality metrics (engagement, empathy, clarity, satisfaction)
- TutorAggregate: Pre-calculated 7d/30d aggregates and churn predictions
- Alert: Generated alerts for tutor issues with severity levels and acknowledgment tracking
- Intervention: Intervention campaigns with A/B test configurations
- PatternInsight: AI-discovered patterns with confidence scores and recommendations
- Experiment: A/B test configurations and assignments via GrowthBook
- EngagementEvent: Engagement tracking events and timeline
See prisma/schema.prisma for the complete schema definition.
- Update Prisma schema if database changes needed
- Run
npx prisma db pushto apply changes - Create API routes in
app/api/ - Build UI components in
components/ - Add pages in
app/dashboard/ - Update documentation
- Test database connection: Visit
/api/test-db - Test AI connection:
npm run test-ai - Test endpoints:
npm run test-endpoints
The application is configured for Vercel deployment with PostgreSQL database and automated cron jobs.
-
Prerequisites:
- Vercel account (Pro plan required for cron jobs)
- PostgreSQL database (Vercel Postgres recommended)
- API keys for AI, email, and optional services
-
Deployment Steps:
# Install Vercel CLI (if not already installed) npm i -g vercel # Login and link project vercel login vercel link # Create database (via Vercel dashboard or CLI) # Set environment variables in Vercel dashboard # Run migrations npx prisma migrate deploy # Deploy vercel --prod
- DEPLOYMENT_CHECKLIST.md - Complete deployment checklist
- DEPLOYMENT_GUIDE.md - Step-by-step deployment guide
- DATABASE_SETUP.md - Database setup instructions
- ENV_VARS_SETUP.md - Environment variables configuration
- DATABASE_MIGRATION.md - Database migration guide
- DEPLOYMENT_VERIFICATION.md - Post-deployment verification
For demo deployments, you can run completely free:
- Use
vercel.free-tier.json(daily cron jobs, works on Hobby plan) - Set
DISABLE_AI=trueto avoid AI API costs (uses mock data) - Use Neon or Supabase free tier for database
- Resend free tier for email (100/day)
See FREE_TIER_GUIDE.md for complete free tier setup.
- Vercel Pro Plan ($20/month) - Required for hourly cron jobs
- PostgreSQL Database - Vercel Postgres or external provider
- Environment Variables - See
ENV_VARS_SETUP.mdfor complete list - CRON_SECRET - Generated secure string for cron authentication
The application includes automated cron jobs (requires Vercel Pro):
- Alert generation: Every hour
- Email sending: Every 6 hours
- Pattern discovery: Weekly (Mondays 2 AM)
See vercel.json for configuration. Cron endpoints are protected with CRON_SECRET.
scripts/deploy.sh- Interactive deployment scriptscripts/migrate-database.sh- Database migration helperscripts/setup-env-vars.sh- Environment variables setup guidescripts/setup-database.sh- Database setup helper
For more details, see the deployment documentation files listed above.
- Create a feature branch
- Make your changes
- Update documentation as needed
- Test thoroughly
- Submit a pull request
Built for Nerdy (Tutor.com) tutor quality monitoring system.
The application is production-ready with core features implemented:
- ✅ Core dashboard with real-time metrics
- ✅ AI-powered insights and pattern discovery
- ✅ Automated email alert system
- ✅ Intervention campaign builder
- ✅ Comprehensive analytics dashboards
- ✅ Tutor profile pages with recommendations
- ✅ Automated cron jobs for alerts and insights
See docs/PROJECT_STATUS.md for detailed status and docs/90_DAY_ROADMAP.md for future enhancements.
For issues or questions:
- Check the QUICKSTART.md guide for setup help
- Review docs/ for detailed documentation
- See troubleshooting sections in individual feature guides