This guide walks you through setting up Supabase for Luna Services, including database configuration, authentication, and security policies.
- Supabase account (free tier available)
- Git access to Luna Services repository
- Basic understanding of SQL and database concepts
- Go to Supabase Dashboard
- Click "New Project"
- Choose your organization
- Enter project details:
- Name: Luna Services
- Database Password: Use a strong password (save this!)
- Region: Choose closest to your users
- Click "Create new project"
Once your project is created, navigate to Settings > API and collect:
# Required for Luna Services
VITE_SUPABASE_URL=https://your-project-ref.supabase.co
VITE_SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_KEY=your-service-role-key
SUPABASE_DB_PASSWORD=your-database-password
# Database connection details
SUPABASE_DB_HOST=db.your-project-ref.supabase.co
SUPABASE_DB_PORT=5432
SUPABASE_DB_NAME=postgres
SUPABASE_DB_USER=postgres
# JWT Configuration
SUPABASE_JWT_SECRET=your-jwt-secret# Using psql (if you have it installed)
psql "postgresql://postgres.tnmsadjdeenhysllhyzp:JglPPLffmXPYaDzS@aws-0-ap-south-1.pooler.supabase.com:5432/postgres" -f supabase/migrations/20250129_000001_initial_schema.sql
psql "postgresql://postgres.tnmsadjdeenhysllhyzp:JglPPLffmXPYaDzS@aws-0-ap-south-1.pooler.supabase.com:5432/postgres" -f supabase/migrations/20250129_000002_rls_policies.sql
psql "postgresql://postgres.tnmsadjdeenhysllhyzp:JglPPLffmXPYaDzS@aws-0-ap-south-1.pooler.supabase.com:5432/postgres" -f supabase/migrations/20250129_000003_functions_triggers.sql# Frontend (in root directory)
npm run dev
# Backend (in backend directory)
cd backend
source venv/bin/activate
uvicorn app.main:app --reloadIf you prefer to set up manually:
npm install @supabase/supabase-js@^2.39.7cd backend
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install "supabase==2.3.4"
pip install "postgrest>=0.10.8,<0.16.0"
pip install -r requirements.txtCreate .env file and add the Supabase configuration.
Follow the migration steps above.
The database schema includes:
- users: User profiles and authentication data
- projects: Project management data
- project_members: Project team membership
- automation_jobs: Automation workflow definitions
- job_executions: Automation execution history
- api_keys: API key management
- Row Level Security (RLS): Fine-grained access control
- Real-time subscriptions: Live updates via Supabase
- Automatic triggers: User creation, statistics updates
- Data validation: Input validation and constraints
- Supabase Auth integration
- JWT token-based authentication
- User roles and permissions
- API key management
- Row Level Security policies
- Encrypted data transmission
- Secure database connections
- Input validation and sanitization
// In your browser console or component
import { supabase } from './src/services/supabase'
// Test connection
const testConnection = async () => {
const { data, error } = await supabase.auth.getSession()
console.log('Connection test:', { data, error })
}
testConnection()# In your Python environment
from backend.app.supabase_client import supabase_manager
# Test connection
async def test_connection():
result = await supabase_manager.verify_connection()
print(f"Connection test: {result}")
# Run the test
import asyncio
asyncio.run(test_connection())# Test a simple query in the Supabase dashboard SQL editor
SELECT version();
SELECT * FROM auth.users LIMIT 1;# If you get postgrest version conflicts
pip uninstall postgrest supabase
pip install "supabase==2.3.4"
pip install "postgrest>=0.10.8,<0.16.0"- Ensure
.envfile is in the project root - Restart your development servers after updating
.env - Check that environment variables are correctly formatted
- Verify the database URL is correct
- Check if your IP is allowed in Supabase settings
- Ensure the password is correctly URL-encoded
- Run migrations in the correct order
- Check for syntax errors in SQL
- Ensure you have sufficient database permissions
If you encounter issues:
- Check the logs: Look for error messages in browser console or terminal
- Verify credentials: Ensure all Supabase credentials are correct
- Check documentation: Review the Supabase documentation
- Create an issue: Open a GitHub issue with detailed error information
After successful setup:
- Create your first user: Sign up through the frontend
- Create a project: Use the project management features
- Set up automation: Create your first automation job
- Explore the API: Test the backend endpoints
- Contribute: Help improve the project!
This setup guide is maintained by the Luna Services team. If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.