A modern, full-stack e-learning platform built with Next.js 15, TypeScript, Supabase, and Cloudinary.
- Frontend & Backend: Next.js 15 (App Router) + TypeScript
- Database: Supabase (PostgreSQL)
- Authentication: Supabase Auth (Email/Password + Google OAuth)
- File Storage: Cloudinary (videos, images, documents)
- Payments: Stripe
- UI Components: shadcn/ui + Tailwind CSS
- Deployment: Vercel
- Admin: Manage users, approve courses, view analytics
- Mentor: Create courses, materials, quests/assessments
- Student: Enroll in courses, complete materials, earn certificates
- Role-based authentication and authorization
- Google OAuth (SSO) sign-in
- User approval workflow
- Course management with video lessons (Cloudinary)
- Progress tracking system
- Quest/Assessment system with auto-grading
- Automatic certificate generation
- Payment integration with Stripe
- Real-time enrollment and progress updates
- Course reviews and ratings
- Points & Rewards: Earn points for completing quests (100-275 pts), courses (200-800 pts), and maintaining streaks
- Badges: 15 automated achievements across 4 tiers (Bronze, Silver, Gold, Platinum)
- Skills Tracking: 25+ cybersecurity skills with proficiency levels (Beginner → Expert)
- Leaderboard: Global rankings based on total points, badges, and achievements
- Learning Streaks: Daily activity tracking with bonus rewards (7, 30, 100-day milestones)
- Skill Progression: Automatic skill advancement based on quiz performance and course completion
See GAMIFICATION_GUIDE.md for detailed integration guide.
├── app/ # Next.js App Router
│ ├── auth/ # OAuth callback handlers
│ ├── login/ # Login page
│ ├── register/ # Registration page
│ ├── dashboard/ # User dashboard
│ ├── admin/ # Admin pages
│ │ └── users/ # User management
│ ├── layout.tsx # Root layout
│ └── page.tsx # Home page
├── components/ # Reusable React components
│ └── ui/ # shadcn/ui components
├── lib/ # Utilities and configs
│ ├── supabase/ # Supabase client (server & client)
│ ├── actions/ # Server Actions
│ └── utils.ts # Helper functions
├── types/ # TypeScript type definitions
├── database/ # Database schema and scripts
│ ├── supabase-schema.sql # Database schema
│ └── create-admin.sql # Admin user script
└── public/ # Static assets
- Node.js 18+ installed
- A Supabase account (free tier)
- Cloudinary account (optional, for video uploads)
- Stripe account (optional, for payments)
-
Clone and install dependencies:
npm install
-
Copy environment file:
cp .env.example .env.local
-
Set up Supabase (see Supabase Setup)
-
Run development server:
npm run dev
-
Open browser: Navigate to http://localhost:3000
- Go to https://supabase.com and sign up
- Click "New Project"
- Fill in:
- Name:
elearning-platform - Database Password: Create a strong password (save it!)
- Region: Choose closest to your location
- Plan: Free
- Name:
- Click "Create new project" and wait 1-2 minutes
- In Supabase dashboard, click "SQL Editor" → "New query"
- Open
database/supabase-schema.sqlin your code editor - Copy ALL contents and paste into SQL Editor
- Click "Run" (or Ctrl+Enter)
- Wait ~10-15 seconds
Expected Result:
Success. No rows returned
NOTICE: E-Learning Platform database schema created successfully!
NOTICE: Tables created: 20+
Verify: Click "Table Editor" - you should see 20+ tables (profiles, courses, materials, skills, badges, etc.)
-
Click "Project Settings" (gear icon) → "API"
-
Copy these values:
Project URL:
https://xxxxxxxxxxxxx.supabase.coAnon/Public Key (long JWT token):
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Edit .env.local:
NEXT_PUBLIC_SUPABASE_URL=https://xxxxxxxxxxxxx.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...# Stop server (Ctrl+C), then restart:
npm run devTo enable the full gamification experience, run these seed files in Supabase SQL Editor:
- Seed Skills (
database/seed-skills.sql) - Adds 25+ cybersecurity skills - Seed Badges (
database/seed-badges.sql) - Adds 15 achievement badges - Seed Tools (
database/seed-tools.sql) - Adds cybersecurity tools database - Seed Test Data (
database/seed-gamification-test.sql) - Adds sample courses and quests for testing
Note: Run each file separately in the SQL Editor.
- Register a new account at http://localhost:3000/register
- In Supabase SQL Editor, run:
UPDATE public.profiles SET role = 'admin', is_approved = true WHERE email = '[email protected]';
- Refresh the page - you now have admin access!
Enable Google Sign-In for students. Note: Mentors and admins must use email/password authentication.
- Go to Google Cloud Console: https://console.cloud.google.com
- Click "New Project" → Name:
elearning-platform - Go to "APIs & Services" → "OAuth consent screen"
- Choose "External" → Click "Create"
- Fill in:
- App name:
E-Learning Platform - User support email: Your email
- Developer contact: Your email
- App name:
- Click "Save and Continue" through all steps
- Click "Add or Remove Scopes"
- Select:
userinfo.emailuserinfo.profile
- Click "Update" → "Save and Continue"
Since the app is in testing mode:
- Click "Add Users"
- Add your email address(es)
- Click "Add" → "Save and Continue"
-
Go to "Credentials" → "Create Credentials" → "OAuth client ID"
-
Choose "Web application"
-
Fill in:
-
Name:
E-Learning Platform Web -
Authorized JavaScript origins:
http://localhost:3000
-
Authorized redirect URIs:
https://YOUR_PROJECT_REF.supabase.co/auth/v1/callback
⚠️ ReplaceYOUR_PROJECT_REFwith your Supabase project reference (from your Supabase URL)
-
-
Click "Create"
-
Save the Client ID and Client Secret!
- Go to Supabase Dashboard → Authentication → Providers
- Find Google and toggle it ON
- Paste:
- Client ID (for OAuth): Your Google Client ID
- Client Secret (for OAuth): Your Google Client Secret
- Click "Save"
- Go to http://localhost:3000/login
- Click "Continue with Google"
- Sign in with your Google account (must be in test users list!)
- You'll be redirected to the dashboard
Important Notes:
- Google OAuth is only for students
- Mentors and admins cannot use Google sign-in
- New Google users will have
Pending Approvalstatus until an admin approves them - If a mentor/admin tries to use Google, they'll see an error and be signed out
For video hosting and course thumbnails.
- Go to https://cloudinary.com/
- Sign up for free (25GB storage, 25GB bandwidth/month)
- Go to Dashboard and note:
- Cloud Name
- API Key
- API Secret
Edit .env.local:
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secretnpm run devCloudinary is ready! You can now upload course videos and thumbnails.
profiles - User profiles (extends Supabase Auth)
- Stores role (admin, mentor, student)
- Approval status and account activation
- Auto-created via database trigger on signup
courses - Course information
- Created by mentors/admins
- Approval workflow
- Tracks enrollment count and ratings
materials - Course chapters/sections
- Belongs to a course
- Contains sub-materials (lessons)
sub_materials - Individual lessons/videos
- Video URLs from Cloudinary
- Document uploads
- Preview capability
enrollments - Student course enrollments
- Links students to courses
- Tracks overall progress
- Records last access
progress - Granular progress tracking
- Completion of each sub-material
- Video playback position
- Time spent
quests - Assessments/Quizzes
- Created by instructors
- Questions with options
- Passing score requirement
quest_attempts - Student quiz attempts
- Records scores and answers
- Tracks pass/fail status
certificates - Auto-generated certificates
- Issued on course completion
- Unique certificate number
- Verification URL
payments - Stripe payment records
- Tracks payment status
- Stripe integration IDs
reviews - Course reviews/ratings
- 1-5 star rating
- Written feedback
skills - Cybersecurity skill definitions
- 25+ skills across 6 categories
- Web Security, Network Security, Cryptography, etc.
student_skills - Student skill progression
- Tracks proficiency levels (beginner → expert)
- Points earned per skill
badges - Achievement badges
- 15 badges across 4 tiers
- Auto-awarded based on milestones
student_badges - Earned badges
- Timestamp of achievement
- Badge progress tracking
leaderboard_stats - Student rankings
- Total points, badges, courses completed
- Learning streaks and averages
- Global rank
point_history - Points transaction log
- Tracks all point awards
- Source tracking (quest, course, skill, streak)
course_skills - Links courses to skills
- Defines which skills a course teaches
- Proficiency level taught
# Start dev server (with Turbopack)
npm run dev
# Build for production
npm run build
# Start production server
npm start
# Type checking
npm run type-check
# Linting
npm run lintComplete .env.local template:
# Supabase
NEXT_PUBLIC_SUPABASE_URL=https://xxxxx.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI...
# Cloudinary (Optional)
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
# Stripe (Optional)
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_xxx
STRIPE_SECRET_KEY=sk_test_xxx
STRIPE_WEBHOOK_SECRET=whsec_xxx
# App
NEXT_PUBLIC_APP_URL=http://localhost:3000All tables have RLS policies:
- Public: Can view published courses
- Students: Can view/update own enrollments, progress, certificates
- Mentors: Can create/edit own courses
- Admins: Full access to all data
When users sign up, a profile is automatically created via database trigger.
- Secure OAuth 2.0 flow
- Email verified automatically by Google
- No password to remember
Supabase Free:
- Database: 500MB storage
- Bandwidth: 2GB/month
- Auth: 50,000 MAU
Cloudinary Free:
- Storage: 25GB
- Bandwidth: 25GB/month
- Videos: 500/month
Vercel Free:
- 100GB bandwidth/month
- Unlimited deployments
Error: "relation already exists"
- You're running the schema twice. Create a new Supabase project or drop all tables first.
Tables not showing up
- Refresh the page
- Check SQL Editor for errors
- Verify you clicked "Run"
Can't login after Google sign-up
- Account needs admin approval
- Admin must approve in
/admin/users
Error: "403: access_denied" (Google)
- Your email is not in test users list
- Add it in Google Cloud Console → OAuth consent screen → Test users
Error: "Invalid client ID" (Google)
- Double-check Client ID matches in Supabase and Google Console
Can't connect from app
- Check URL and anon key are correct in
.env.local - No extra spaces in environment variables
- Restart dev server after changing
.env.local
Build and run with Docker:
# Production build
docker-compose up --build -d
# Development build (with hot reload)
docker-compose -f docker-compose.dev.yml up --build
# View logs
docker-compose logs -f
# Stop containers
docker-compose downYour app will be available at: http://localhost:3000
Docker Features:
- ✅ Production-optimized build with multi-stage Dockerfile
- ✅ Standalone Next.js output for faster cold starts
- ✅ Development mode with hot reload
- ✅ Minimal image size using Alpine Linux
- Push your code to GitHub
- Go to https://vercel.com
- Import your repository
- Add environment variables (same as
.env) - Deploy!
Update Google OAuth after deployment:
- Add production URL to Authorized JavaScript origins
- Example:
https://your-app.vercel.app
- Push your code to GitHub
- Go to https://netlify.com
- Import your repository
- Build settings:
- Build command:
npm run build - Publish directory:
.next
- Build command:
- Add environment variables
- Deploy!
✅ Completed:
- Next.js 15 + TypeScript setup
- Supabase integration (PostgreSQL)
- Email/Password authentication
- Google OAuth SSO (students only)
- Role-based access control (Admin, Mentor, Student)
- User management dashboard with approval workflow
- Protected routes & middleware
- Database schema with RLS policies
- Docker containerization (production & development)
- Netlify/Vercel deployment ready
✅ Gamification Features:
- Points and rewards system
- 15 automated badges (Bronze, Silver, Gold, Platinum tiers)
- 25+ cybersecurity skills tracking
- Global leaderboard with rankings
- Learning streaks (7, 30, 100-day milestones)
- Skill progression (Beginner → Expert)
🚧 In Progress:
- Course creation interface (UI)
- Video upload with Cloudinary (UI)
- Stripe payment integration (UI)
- Advanced analytics dashboard
- Supabase: https://supabase.com/docs
- Next.js: https://nextjs.org/docs
- shadcn/ui: https://ui.shadcn.com
- Cloudinary: https://cloudinary.com/documentation
- Stripe: https://stripe.com/docs
ISC License
Built with: Next.js 15 | TypeScript | Supabase | Cloudinary | Stripe | Tailwind CSS