# WSB-Backend Resources

## Knowledge

### In-repo (primary, always current)
- [README.md](/Users/vivek/wsb/WSB-Backend/README.md)
  Setup, project structure, run commands. Use for: local stack ports, where commands run from.
- [CLAUDE.md](/Users/vivek/wsb/WSB-Backend/CLAUDE.md)
  House rules: run CLI from `src/`, never `db push`/`functions deploy`, type conventions, test priority order.
- [docs/EDGE_FUNCTIONS_STATE.md](/Users/vivek/wsb/WSB-Backend/docs/EDGE_FUNCTIONS_STATE.md)
  Every endpoint, its auth tier, external APIs, ingestion invariants. Use for: "what does /stocks/x do".
- [docs/DATABASE_SCHEMA.md](/Users/vivek/wsb/WSB-Backend/docs/DATABASE_SCHEMA.md)
  Schema reference. Use for: table shapes before reading migrations.
- [docs/DEPLOYMENT_GUIDE.md](/Users/vivek/wsb/WSB-Backend/docs/DEPLOYMENT_GUIDE.md)
  How prod gets code. Use for: link/push/deploy/unlink sequence and why we unlink.
- [stocks/docs/TIERED_RETENTION_ARCHITECTURE.md](/Users/vivek/wsb/WSB-Backend/src/supabase/functions/stocks/docs/TIERED_RETENTION_ARCHITECTURE.md)
  Price history partitions and tiers. Use for: anything touching `Stock_Price_History`.
- [src/supabase/config.toml](/Users/vivek/wsb/WSB-Backend/src/supabase/config.toml)
  Function declarations, auth providers, exposed schemas. Comments explain prod-vs-local gaps.

### Supabase (official docs, also mirrored at `ssh supabase.sh cat /supabase/docs/...`)
- [Edge Functions overview](https://supabase.com/docs/guides/functions)
  What the edge runtime is, limits, how routing to `/functions/v1/<name>` works.
- [Edge Functions: dependencies & import maps](https://supabase.com/docs/guides/functions/dependencies)
  `deno.json`, `jsr:`/`npm:` specifiers, why `_shared/` exists.
- [Edge Functions: unit testing](https://supabase.com/docs/guides/functions/unit-test)
  The pattern CLAUDE.md mandates for Deno tests.
- [Row Level Security](https://supabase.com/docs/guides/database/postgres/row-level-security)
  Why the anon key is safe to ship and what `service_role` bypasses.
- [Verifying a JWT](https://supabase.com/docs/guides/auth/jwts#verifying-a-jwt-from-supabase)
  Source of `_shared/jwt/default.ts`.
- [pg_cron](https://supabase.com/docs/guides/database/extensions/pg_cron), [pg_net](https://supabase.com/docs/guides/database/extensions/pg_net), [Vault](https://supabase.com/docs/guides/database/vault)
  The three pieces behind `private.post_to_edge_function`.
- [Local development & CLI](https://supabase.com/docs/guides/local-development)
  `supabase start`, `db reset`, migrations, `config.toml` semantics.
- [pgTAP testing](https://supabase.com/docs/guides/database/extensions/pgtap)
  The database test framework used in `src/supabase/tests/database/`.

### Deno (official)
- [Deno Manual: Fundamentals](https://docs.deno.com/runtime/fundamentals/)
  Modules, `deno.json`, permissions, standard library.
- [Deno: `Deno.serve`](https://docs.deno.com/api/deno/~/Deno.serve)
  The only HTTP entrypoint edge functions use.
- [Deno: Modules and dependencies](https://docs.deno.com/runtime/fundamentals/modules/)
  `jsr:`, `npm:`, `https:` specifiers, lockfile, import maps.
- [JSR](https://jsr.io/docs/introduction)
  Why `jsr:@supabase/supabase-js@2` and `jsr:@std/assert` rather than npm.

## Wisdom (Communities)
- [Supabase Discord](https://discord.supabase.com)
  Official; `#edge-functions` and `#database` channels. Use for: runtime quirks, Kong header stripping.
- [Deno Discord](https://discord.gg/deno)
  Official. Use for: module resolution, permissions, `npm:` compat issues.
- [GitHub Discussions: supabase/supabase](https://github.com/orgs/supabase/discussions)
  Searchable history of CLI/runtime edge cases.

## Gaps
- No single doc explains the Kong gateway layer between client and edge runtime; lesson 1 reconstructs it from behaviour (`validateServiceRole` comments).
