Overview
Risk Legion uses Supabase for:- PostgreSQL Database - Primary data storage
- Authentication - User management and JWT tokens
- Row Level Security - Multi-tenant data isolation
Creating a Project
1. Create New Project
- Go to supabase.com
- Sign in and click “New Project”
- Choose organization
- Enter project details:
- Name: risk-legion-production
- Database Password: (save securely)
- Region: Choose closest to your users
- Click “Create new project”
2. Note Credentials
From Project Settings → API:| Credential | Use |
|---|---|
| Project URL | SUPABASE_URL |
| anon/public key | SUPABASE_ANON_KEY (frontend) |
| service_role key | SUPABASE_SERVICE_ROLE_KEY (backend) |
| Credential | Use |
|---|---|
| Connection string | DATABASE_URL |
Database Setup
1. Create Tables
Run schema SQL in SQL Editor:2. Enable RLS
3. Create RLS Policies
4. Create Indexes
Authentication Setup
1. Configure Providers
In Authentication → Providers:- Email: Enable
- Password requirements: Set minimum 8 characters
2. Configure URLs
In Authentication → URL Configuration:| Setting | Development | Production |
|---|---|---|
| Site URL | http://localhost:5173 | https://app.risklegion.com |
| Redirect URLs | http://localhost:5173/* | https://app.risklegion.com/* |
3. Email Templates (Optional)
In Authentication → Email Templates: Customize:- Confirm signup
- Reset password
- Magic link
Profile Trigger
Create a trigger to automatically create profiles:Storage Setup (Optional)
If you need file storage:- Go to Storage → Create bucket
- Name:
documents - Configure RLS policies for bucket access
Backup Configuration
Automatic Backups
Supabase Pro plans include:- Daily automated backups
- Point-in-time recovery
- 7-day retention
Manual Backup
Monitoring
Dashboard Metrics
In Project Dashboard:- Database size
- API requests
- Auth users
- Realtime connections
Logs
In Logs:- API logs
- Auth logs
- Database logs
Environment-Specific Projects
Consider separate projects for:| Environment | Project Name |
|---|---|
| Development | risk-legion-dev |
| Staging | risk-legion-staging |
| Production | risk-legion-production |
Security Checklist
RLS Enabled
RLS Enabled
- All tables have RLS enabled
- Policies cover all operations (SELECT, INSERT, UPDATE, DELETE)
- Test with different user roles
Keys Protected
Keys Protected
- Never expose service_role key to frontend
- anon key is safe for frontend
- Rotate keys if compromised
Network Security
Network Security
- Enable SSL enforcement
- Restrict database connections (optional)
- Use VPN for direct database access
Auth Security
Auth Security
- Strong password requirements
- Consider MFA for admin users
- Monitor for suspicious activity
Troubleshooting
RLS blocking queries
RLS blocking queries
- Check if user has correct enterprise_id
- Verify auth.uid() returns expected value
- Test policy with direct SQL
Connection refused
Connection refused
- Check project is active (not paused)
- Verify connection string is correct
- Check IP whitelist settings
Auth not working
Auth not working
- Verify API keys are correct
- Check redirect URLs are configured
- Review auth logs for errors