How to understand a Supabase (with Edge Functions) codebase
A Supabase app usually talks to Postgres straight from the client with `supabase-js`, with row-level security policies deciding what each user can see. Server logic that can't run in the client lives in Edge Functions, which run on Deno.
How to tell it's Supabase (with Edge Functions)
- A
supabase/folder withconfig.toml,migrations/andfunctions/ @supabase/supabase-jsandcreateClient(...)in the app- Edge Functions calling
Deno.serveinsupabase/functions/<name>/index.ts
Where things usually live
- supabase/migrations/
- SQL migrations: tables, policies, functions, triggers.
- supabase/functions/<name>/index.ts
- One Edge Function per folder.
- supabase/config.toml
- Local development settings.
- src/lib/supabase.ts
- Client creation in the app.
Conventions, not rules. Real projects rename and move things, so confirm against the repository.
Where to start reading
- The migrations, for tables and row-level security policies
- Every
supabase.from(...)call in the app - Edge Functions the app calls with
supabase.functions.invoke
How a request moves through the code
- The app queries a table with
supabase.from('table'), sending the user's JWT. - Postgres applies row-level security policies for that user.
- For privileged work, the app invokes an Edge Function.
- The function runs on Deno, often with the service-role key, and returns a response.
Questions to ask about the repository
- Which tables does the client query directly, and which policies protect them?
- Which Edge Functions use the service-role key?
- Where are database triggers or functions doing hidden work?
What trips people up
- Security lives in SQL policies, so reading only the TypeScript misses half the access rules.
- The service-role key bypasses row-level security and must never reach the browser.