# 1. Deploy backend migrations
./deploy-backend.sh
# 2. Install frontend dependencies (if not done)
npm install
# 3. Start the development server
npm run devMake sure you have:
- ✅ Node.js installed (v16 or higher)
- ✅ npm or bun installed
- ✅ Supabase account with a project created
- ✅
.envfile configured (see below)
Your .env file should have:
# Clerk Authentication
VITE_CLERK_PUBLISHABLE_KEY=pk_test_your-key-here
# Supabase Configuration
VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_ANON_KEY=your-anon-key-hereGet these from:
- Clerk: https://dashboard.clerk.com → Your App → API Keys
- Supabase: https://supabase.com/dashboard → Your Project → Settings → API
Option A - Using the deployment script (Recommended):
./deploy-backend.shThis will:
- Install Supabase CLI if needed
- Link to your Supabase project
- Deploy all 4 migration files
- Verify the deployment
Option B - Manual deployment via Supabase Dashboard:
- Go to https://supabase.com/dashboard
- Select your project
- Click SQL Editor (left sidebar)
- Copy and run each file in order:
supabase/migrations/001_video_validation.sqlsupabase/migrations/002_quiz_enforcement.sqlsupabase/migrations/003_progress_enforcement.sqlsupabase/migrations/004_feature_flags_rls.sql
Option C - Supabase CLI manually:
# Install Supabase CLI
npm install -g supabase
# Login
supabase login
# Link your project (replace with your project ref)
supabase link --project-ref YOUR_PROJECT_REF
# Deploy all migrations
supabase db push
# Or deploy individually
supabase db execute --file supabase/migrations/001_video_validation.sql
supabase db execute --file supabase/migrations/002_quiz_enforcement.sql
supabase db execute --file supabase/migrations/003_progress_enforcement.sql
supabase db execute --file supabase/migrations/004_feature_flags_rls.sqlRun these SQL queries in Supabase SQL Editor:
-- Check video constraints (should show 3 rows)
SELECT constraint_name, constraint_type
FROM information_schema.table_constraints
WHERE table_name = 'videos'
AND constraint_name IN ('duration_range', 'video_url_format', 'thumbnail_url_format');
-- Check triggers (should show 3 triggers)
SELECT trigger_name, event_object_table
FROM information_schema.triggers
WHERE trigger_name IN ('enforce_quiz_question_limit', 'check_quiz_before_approval', 'enforce_quiz_completion');
-- Check feature flags (should show 5 rows, all disabled)
SELECT feature_name, enabled FROM feature_flags;
-- Check RLS is enabled (should show multiple tables)
SELECT tablename FROM pg_tables
WHERE schemaname = 'public' AND rowsecurity = true;Expected output:
- ✅ 3 video constraints
- ✅ 3 triggers
- ✅ 5 feature flags (all
enabled = false) - ✅ RLS enabled on users, videos, progress, badges, etc.
# Install dependencies (first time only)
npm install
# Start development server
npm run devThe app will open at: http://localhost:5173
- Go to http://localhost:5173
- Click "Sign Up" or "Sign In"
- Create an account via Clerk
- Check Supabase → Table Editor → users (you should see your user)
- Switch to creator role in Supabase (update users table, set
role = 'creator') - Go to Upload page
- Try uploading a video:
- Duration < 2 min → Should fail validation ❌
- Duration > 5 min → Should fail validation ❌
- Duration 2-5 min → Should succeed ✅
- Add 1-3 quiz questions (required)
- Set your role to
adminin Supabase - Go to Admin dashboard
- See pending videos
- Approve a video
- Video now appears in Browse page
- As a learner, watch an approved video
- Complete the quiz
- Check your dashboard:
- Points should increase ✅
- Progress should update ✅
- Badges may unlock ✅
- Streak may increase ✅
- Complete several videos
- Dashboard should show:
- Total points
- Current level (beginner/intermediate/advanced/expert)
- Videos completed count
- Quiz accuracy %
- Current streak
- Badges earned
- Skill-wise progress
// In browser console on Upload page:
const testDuration = async () => {
try {
// This should FAIL
await createVideo({
duration_seconds: 90, // Too short!
// ... other fields
}, userId);
} catch (error) {
console.log('✅ Validation working:', error.message);
// Should show: "Video duration must be at least 2 minutes"
}
};-- In Supabase SQL Editor:
-- Try to mark video complete without quiz (should FAIL)
UPDATE progress
SET completed = true, quiz_answers = NULL
WHERE id = 'some-progress-id';
-- Error: "Cannot mark video complete without quiz answers" ✅-- Check all social features are disabled
SELECT * FROM feature_flags WHERE enabled = true;
-- Should return 0 rows ✅# Development
npm run dev # Start dev server
npm run build # Build for production
npm run preview # Preview production build
# Linting
npm run lint # Check code quality
# Database
supabase db push # Deploy migrations
supabase db pull # Pull schema from remote
supabase db reset # Reset local database
# Supabase CLI
supabase status # Check connection
supabase link # Link to project
supabase login # Authenticate# Clear node_modules and reinstall
rm -rf node_modules package-lock.json
npm install
npm run dev# Make sure .env exists and has correct format
cat .env
# Restart dev server after changing .env
# Press Ctrl+C then run: npm run dev# Check Supabase connection
supabase status
# Re-link if needed
supabase link --project-ref YOUR_PROJECT_REF
# Try deploying again
supabase db pushThis is expected behavior! Videos can only be completed via quiz submission.
Use submitQuiz() function, not markVideoWatched().
SkillUp/
├── src/
│ ├── services/
│ │ ├── validation.ts # NEW: All validation logic
│ │ ├── videos.ts # ENHANCED: With validation
│ │ ├── progress.ts # ENHANCED: Quiz enforcement
│ │ ├── users.ts # Points & streaks
│ │ └── badges.ts # Badge awarding
│ ├── pages/ # React pages
│ └── components/ # React components
├── supabase/
│ └── migrations/ # Database migrations
├── docs/
│ └── BACKEND_API.md # API documentation
├── .env # Environment variables
├── deploy-backend.sh # Deployment script
└── QUICK_START.md # Quick start guide
Before going to production:
- All migrations deployed to Supabase
- Environment variables configured
- Clerk authentication working
- Video upload with validation working
- Quiz submission working
- Points and badges working
- Progress tracking accurate
- Admin approval workflow tested
- RLS policies protecting data
Everything is implemented and ready to use. The full stack should work seamlessly:
- Backend: Supabase with constraints, triggers, and RLS
- Services: TypeScript services with validation
- Frontend: React + Vite with all features
- Auth: Clerk handling authentication
Run npm run dev and start learning! 🚀