Pure Supabase backend services for the EdVerse learning management system.
This backend provides:
- Authentication: Supabase Auth for user management
- Database: PostgreSQL via Supabase for data storage
- Functions: Supabase Edge Functions for serverless API endpoints
- Storage: Supabase Storage for file uploads
- Security: Row Level Security (RLS) policies
edverse-project/
├── edverse-frontend/ # React Frontend Application
│ ├── src/ # React components, pages, hooks
│ ├── public/ # Static assets
│ ├── package.json # Frontend dependencies
│ └── supabase/ # Local development config only
│ ├── config.toml # Supabase local settings
│ └── .gitignore # Supabase gitignore
└── edverse-backend/ # Pure Supabase Backend
├── supabase/
│ └── functions/ # Supabase Edge Functions (15 total)
│ ├── create-course/
│ ├── create-notification/
│ ├── create-user-profile/
│ ├── delete-user/
│ ├── enroll-student-in-course/
│ ├── get-dashboard-stats/
│ ├── get-instructors/
│ ├── get-notifications/
│ ├── get-students/
│ ├── get-user-by-id/
│ ├── get-user-courses/
│ ├── get-users/
│ ├── health-check/
│ ├── test-connection/
│ ├── update-user-profile/
│ └── _shared/ # Shared utilities
├── supabase-rls-policies-enhanced.sql # Database security policies
├── package.json # Backend tooling configuration
└── README.md # This file
Important: Edge Functions only exist in the backend directory. The frontend communicates with these functions via HTTP calls to the deployed Supabase Edge Functions.
- Node.js (v18 or higher)
- Supabase CLI (
npm install -g supabase) - Supabase project setup
-
Navigate to the backend directory:
cd edverse-backend -
Install dependencies:
npm install
-
Set up environment variables:
cp .env.example .env # Edit .env with your Supabase project details -
Start the Edge Functions locally:
supabase functions serve
# Start Edge Functions locally
supabase functions serve
# Start without JWT verification (for testing)
supabase functions serve --no-verify-jwt
# Deploy all functions
supabase functions deploy
# Deploy a specific function
supabase functions deploy <function-name>
# Test a function
curl -X POST "http://localhost:54321/functions/v1/<function-name>" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"key": "value"}'# Deploy all Edge Functions to production
npm run deploy
# Deploy specific function
supabase functions deploy create-course
# Check function logs
supabase functions logs
# View function status
supabase functions list- Email/password authentication
- OAuth integration (Google, GitHub, etc.)
- Row Level Security for role-based access
- JWT-based authentication tokens
- User profiles and preferences
- Course and curriculum data
- Student and instructor records
- Attendance and grade tracking
- Real-time notifications
- User profile creation and management
- Data validation and processing
- API endpoints for complex operations
- Real-time event handling
- Background job processing
- Profile pictures and avatars
- Course materials and documents
- Assignment submissions
- Media files for courses
Located in supabase-rls-policies-enhanced.sql, these policies control:
- User data access permissions
- Role-based data visibility
- Data validation on writes
- Real-time subscription security
Control file upload and access:
- User-specific file access
- File type validation
- Size limits
- Public vs private files
# Start Edge Functions locally
supabase functions serve
# Test health check
curl http://localhost:54321/functions/v1/health-check
# Test with authentication
curl -X POST "http://localhost:54321/functions/v1/create-course" \
-H "Authorization: Bearer <your-jwt-token>" \
-H "Content-Type: application/json" \
-d '{"title": "Test Course", "description": "Test"}'# Run test suite
npm test
# Test specific function
supabase functions deploy test-connection --project-ref <project-id>- Function logs and metrics
- Database usage and performance
- Authentication statistics
- Storage usage
- Real-time activity
- Automatic error collection
- Performance monitoring
- Custom metrics tracking
- Edge Function analytics
Create a .env file in the project root:
# Supabase Configuration
SUPABASE_URL=your_supabase_project_url
SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
# Optional: Additional service integrations
SENDGRID_API_KEY=your_sendgrid_key
STRIPE_SECRET_KEY=your_stripe_keyPOST /functions/v1/create-user-profile- Create user profileGET /functions/v1/get-user-by-id- Get user profilePOST /functions/v1/update-user-profile- Update user profileGET /functions/v1/get-users- List all usersPOST /functions/v1/delete-user- Delete user
GET /functions/v1/get-user-courses- List user coursesPOST /functions/v1/create-course- Create course
GET /functions/v1/get-students- List studentsPOST /functions/v1/enroll-student-in-course- Enroll student
GET /functions/v1/get-instructors- List instructors
GET /functions/v1/get-dashboard-stats- Get dashboard statistics
GET /functions/v1/get-notifications- Get notificationsPOST /functions/v1/create-notification- Create notification
GET /functions/v1/health-check- Health checkGET /functions/v1/test-connection- Test connection
# Deploy all functions to production
supabase functions deploy --project-ref <your-project-ref>
# Deploy specific function
supabase functions deploy create-course --project-ref <your-project-ref>
# Using npm script
npm run deploy# Deploy to staging environment
supabase functions deploy --project-ref <your-staging-project-ref>
# Set up different environments
supabase link --project-ref <staging-project-ref>
supabase functions deploy- Follow TypeScript best practices
- Write comprehensive tests
- Update RLS policies as needed
- Document new functions and APIs
- Test locally before deployment
- Ensure proper error handling
- Follow RESTful API conventions
EdVerse Backend - Powering education with Supabase ⚡