Overview
Money Tracker production deployment involves:- Creating a Supabase project
- Deploying the database schema and Edge Functions
- Configuring production secrets
- Deploying the frontend to a hosting provider
- Setting up Google Cloud integrations
Prerequisites
- Supabase account with a project created
- Supabase CLI installed locally
- Google Cloud Console project
- Hosting provider account (Vercel, Railway, Fly.io, etc.)
Step 1: Create Supabase project
Create a new project
- Go to Supabase Dashboard
- Click “New project”
- Choose your organization
- Enter project name and database password
- Select a region close to your users
- Wait for provisioning to complete (2-3 minutes)
Link local project to remote
https://app.supabase.com/project/[your-project-ref]Step 2: Configure production secrets
Edge Functions secrets
Set all required environment variables for Edge Functions:Vault secret
Therenew_gmail_watches() database function requires INTERNAL_FUNCTIONS_SECRET in the Vault:
Step 3: Deploy Edge Functions
Deploy all Edge Functions to production:After deploying functions, verify they’re running in the Supabase Dashboard under Edge Functions.
Step 4: Configure Google Cloud
OAuth credentials
Create OAuth consent screen
- Go to Google Cloud Console
- Navigate to APIs & Services > OAuth consent screen
- Select “External” user type
- Fill in app name, user support email, and developer contact
- Add scopes:
https://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/gmail.modify
- Add test users if in testing mode
Create OAuth credentials
- Go to APIs & Services > Credentials
- Click “Create Credentials” > “OAuth client ID”
- Choose “Web application”
- Add authorized redirect URIs:
https://your-domain.com/auth/callback
- Copy Client ID and Client Secret to your Edge Functions secrets
Pub/Sub configuration
Step 5: Deploy frontend
The frontend is a static React application built with Vite. You can deploy it to any static hosting provider.Option 1: Vercel
Option 2: Railway
Connect your repository
- Go to Railway
- Click “New Project” > “Deploy from GitHub repo”
- Select your repository
Configure build settings
- Build Command:
cd packages/frontend && bun install && bun run build - Start Command:
bun run preview - Root Directory:
/
Option 3: Custom server
Build and serve the frontend manually:dist/ folder with any static file server:
Ensure your web server is configured for single-page applications. All routes should serve
index.html for client-side routing to work.Step 6: Update CORS and redirect URIs
Update your production URLs in:-
Edge Functions secrets:
-
Google Cloud Console:
- Update authorized redirect URIs in OAuth credentials
- Update authorized domains in OAuth consent screen
-
Supabase Dashboard:
- Go to Authentication > URL Configuration
- Add
https://your-domain.comto “Site URL” - Add
https://your-domain.com/auth/callbackto “Redirect URLs”
Seed production data
To manually run seed scripts on production:Post-deployment checklist
Test OAuth flow
- Visit your frontend at
https://your-domain.com - Sign up for a new account
- Connect Gmail
- Verify OAuth redirect works correctly
Verify Gmail webhook
- Connect Gmail in the app
- Check that a watch was created: view
gmail_connectionstable - Send a test transaction email to your Gmail
- Verify it appears in the app within 30 seconds
Check cron job logs
The
renew_gmail_watches() function runs every day at 2 AM UTC.View logs in Supabase Dashboard under Database > Extensions > pg_cron:Monitoring and maintenance
Health checks
The/health endpoint provides a simple health check:
Gmail watch renewal
Gmail watches expire after 7 days. The cron job automatically renews them:Database backups
Supabase automatically backs up your database daily. To create manual backups:Scaling considerations
- Database: Supabase Pro plan includes connection pooling and read replicas
- Edge Functions: Automatically scale with Deno Deploy
- Gmail API: Subject to quota limits
- Pub/Sub: Monitor message delivery latency in Google Cloud Console
Troubleshooting
OAuth redirect fails
OAuth redirect fails
- Verify redirect URI matches exactly in Google Cloud Console
- Check CORS_ALLOWED_ORIGINS and FRONTEND_URL secrets
- Ensure OAuth consent screen is published (not in testing mode)
Gmail webhook not receiving messages
Gmail webhook not receiving messages
- Check Pub/Sub subscription is active:
gcloud pubsub subscriptions describe gmail-notifications-sub - Verify IAM permissions for
[email protected] - Test webhook endpoint manually
- Check watch expiration in
gmail_connectionstable
Cron job failing
Cron job failing
- Verify
INTERNAL_FUNCTIONS_SECRETmatches in both Edge Functions secrets and Vault - Check cron logs:
select * from cron.job_run_details - Manually trigger:
select renew_gmail_watches();
High database connection count
High database connection count
- Enable connection pooling in Supabase Dashboard
- Use
supavisorfor transaction pooling - Audit Edge Functions for connection leaks
Edge Function timeout
Edge Function timeout
- Check function execution time in logs
- Optimize database queries (add indexes, reduce joins)
- Increase timeout in function config (max 120s)
Rolling back
If you need to roll back a deployment:Roll back Edge Functions
Roll back database migrations
Security recommendations
- Enable database webhooks for audit logging
- Use Supabase Auth hooks to validate new user signups
- Rotate
INTERNAL_FUNCTIONS_SECRETquarterly - Enable Google Cloud audit logging for OAuth and Pub/Sub
- Use Supabase Network Restrictions to limit database access
- Set up rate limiting for Edge Functions
- Enable Supabase WAF for production projects
Cost optimization
- Use Supabase connection pooling to reduce database connections
- Implement edge caching for static assets
- Optimize database queries and add appropriate indexes
- Monitor Edge Function invocations and optimize frequently called functions
- Set up Google Cloud budget alerts
- Consider Supabase Pro plan for better performance and support