Edge functions
NativeExpress includes four Supabase Edge Functions , each running on Deno in supabase/functions/.
| Function | What it does | Custom secrets |
|---|---|---|
chat | Streams AI chat responses, persists threads and messages | Yes |
generate | Image generation for the Create tab | Yes |
identify | Object identification for the Scan tab | Yes |
delete-account | Removes the user’s stored images, then deletes their account | No |
Supabase supplies the database connection settings for all four functions. Set function secrets before using the AI features.
Every function authenticates the caller using their Supabase access token. Shared
helpers in _utils/ handle provider access, entitlements, quota and storage.
Files
- auth.ts - Caller authentication and Supabase clients
- http.ts - Request validation and error responses
- ai.config.json - Models, presets and default allowance
- registry.ts - Shared configuration exports
- provider.ts - OpenRouter client
- entitlements.ts - RevenueCat Pro checks
- quota.ts - Monthly usage checks
- media.ts - Image uploads and downloads
- storage.ts - Account image cleanup
- index.ts - Streaming chat handler
- deno.json - Function dependencies and compiler settings
- index.ts - Image generation handler
- index.ts - Scan handler
- index.ts - Account deletion handler
Each function has its own deno.json. When adding a function, copy a sibling’s
configuration and run yarn check:functions to check its types and the shared tests.
This needs Deno
installed. Without Deno, the local script checks the configuration files and skips
the type checks and tests.
See the AI request diagram for how the app, functions, provider and database connect.