Environment Configuration

FindU uses separate Supabase projects for development and production environments. This guide explains how to configure and manage these environments.

Architecture Overview

We use separate Supabase projects instead of branches due to Branching 2.0 limitations where preview branches can only merge to main.

The .env.local File

Your .env.local file in the findu root directory controls everything:
# Current environment (dev or prod)
SUPABASE_ENV=dev

# Production credentials
SUPABASE_PROJECT_ID_PROD=fhihneglvyiqwhvfedni
SUPABASE_URL_PROD=https://fhihneglvyiqwhvfedni.supabase.co
SUPABASE_ANON_KEY_PROD=<your-prod-anon-key>
SUPABASE_SERVICE_ROLE_KEY_PROD=<your-prod-service-key>
SUPABASE_DB_PASSWORD_PROD=<your-prod-password>

# Development credentials
SUPABASE_PROJECT_ID_DEV=gcoysibmtdyszenxxpxu
SUPABASE_URL_DEV=https://gcoysibmtdyszenxxpxu.supabase.co
SUPABASE_ANON_KEY_DEV=<your-dev-anon-key>
SUPABASE_SERVICE_ROLE_KEY_DEV=<your-dev-service-key>
SUPABASE_DB_PASSWORD_DEV=<your-dev-password>

# Personal tokens
SUPABASE_ACCESS_TOKEN=<your-personal-token>
GITHUB_TOKEN=<your-github-token>

Switching Environments

Use the findu CLI to switch between environments:
# Switch to development (recommended for daily work)
./findu env switch dev

# Switch to production (be very careful!)
./findu env switch prod

# Check current environment
./findu env status
Always double-check your environment before running migrations or making database changes!

What Happens When You Switch

When you switch environments, the following updates automatically:
  1. Supabase CLI - Points to the correct project
  2. MCP for Claude Code - Updates database credentials
  3. Local environment variables - All tools use the new settings
  4. iOS App Configuration - Updates Secrets.xcconfig with correct Supabase URL and key
  5. Web App Configuration - Updates .env file with correct environment variables

Environment-Specific Features

Development Environment

  • Safe for experimentation
  • Preview branches create here
  • Test data and migrations
  • Faster iteration cycles

Production Environment

  • Real user data
  • Requires extra caution
  • Deployment from main branch only
  • Monitoring and backups enabled

CI/CD Integration

GitHub Actions use organization secrets for each environment:

Development Secrets

  • SUPABASE_URL_DEV
  • SUPABASE_ANON_KEY_DEV
  • SUPABASE_SERVICE_ROLE_KEY_DEV
  • RAILWAY_TOKEN_DEV

Production Secrets

  • SUPABASE_URL_PROD
  • SUPABASE_ANON_KEY_PROD
  • SUPABASE_SERVICE_ROLE_KEY_PROD
  • RAILWAY_TOKEN_PROD

Working with Preview Branches

Preview branches are temporary Supabase environments for testing:
# Created automatically when you open a PR
# Deleted automatically when PR is merged/closed
Each preview branch gets its own:
  • Database copy (schema only, no data)
  • Unique URL for testing
  • Isolated environment

Best Practices

1

Always work in development

Start your day by switching to dev:
./findu env switch dev
2

Test thoroughly before production

  • Test all migrations in dev first
  • Run the app locally against dev
  • Get PR reviews before merging
3

Use preview branches for experiments

Preview branches are perfect for:
  • Testing breaking changes
  • Trying new features
  • Demonstrating work to teammates
4

Monitor production carefully

When in production:
  • Double-check every command
  • Have backups ready
  • Monitor error logs

Troubleshooting

Security Notes

  • Never commit .env.local - It’s gitignored for a reason
  • Rotate credentials regularly - Especially if exposed
  • Use personal access tokens - Not shared credentials
  • Limit production access - Only when necessary

Next, learn about the findu CLI commands to speed up your workflow, or dive into database operations to understand how to work with Supabase.