Skip to main content

Database Reference

Nexus uses PostgreSQL (via Supabase) with approximately 143 tables organized across functional domains. Every table includes an organization_id column (or is indirectly scoped via a parent record) to enforce multi-tenant isolation through Row-Level Security (RLS).

Auto-generated reference

The table dictionary below is auto-generated by scripts/docs-gen/introspect_db.ts and scripts/docs-gen/render_db_docs.ts. To regenerate:

npm run docs:gen

If the database is not accessible, the generator preserves the last generated output and warns.

Table groups

Tables are organized by module/naming convention:

GroupPrefix/PatternTablesDescription
Organizationsorganizations*, organization_*~3Multi-tenant management
Customers / CRMcustomers, customer_*, labels, lead_*~8Contact management
Conversationschats, messages, message_*~4Omnichannel messaging
WhatsAppwhatsapp_*~3WhatsApp configuration
Ordersorders, order_*~4Order management
Fulfillmentpick_*, fulfillment_*~4Pick/pack/ship
Shippingawbs, awb_*~3AWB/shipment tracking
Inventoryinventory_*, warehouses, warehouse_*~8Stock management
Purchase Orderspurchase_orders, po_*, suppliers, vendors~5Procurement
Calls / PBXcall_*, active_calls, pbx_*, user_extensions~6VoIP/telephony
Analyticsshopify_kpis, *_analytics~4Reporting
Automationautomation_*, cron_*~3Workflow automation
Platformplatform_*, profiles, user_sessions~5System management
Integrationsshopify_*, facebook_*, social_*~10External connections
AIai_*, embeddings_*, annotations_*~5AI processing
Competitioncompetition_*~4Market intelligence

RLS overview

Every table with an organization_id column has an RLS policy that:

  1. Extracts the organization_id from the JWT token (auth.jwt() -> 'app_metadata' ->> 'organization_id').
  2. Allows SELECT, INSERT, UPDATE, DELETE only where the row's organization_id matches the token's.
  3. Some tables have additional role-based restrictions (e.g., only owner or admin can delete).

Generated pages

When npm run docs:gen completes successfully, individual table pages appear in subdirectories organized by schema:

  • reference/database/public/<table-name>.md — one page per table with columns, types, constraints, and relationships.

If no generated pages exist yet, run npm run docs:gen with a DOCS_DB_URL environment variable pointing to a read-only database connection.