Supabase Setup
Supabase provides the database, authentication, real-time subscriptions, and Edge Functions.
Project Creation
- Sign in at supabase.com
- Click New Project
- Configure:
- Name:
staccato-coffee - Database Password: Generate and save securely
- Region: Choose closest to your users
- Name:
- Wait for provisioning (~2 minutes)
API Keys
Go to Settings → API:
| Key | Purpose | Where Used |
|---|---|---|
| Project URL | Base URL for all API calls | AppConfig.supabaseURL |
| anon/public key | Client-side authentication | AppConfig.supabaseAnonKey |
| service_role key | Server-side admin access | Never in client code |
Database Schema
Initial Setup
- Go to SQL Editor
- Run
supabase/schema.sql— creates all 14 tables, RLS policies, indexes, sample data - Run migrations in order from
supabase/migrations/
Key Migrations
| Migration | Description |
|---|---|
001_staff_access.sql | RLS policies for employee/admin order access |
002_starbucks_rewards.sql | Enhanced rewards with tiers |
003_enable_realtime.sql | Realtime on orders/order_items |
004-005 | KDS access policies |
006-010 | Menu data updates |
011 | Reward tier gates |
012 | Profile birthday field |
013-014 | Menu updates |
015-018 | Admin CRUD for items/modifiers |
019 | Employee menu access |
Realtime Configuration
Enable Realtime for the order queue:
- Go to Database → Replication
- Under “supabase_realtime”, enable:
orders— Order status changesorder_items— New order items
This powers real-time order updates for the staff view.
Authentication Providers
Email (Default)
- Enabled by default
- Supports sign up and sign in
- Optional email confirmation (recommended for production)
Apple Sign In
- Enable Apple provider in Authentication → Providers
- Required:
- Apple Services ID
- Apple Team ID
- Private key (.p8 file)
- Callback URL:
staccatocoffee://auth/callback
Google OAuth
- Enable Google provider in Authentication → Providers
- Required:
- Google OAuth client ID
- Client secret
- Callback URL:
staccatocoffee://auth/callback
Edge Functions
Deploy
brew install supabase/tap/supabase
supabase login
supabase link --project-ref YOUR_PROJECT_REF
# Set secrets
supabase secrets set SQUARE_ACCESS_TOKEN=your_token
supabase secrets set SQUARE_LOCATION_ID=your_location
# Deploy
supabase functions deploy process-payment
supabase functions deploy sync-square-orderMonitor
# View logs
supabase functions logs process-payment --follow
supabase functions logs sync-square-order --follow