Seedworks Labs Wiki The engineering referenceStudio website ↗
Studio & ecosystem

Supabase reference

Shared platform contracts, app schemas, migrations and regression tests.

Engineering documentation • Reviewed 2026-11-29

One shared project, explicitly separated contracts#

Seedworks Labs operates a centralized Supabase database for its application ecosystem. The Supabase repository owns the server-side schema for shared Seed accounts and application cloud features. It contains ordered SQL migrations, SQL regression suites, local configuration and the delete-account Edge Function.

The client-facing project URL and publishable key are public configuration. The service-role key is not. A static website/wiki never needs that secret.

Schema responsibilities#

Schema Responsibility Typical access
auth Supabase-managed identities/sessions Auth APIs; privileged server integration
public Seed app registry, profiles, connections, usage and platform RPCs Explicit account/platform calls
coconut Finance sync, Shared Spaces and associated RPCs Coconut client plus owner/member/client rules
banana Meal-planning sync and household identities Banana client plus identity membership rules
cherry Reserved app namespace in reviewed baseline Do not infer shipped sync from schema existence
pomelo Private note sync and own-profile RPCs New local migration; deployment not verified here

Clients set a default app schema in createClient(..., { db: { schema: "coconut" } }). Shared calls must target public explicitly:

await client.schema('public').rpc('seed_report_app_usage', {
  p_app_slug: 'coconut',
  p_record_count: 1234,
  p_byte_count: 456789,
  p_device_name: 'Example device',
});

The user's access token authorizes that call. A publishable key alone does not make it an authenticated owner request.

Platform tables and RPCs#

The account baseline creates:

  • seed_apps: public app labels/order/registry.
  • seed_profiles: one profile per Auth user, automatically created.
  • seed_app_connections: app/device activity records.
  • seed_app_usage: reported app-level record/byte counts.
  • seed_report_app_usage: authenticated reporting entry point.
  • seed_account_overview: account payload without exposing arbitrary app tables.

Later migrations bridge usernames, add OAuth boundary wrappers and add private processed pictures. The public registry is intentionally different from private account data.

Apps must be registered before reporting usage. A zero/empty overview can simply mean no report has occurred; the website should not invent connected apps.

Migration ledger#

These are source-file responsibilities, not a production deployment ledger:

Migration prefix / name Purpose
20261110090000_seed_accounts Shared platform baseline
20261110100000_seed_app_schemas Coconut/Cherry/Banana namespaces and grants
20261110101000_coconut_schema Personal/cloud/shared Coconut baseline and RLS
20261110102000_migrate_legacy_public_coconut Move early public-schema finance tables into Coconut
20261112090000_shared_transaction_mirror_identity Deduplicate/enforce identity for shared personal mirrors
20261112100000_seed_username_bridge Central profile ↔ Coconut username compatibility
20261112110000_coconut_transaction_rating_exclusion Optional rating-exclusion flag
20261112120000_coconut_shared_membership_hardening Tighten membership/lifecycle authorization
20261115120000_banana_personal_sync Banana cloud row-payload tables and owner policies
20261118090000_coconut_month_subscription_sync Month-specific subscription synchronization
20261118120000_banana_shared_life Household identities, invitation RPCs and dataset membership
20261121120000_oauth_client_isolation Restrictive client policies, REST guard and readiness RPC
20261123120000_seed_profile_pictures Private PNG storage and narrow getter/setter routes
20261123140000_coconut_sync_notifications Add selected Coconut tables to realtime publication if present
20261123150000_pomelo_sync Private note revision/CAS sync and profile contract

The last two migrations and their SQL tests were untracked local files at review. Backend README/configuration also had local changes. Links to those files may not resolve publicly until the owner commits/pushes them. This wiki does not apply, commit or deploy them.

Coconut server model#

Personal tables use owner-scoped rows and portable identities. Shared tables use related space membership. Server helpers support membership operations and lifecycle handling. Personal mirror uniqueness prevents duplicate spending rows for one shared expense source.

The migration chain matters: applying only the baseline omits later membership hardening, subscription rows, OAuth restrictions and profile compatibility.

Local SQLite schema changes are independent. A new client column/table needs corresponding server support and compatibility tests; changing the app's migration list does not update Supabase.

Banana server model#

The personal-sync migration creates cloud row envelopes with UUID, owner field, payload and timestamp plus settings/tombstones. The later shared-life migration changes the meaning of the owner field to a data_identities UUID.

resolve_data_identity selects the current personal or household namespace. can_access_identity enforces personal/membership access. Invitation/status/leave RPCs handle consent and active membership; they do not merge two personal datasets.

This is why blindly checking user_id = auth.uid() everywhere after household support would be incorrect: authorized household rows can have a different dataset UUID.

Newer local Pomelo contract#

The reviewed local Pomelo migration registers a private schema and provides:

  • pomelo_sync_push(p_changes): bounded batches with expected revision and explicit accepted/conflict acknowledgements.
  • pomelo_sync_pull(p_cursor): count/byte-bounded cursor pagination.
  • pomelo_profile(): only the caller's username and processed picture.

Direct table/internal helper execution is not granted to normal API users. Native password sessions are supported; Coconut/unknown delegated clients are denied. The revision-head design serializes allocation through commit so pagination cannot skip a later-committing lower revision.

This is a backend orientation, not the promised full Pomelo product reference. See coverage. Do not substitute these revision semantics for Coconut/Banana timestamp sync.

Configuration versus deployed settings#

supabase/config.toml configures local development. Hosted projects require separate dashboard configuration:

  • Expose the reviewed app schemas through the API.
  • Keep the shared Auth Site URL at the central website.
  • Allow exact central signup/recovery redirects.
  • Register the exact public Coconut OAuth callback separately from general Auth redirect URLs.
  • Disable dynamic OAuth client registration.
  • Configure confirmation, password-security settings, rate limits and email abuse protections.
  • Deploy the intended Edge Function and allowed-origin configuration.

An app targeting an unexposed schema can fail before its row policy is even evaluated. A saved hook setting can also differ from what existing PostgREST connections have loaded.

Edge Function secrets and deletion#

The deletion function reads server-provided Supabase URL, anon key and service-role key. SEEDWORKS_ALLOWED_ORIGINS can override the default central-origin list.

Changing a source default does not override an already deployed secret. Deployment and secret updates must be reviewed separately. See account deletion for request/password/client checks and cascading behavior.

Safe deployment discipline#

Preparing source files is not authorization to run production migrations. Before an intentional rollout:

  1. Review current migration history and take a recoverable backup.
  2. Test the ordered chain on an isolated database, including legacy upgrade paths where applicable.
  3. Run policy/RPC suites and inspect grants.
  4. Review the hosted API/Auth configuration separately.
  5. Apply reviewed migrations and deploy the matching function through the owner's normal process.
  6. Verify actual HTTP denials and browser/device flows in staging.
  7. Deploy dependent frontends only after required server boundaries are active.

The legacy public-to-Coconut migration can drop old public copies after moving them. It needs backup/review; do not treat the entire chain as a harmless preview command.

Regression suites#

The repository contains rollback-oriented SQL tests for OAuth isolation and profile pictures, plus local suites for newer Coconut notifications and Pomelo sync.

Example for an intentionally isolated local database:

psql "$LOCAL_DATABASE_URL" -v ON_ERROR_STOP=1 -f supabase/tests/oauth-isolation.sql
psql "$LOCAL_DATABASE_URL" -v ON_ERROR_STOP=1 -f supabase/tests/profile-pictures.sql

These commands are documentation, not executed by the wiki. Never point test fixtures at production. SQL tests cannot by themselves prove that the running PostgREST service loaded a pre-request hook or that a hosted redirect/client registration matches the source.