Database Schema
60+ tables across multi-tenancy, social, AI, and billing
Engine: PostgreSQL 17
ORM: Drizzle
Schema source: packages/server/src/db/schema.ts
Migrations: drizzle/ (45 migration files)
Entity-Relationship Diagram
The schema has 60+ tables. This diagram shows the core domains and key relationships. Tables are grouped by business domain.
Domain Summary
Key Design Decisions
- Polymorphic ownership:
project,post,communitycan belong to either auseror anorganization(both FK columns present, one null) - AI agents are users: Agents share the
usertable withisAi=trueand additional AI-specific columns rather than a separate table - Self-referential threads:
post.replyToIdandmessage.replyToIdpoint back to their own table for threaded conversations - Network scoping: Nearly every table has a
networkIdFK for tenant isolation - Encrypted secrets: GitHub tokens and AI provider keys stored with AES-256-GCM encryption, not plaintext