System map

One page. Where things live and which way traffic flows.

Layers (outside in)

LayerWhat it isIn this repo
ClientsiOS/RN app, web, crawlers, Slack, vendor webhooksnot here (see config.toml redirect URLs)
Kong gatewayRoutes /functions/v1, /rest/v1, /auth/v1; checks apikeyinvisible; behaviour noted in _shared/jwt/default.ts
Edge runtimeDeno, one isolate per function, Deno.serve entrysrc/supabase/functions/*/index.ts
PostgRESTREST over exposed schemas, RLS enforced[api].schemas in config.toml
PostgresTables, RLS, functions, pg_cron, pg_net, vaultsrc/supabase/migrations/ (239 files)
External APIsMassive, Quartr, SnapTrade, Resend, Google, Slack, OpenAI, SEC EDGARcalled from handlers; keys in function env

Three traffic directions

AInbound user request. Client → Kong → edge function router → handler → supabase-js (anon or user JWT) → Postgres under RLS → JSON back. Gate order inside the function: OPTIONS, CORS origin, then route. stocks/index.ts
BScheduled internal call. pg_cron → SQL job → private.post_to_edge_function(path, body) → pg_net → Kong → edge function with service_role bearer + Origin: https://api.wallstreetbets.com → handler calls vendor API → writes with service client (RLS bypassed). migrations/*schedule*.sql
CInbound vendor webhook / DB trigger. Quartr, SnapTrade sign payloads with HMAC; handler verifies, writes. DB triggers (waitlist welcome email, Slack alerts) use direction B's transport. quartr-webhook-handling/, notify-slack/

Function inventory

FunctionAuth tierRole
stockspublic + service routesmarket data API and all ingestion/refresh jobs (30 handlers)
earnings, earnings-cachepublic / userQuartr-derived earnings data
quartr-webhook-handling, snaptrade-webhookHMACvendor push ingestion
brokerage, account, feed, submit-feedbackuser JWTper-user features
news-admin, news-api, news-publicAPI key / publicnews CMS surfaces
send-email, notify-slack, fx, clickup-sprint-guard, proxyservice / hookinternal utilities

Shared primitives (_shared/)

FileUse it for
cors.tsOPTIONS handling and the Origin allow-list. Missing Origin is a 403.
jwt/default.tsgetUserId (user JWT via JWKS) and validateServiceRole (shared-secret check).
utils.tscreateSuccessResponse / createErrorResponse, the canonical JSON envelope.
validation.ts, canonicalTicker.tsInput validation at the trust boundary.
audit.tsWrites to the audit schema.

Tooling

Command (from src/)Effect
npx supabase startDocker stack: Postgres 54322, API 54321, Studio 54323, Mailpit 54324. Applies migrations + seed.sql.
npx supabase functions serve --no-verify-jwtRuns every function in one edge runtime with hot reload. The flag skips Kong's JWT check locally.
npx supabase db resetDrop and replay all migrations. The local way to apply a new migration.
npx supabase test dbRun pgTAP files.
deno test --allow-all supabase/tests/functions/Edge function tests. CI runs only the standalone subset.
never db push / functions deployProd is deployed by the GitHub integration on merge to main.