An intelligent, emotion-aware AI tutoring platform with voice interaction, real-time emotion detection, and adaptive learning.
Built with Next.js 16, TypeScript, Supabase (Auth + Database), and cutting-edge AI technologies.
- Voice Interaction - Natural voice conversations with AI tutor (spacebar to speak)
- Emotion Detection - Real-time camera-based emotion recognition with adaptive responses
- Adaptive Learning - Content dynamically adjusts based on emotions and progress
- Interactive Slides - AI-generated learning slides with visual explanations
- Smart Notes - Auto-generated notes from learning sessions
- Quiz System - AI-generated quizzes with detailed analytics
- Dashboard Analytics - Comprehensive learning statistics and insights
- Achievement System - Gamification with auto-unlocking achievements
- Streak Tracking - Daily learning streaks and motivation
- Session History - Full session analysis and resume capability
- Structured Courses - Multiple courses across different topics
- YouTube Integration - Video-based learning content
- Progress Tracking - Resume sessions where you left off
- Starter Plan - 50 free credits to get started
- Pro Plan - 500 credits/month ($19/mo)
- Unlimited Plan - Unlimited credits ($49/mo)
- Stripe Integration - Secure payment processing
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router) |
| Language | TypeScript |
| Auth & Database | Supabase (PostgreSQL + Auth + RLS) |
| AI (Primary) | SLM via Hugging Face Inference API |
| AI (Fallback) | OpenAI GPT-4o, Google Gemini |
| Voice (TTS) | ElevenLabs |
| Voice (STT) | Deepgram |
| Payments | Stripe |
| Styling | Tailwind CSS, Framer Motion |
| Deployment | Vercel |
- Node.js 18+
- Supabase account (supabase.com)
- API keys (see Environment Variables below)
git clone <your-repo-url>
cd ai-voice-tutor
npm install
cp .env.example .env.local
# Edit .env.local with your API keys
npm run devOpen http://localhost:3000.
Copy .env.example to .env.local and fill in your keys:
| Variable | Description | Get it from |
|---|---|---|
NEXT_PUBLIC_SUPABASE_URL |
Supabase project URL | supabase.com/dashboard > Settings > API |
NEXT_PUBLIC_SUPABASE_ANON_KEY |
Supabase anon/public key | Same as above |
SUPABASE_SERVICE_ROLE_KEY |
Supabase service role key (server-side only) | Same as above |
HF_API_KEY |
Hugging Face API key (primary AI) | huggingface.co/settings/tokens |
ELEVENLABS_API_KEY |
ElevenLabs TTS key | elevenlabs.io/app/settings/api-keys |
DEEPGRAM_API_KEY |
Deepgram STT key | console.deepgram.com |
NEXT_PUBLIC_APP_URL |
App URL (http://localhost:3000 for dev) |
- |
| Variable | Description | Get it from |
|---|---|---|
OPENAI_API_KEY |
OpenAI fallback (if HF_API_KEY not set) | platform.openai.com |
GEMINI_API_KEY |
Gemini for quiz generation & fallback | aistudio.google.com/app/apikey |
GEMINI_MODEL_NAME |
Gemini model (default: gemini-1.5-flash) |
- |
SLM_MODEL_NAME |
Custom SLM model name | - |
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY |
Stripe publishable key | dashboard.stripe.com |
STRIPE_SECRET_KEY |
Stripe secret key | Same as above |
STRIPE_WEBHOOK_SECRET |
Stripe webhook signing secret | Same as above |
STRIPE_PRICE_ID_PRO |
Stripe Price ID for Pro plan | Stripe Dashboard > Products |
STRIPE_PRICE_ID_UNLIMITED |
Stripe Price ID for Unlimited plan | Same as above |
- Go to supabase.com/dashboard
- Create a new project
- Copy your project URL and keys from Settings > API
- Go to SQL Editor in your Supabase dashboard
- Run
migrations/001_complete_schema.sql(creates all tables, RLS, triggers) - Run
migrations/002_add_quiz_tables.sql(adds quiz system tables)
| Table | Purpose |
|---|---|
user_profiles |
User info (linked to auth.users) |
user_subscriptions |
Subscription tier and status |
user_credits |
Credit balance (total, used, bonus) |
credit_transactions |
Credit usage history |
learning_sessions |
Session data (topic, duration, emotions) |
learning_progress |
Progress tracking per session |
conversation_messages |
Chat history per session |
user_notes |
Auto-generated and manual notes |
achievement_definitions |
Available achievements |
user_achievements |
Unlocked achievements per user |
user_preferences |
User settings (voice, theme, etc.) |
stripe_payments |
Payment records |
stripe_invoices |
Invoice records |
Auto-provisioning: A database trigger (handle_new_user) automatically creates user_profiles, user_subscriptions, user_credits, and user_preferences when a new user signs up via Supabase Auth.
Row Level Security (RLS): All tables have RLS enabled. Users can only access their own data.
ai-voice-tutor/
├── app/ # Next.js App Router
│ ├── api/ # API routes
│ │ ├── auth/ensure-profile/ # Profile initialization
│ │ ├── credits/ # Credit balance & usage
│ │ ├── subscription/ # Subscription info & checkout
│ │ ├── tutor/ # AI tutor endpoints
│ │ ├── tts/ # Text-to-speech
│ │ ├── stt/ # Speech-to-text
│ │ ├── quiz/ # Quiz generation
│ │ └── webhooks/stripe/ # Stripe webhooks
│ ├── auth/ # Login, signup, callback pages
│ ├── dashboard/ # Dashboard pages
│ ├── course/[courseId]/ # Course detail pages
│ ├── session/[sessionId]/ # Session replay
│ └── page.tsx # Landing page
├── components/ # React components
│ ├── dashboard/ # Dashboard widgets
│ ├── providers/ # Context providers
│ ├── ui/ # Reusable UI components
│ ├── TutorSession.tsx # Main tutoring session
│ ├── CreditsDisplay.tsx # Credit balance display
│ └── ... # Other feature components
├── contexts/
│ └── AuthContext.tsx # Supabase Auth context
├── hooks/
│ ├── useCredits.ts # Credit fetching with cache
│ └── useUserSync.ts # User data sync
├── lib/
│ ├── auth.ts # Server-side auth helpers
│ ├── supabase.ts # Supabase browser client
│ ├── supabase-auth.ts # Supabase SSR client
│ ├── ai-adapter.ts # AI provider abstraction
│ ├── credits-events.ts # Credit update event system
│ └── subscription/ # Subscription & credit logic
├── migrations/
│ ├── 001_complete_schema.sql # Main schema
│ └── 002_add_quiz_tables.sql # Quiz tables
├── middleware.ts # Auth middleware (Supabase)
└── docs/ # Documentation
- Push code to GitHub
- Import project in Vercel
- Add all environment variables from the table above
- Set
NEXT_PUBLIC_APP_URLto your production URL - Deploy
For Stripe webhooks in production, create a webhook endpoint pointing to https://your-domain.com/api/webhooks/stripe.
npm run dev # Start dev server
npm run build # Production build
npm run start # Start production server
npm run lint # Run linterLayfirto