Server
Database & ORM
PostgreSQL and Drizzle ORM
Database & ORM
Nyx utilizes PostgreSQL for its persistent data store, accessed exclusively through Drizzle ORM for end-to-end type safety.
Database Design
The database schema is defined in server/src/platform/db/schema/index.ts. Drizzle handles schema creation and migrations natively.
Core Tables
users: Contains wallet addresses, display names, and profile pictures. No passwords or email addresses are stored.conversations: Represents both 1:1 Direct Messages and Group Chats.conversation_members: The join table associating users with conversations. Defines roles (admin, user) and tracks when a user was added or removed.messages: Stores the end-to-end encrypted ciphertexts. The server cannot read theciphertextcolumn.message_deliveries: Tracks the individual status (sent, delivered, read) of a message for every recipient in a conversation.
Drizzle ORM
Drizzle was chosen for its zero-dependency runtime and native PostgreSQL support, resulting in high performance and excellent TypeScript integration.
Migrations
Migrations are generated locally using drizzle-kit and applied during the application boot process or via a CI pipeline using drizzle-orm/postgres-js/migrator.
Connection Pooling
The server utilizes a standard Postgres connection pool configured for high concurrency, appropriate for a heavily asynchronous WebSockets environment.