HOW SUPABASE
ACTUALLY WORKS
The open-source Firebase alternative. Conventions, patterns, and architecture extracted from the supabase/supabase repository by sourcebook.
WHAT_MATTERS
-
→
This is a monorepo — check workspace dependencies before modifying shared code
-
→
packages/ui/src/lib/utils/cn.ts is a hub file (imported by 57 files) — changes here ripple everywhere
-
→
Circular import chains detected — avoid adding to these cycles
KEY_FINDINGS
Local Supabase setup detected (supabase/ directory). Use `supabase db push` for migrations, not the dashboard.
HIGHThis is a monorepo. Changes may affect multiple packages. Check workspace dependencies before modifying shared code.
HIGHTests are co-located with source files (*.test.ts next to *.ts). Keep this pattern -- don't create a separate test/ directory.
HIGHProject uses barrel exports (index.ts files that re-export). Import from the directory, not from deep paths.
HIGH14 barrel export files found
Project strongly prefers named exports over default exports. Use `export function` / `export const`, not `export default`.
HIGH53 named vs 6 default exports in sampled files
Data fetching uses React Query (useQuery/useMutation). Follow this pattern for new data operations.
HIGH15 files
Hub files (most depended on): packages/ui/src/lib/utils/cn.ts (imported by 57 files); packages/pg-meta/src/pg-format/index.ts (imported by 40 files); packages/icons/src/createSupabaseIcon.ts (imported by 34 files); apps/studio/data/storage/keys.ts (imported by 24 files); packages/marketing/src/go/schemas.ts (imported by 23 files). Changes here have the widest blast radius.
HIGHCircular import chains detected: useCommandMenuTelemetry.ts → useCommandMenuTelemetryContext.tsx; Day5.tsx → index.tsx; CustomersSliderMobile.tsx → index.tsx. Avoid adding to these cycles.
HIGH