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:
| Group | Prefix/Pattern | Tables | Description |
|---|---|---|---|
| Organizations | organizations*, organization_* | ~3 | Multi-tenant management |
| Customers / CRM | customers, customer_*, labels, lead_* | ~8 | Contact management |
| Conversations | chats, messages, message_* | ~4 | Omnichannel messaging |
whatsapp_* | ~3 | WhatsApp configuration | |
| Orders | orders, order_* | ~4 | Order management |
| Fulfillment | pick_*, fulfillment_* | ~4 | Pick/pack/ship |
| Shipping | awbs, awb_* | ~3 | AWB/shipment tracking |
| Inventory | inventory_*, warehouses, warehouse_* | ~8 | Stock management |
| Purchase Orders | purchase_orders, po_*, suppliers, vendors | ~5 | Procurement |
| Calls / PBX | call_*, active_calls, pbx_*, user_extensions | ~6 | VoIP/telephony |
| Analytics | shopify_kpis, *_analytics | ~4 | Reporting |
| Automation | automation_*, cron_* | ~3 | Workflow automation |
| Platform | platform_*, profiles, user_sessions | ~5 | System management |
| Integrations | shopify_*, facebook_*, social_* | ~10 | External connections |
| AI | ai_*, embeddings_*, annotations_* | ~5 | AI processing |
| Competition | competition_* | ~4 | Market intelligence |
RLS overview
Every table with an organization_id column has an RLS policy that:
- Extracts the
organization_idfrom the JWT token (auth.jwt() -> 'app_metadata' ->> 'organization_id'). - Allows
SELECT,INSERT,UPDATE,DELETEonly where the row'sorganization_idmatches the token's. - Some tables have additional role-based restrictions (e.g., only
owneroradmincan 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.