Architecture
Edge runtime, server functions, data model and AI routing.
Stack
- Frontend — React 19, TanStack Router/Start v1, Vite 7, Tailwind v4.
- Backend — TanStack server functions running on an edge runtime.
- Database + auth — managed Postgres with Row-Level Security.
- AI — server-side model routing; keys never reach the browser.
- Payments — Razorpay, INR, one-time orders.
- Email — transactional templates through managed email infrastructure.
Request path
- The browser calls a typed server function with the session bearer token attached.
- Auth middleware verifies the token and resolves the user before the handler runs.
- The handler reads limits, calls the model server-side and records usage.
- The response streams or returns; nothing sensitive crosses the boundary.
Data model highlights
| Table | Holds | Access |
|---|---|---|
| conversations / messages | Code Studio history | Owner only via RLS |
| brand_profiles | Tone and audience memory | Owner only |
| saved schemas | Synthetic data definitions | Owner only |
| user_plans | Active plan and expiry | Owner read, service write |
| user_roles | Role assignments | Read via has_role() only |
| processed_webhook_events | Replay protection | Service role only |
| abuse_log | Rate-limit offenders | Service role only |
