Overview
ClassroomIO uses Supabase as its database and authentication backend. You can use either a local Supabase instance or a cloud-hosted project.Prerequisites
- Supabase CLI installed
- Docker (for local Supabase)
- Git (to clone the repository)
Option 1: Local Supabase Setup
Install Supabase CLI
Initialize Supabase
- Navigate to your ClassroomIO source directory:
- The project already includes a
supabasedirectory with configuration. Start Supabase:
- Start a local Supabase instance using Docker
- Run all migrations
- Set up the database schema
- Start the following services:
- PostgreSQL database (port 54322)
- API server (port 54321)
- Studio UI (port 54323)
- Inbucket (email testing - port 54324)
- Note the output - you’ll need these credentials:
Access Supabase Studio
Open your browser tohttp://localhost:54323 to access the Supabase Studio dashboard where you can:
- View and edit database tables
- Manage authentication
- Test SQL queries
- Monitor API usage
Option 2: Supabase Cloud
Create a Project
- Go to supabase.com and sign in
- Click “New Project”
- Fill in:
- Name: ClassroomIO (or your preferred name)
- Database Password: Use a strong password
- Region: Choose closest to your users
- Click “Create new project”
Run Migrations
- Link your local project to the cloud project:
- Push migrations to your cloud database:
- Verify migrations:
Get API Credentials
- Go to Settings > API in your Supabase dashboard
- Copy the following:
- Project URL (
PUBLIC_SUPABASE_URL) - anon/public key (
PUBLIC_SUPABASE_ANON_KEY) - service_role key (
PRIVATE_SUPABASE_SERVICE_ROLE)
- Project URL (
Database Configuration
Configuration File
Thesupabase/config.toml file contains important settings:
Key Settings
Maximum rows returned from API queriesDefault: 1000
Base URL for email redirectsProduction: Set to your actual domain
Maximum file upload sizeDefault: 50MiB
Running Migrations
ClassroomIO includes multiple database migrations insupabase/migrations/. These handle:
- Course and lesson management
- User authentication and profiles
- Organization and team features
- Custom domains
- AI grading
- Analytics
- Multi-language support
- And more…
Apply All Migrations
Create New Migration
If you need to modify the schema:supabase/migrations/, then apply:
Check Migration Status
Seeding Data
ClassroomIO includes a seed file (supabase/seed.sql) with test data:
- 3 test users (admin, teacher, student)
- Sample organizations
- Demo courses with lessons
- Example exercises and quizzes
Apply Seed Data
Test Accounts
After seeding, you can log in with:| Password | Role | |
|---|---|---|
| [email protected] | password | Admin |
| [email protected] | password | Teacher |
| [email protected] | password | Student |
Row Level Security (RLS)
ClassroomIO uses Supabase’s Row Level Security for data protection. Migrations include RLS policies for:- Courses: Users can only access courses they’re enrolled in or teaching
- Profiles: Users can view their own profile and update allowed fields
- Organizations: Members can view organization data based on role
- Submissions: Students see their own submissions, teachers see all
Verify RLS Policies
In Supabase Studio:- Go to Authentication > Policies
- Check each table has appropriate policies
- Test with different user roles
Storage Buckets
The seed data creates anavatars bucket for user profile pictures.
Configure Storage
Storage Policies
Set up policies for who can upload/download:Edge Functions
ClassroomIO includes Supabase Edge Functions insupabase/functions/:
- notify: Handles notifications
- grades-tmp: Temporary grading function
Deploy Edge Functions
Test Functions Locally
Authentication Setup
Email Authentication
Enabled by default inconfig.toml:
OAuth Providers
To enable social login (Google, GitHub, etc.):- In Supabase Dashboard: Authentication > Providers
- Enable desired providers
- Add client ID and secret
- Configure redirect URLs
Email Templates
Customize email templates in Authentication > Email Templates:- Confirmation email
- Password reset
- Magic link
- Email change
Environment Variables
After setting up Supabase, add these to your.env:
.env
Database Backups
Local Backups
Cloud Backups
Supabase Cloud provides automatic daily backups (Pro plan and above). Manual backup:- Go to Database > Backups
- Click “Create backup”
Monitoring
Local Monitoring
Cloud Monitoring
In Supabase Dashboard:- Reports: API usage, database size
- Logs: Real-time logs explorer
- Monitoring: Performance metrics
Common Supabase Commands
Troubleshooting
Port Already in Use
If Supabase ports are taken:Migration Errors
Connection Issues
- Verify Supabase is running:
supabase status - Check connection string in
.env - Ensure firewall allows connections
- For cloud: verify API keys are correct
RLS Policy Errors
If queries fail due to RLS:- Check policies in Studio
- Verify user is authenticated
- Test with service role key (bypasses RLS)
- Review migration files for policy definitions
Production Considerations
- Enable email confirmations in auth settings
- Set up custom SMTP for emails (avoid Supabase’s default)
- Configure backups (automatic + manual)
- Set up monitoring and alerts
- Use connection pooling for high traffic
- Enable SSL for database connections
- Review and test RLS policies thoroughly
- Set appropriate file size limits for storage
Next Steps
Environment Variables
Configure all required variables
Docker Setup
Deploy with Docker