Skip to main content

Architecture

Monorepo Structure

Tonnex uses Turborepo for monorepo management with pnpm workspaces.

Data Flow

  1. Userapps/web (Next.js) for UI interactions
  2. apps/web → Server Actions for simple mutations
  3. apps/web → Proxy (/api/v1/*) → apps/api (NestJS) for business logic
  4. apps/api@tonnex/db (Drizzle) → Supabase PostgreSQL
  5. Supabase RLS ensures data isolation per org_id

Authentication Flow

Multi-Tenancy

Every table has org_id. PostgreSQL Row Level Security (RLS) policies filter data automatically: