There is no custom backend server. All server-side logic uses Supabase: PostgreSQL (tables, views, triggers, RLS), Auth API, Storage, and Edge Functions.
Prefer frontend-only solutions via custom dataProvider methods calling the PostgREST API.
When backend logic is needed:
- Aggregation/read optimization: Create a database view (
CREATE OR REPLACE VIEWin a new migration). PostgREST exposes views like tables. When underlying table columns change, update thecontacts_summaryandcompanies_summaryviews too. - Complex mutations (multi-table writes): Create a Supabase edge function in Deno. Stored procedures via RPC are less preferred (code lives in migrations, harder to maintain). On the frontend, expose the edge function as a custom dataProvider method (using
httpClient(${supabaseUrl}/functions/v1/)) and call it via react-query. (e.g.salesCreate()→/functions/v1/users,mergeContacts()→/functions/v1/merge_contacts)
Edge function conventions:
- Shared utils in
supabase/functions/_shared/— reuseauthentication.ts,supabaseAdmin.ts,cors.ts,utils.ts - Follow the middleware chain pattern: CORS preflight →
authenticate()→ handler verify_jwt = falsein config.toml, so JWT validation is manual viaauthenticate()
Other conventions:
- New tables need RLS policies and the auto-set
sales_idtrigger (see migration20260108160722)
Converted and distributed by TomeVault — claim your Tome and manage your conversions.