ConfigurationSupabase Setup

Supabase Setup

Supabase provides the database, authentication, real-time subscriptions, and Edge Functions.

Project Creation

  1. Sign in at supabase.com
  2. Click New Project
  3. Configure:
    • Name: staccato-coffee
    • Database Password: Generate and save securely
    • Region: Choose closest to your users
  4. Wait for provisioning (~2 minutes)

API Keys

Go to Settings → API:

KeyPurposeWhere Used
Project URLBase URL for all API callsAppConfig.supabaseURL
anon/public keyClient-side authenticationAppConfig.supabaseAnonKey
service_role keyServer-side admin accessNever in client code

Database Schema

Initial Setup

  1. Go to SQL Editor
  2. Run supabase/schema.sql — creates all 14 tables, RLS policies, indexes, sample data
  3. Run migrations in order from supabase/migrations/

Key Migrations

MigrationDescription
001_staff_access.sqlRLS policies for employee/admin order access
002_starbucks_rewards.sqlEnhanced rewards with tiers
003_enable_realtime.sqlRealtime on orders/order_items
004-005KDS access policies
006-010Menu data updates
011Reward tier gates
012Profile birthday field
013-014Menu updates
015-018Admin CRUD for items/modifiers
019Employee menu access

Realtime Configuration

Enable Realtime for the order queue:

  1. Go to Database → Replication
  2. Under “supabase_realtime”, enable:
    • orders — Order status changes
    • order_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

  1. Enable Apple provider in Authentication → Providers
  2. Required:
    • Apple Services ID
    • Apple Team ID
    • Private key (.p8 file)
  3. Callback URL: staccatocoffee://auth/callback

Google OAuth

  1. Enable Google provider in Authentication → Providers
  2. Required:
    • Google OAuth client ID
    • Client secret
  3. 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-order

Monitor

# View logs
supabase functions logs process-payment --follow
supabase functions logs sync-square-order --follow