Overview
BoxApp uses Supabase as its backend-as-a-service platform, providing authentication, database, storage, and real-time capabilities. This guide covers both local development and production setup.Local Development Setup
Prerequisites
- Docker Desktop installed and running
- Supabase CLI installed (
npm install -g supabase) - Node.js 18+
Initialize Supabase Locally
Start Supabase
Initialize and start the local Supabase instance:This command:
- Pulls required Docker images
- Starts all Supabase services (PostgreSQL, Auth, Storage, etc.)
- Creates a local development environment
The first run may take several minutes to download Docker images.
Note Your Credentials
After starting, Supabase will display important URLs and keys:Copy the
API URL and anon key for your .env file.Local Configuration
Supabase Config File
Thesupabase/config.toml file contains all local development settings:
Key Configuration Sections
API Configuration
- port: Local API endpoint port
- schemas: Database schemas exposed via API
- max_rows: Maximum rows returned per request (prevents accidental large queries)
Authentication Settings
Storage Configuration
Production Setup
Create a Supabase Project
Sign Up for Supabase
- Go to supabase.com
- Sign up or log in
- Click “New Project”
Configure Your Project
Provide the following information:
- Project Name: BoxApp Production (or your preferred name)
- Database Password: Strong password (save this securely)
- Region: Choose closest to your users
- Pricing Plan: Select based on your needs
Wait for Provisioning
Supabase will provision your project (usually takes 1-2 minutes). Once complete, you’ll have access to your project dashboard.
Link Local Project to Production
Deploy Database Schema
Database Migrations
BoxApp includes comprehensive database migrations that set up:- Multi-tenant data isolation with Row Level Security (RLS)
- User authentication and profiles
- WOD (Workout of the Day) management
- Member management and subscriptions
- Competition tracking and scoring
- Lead management
- Financial tracking (expenses, revenue)
- Security audit system
- Avatar storage bucket
Migration Structure
Key migrations include:Multi-Tenant Isolation
BoxApp implements strict tenant isolation using RLS policies. The key helper function:All tables with multi-tenant data include RLS policies that filter by
box_id using the current_user_box_id() function.Storage Setup
Avatar Bucket Configuration
BoxApp uses a storage bucket for user avatars:Additional Storage Buckets
You can create additional buckets for:- Workout images/videos
- Competition media
- Document storage
- Export files
Authentication Configuration
Email Authentication
Configure email settings in the Supabase dashboard:- Navigate to Authentication > Settings
- Configure Email Templates for:
- Confirmation emails
- Password reset
- Magic link
- Set Site URL to your production domain
- Add Redirect URLs for allowed authentication redirects
OAuth Providers (Optional)
Enable social authentication:- Go to Authentication > Providers
- Enable desired providers (Google, GitHub, etc.)
- Configure OAuth credentials from each provider
Environment Variables
Development
Production
Monitoring and Maintenance
Database Performance
Monitor your database in the Supabase dashboard:- Database > Performance: Query performance insights
- Database > Logs: Real-time database logs
- Database > Backups: Automated backup status
Usage Monitoring
Track your usage under Project Settings > Usage:- Database size
- API requests
- Storage usage
- Bandwidth
Troubleshooting
Local Supabase Won’t Start
- Ensure Docker is running
- Check port availability:
lsof -i :54321,54322,54323 - Reset Supabase:
npx supabase db reset
Migration Failures
RLS Policy Issues
Test RLS policies in the SQL Editor:Connection Issues
Verify your connection:Next Steps
- Deployment Guide - Deploy your application
- Environment Variables - Complete environment configuration
- Database Schema - Understand the data model