User Model
TheUser model is the central entity representing a Deltalytix user with authentication, preferences, and relationships to all user-owned data.
Schema Fields
Unique identifier for the user
- Constraint: Primary key
- Default: Auto-generated CUID
User’s email address
- Constraint: Unique
- Indexed: Yes (performance optimization)
- Used for authentication and notifications
External authentication provider user ID
- Constraint: Unique
- Links to authentication service (e.g., Auth0, Clerk)
Whether this is the user’s first login
- Default: true
- Used to trigger onboarding flows
Token for ETP (External Trading Platform) integration
- Optional field for third-party integrations
Whether the user has beta access to new features
- Default: false
User’s preferred language
- Default: “en”
- ISO language code (e.g., “en”, “fr”, “es”)
Token for Thor integration
- Optional field for Thor platform access
Relationships
The User model has extensive relationships with other entities:All trading accounts owned by the user
- One-to-Many: One user can have multiple accounts
All businesses created by the user
- One-to-Many: One user can own multiple businesses
All teams created by the user
- One-to-Many: One user can create multiple teams
Team subscriptions associated with the user
- One-to-Many: Multiple team subscriptions possible
All comments made by the user
- One-to-Many: Users can make multiple comments
User’s custom dashboard layout
- One-to-One: Each user has one dashboard layout
Account groups created by the user
- One-to-Many: Users can organize accounts into multiple groups
Mood journal entries by the user
- One-to-Many: Daily mood tracking entries
Notifications for the user
- One-to-Many: Users receive multiple notifications
Trading orders placed by the user
- One-to-Many: Users can place multiple orders
Feature requests, bug reports, and discussions posted by the user
- One-to-Many: Users can create multiple posts
Individual subscription for the user
- One-to-One: Each user has at most one individual subscription
Account synchronization records
- One-to-Many: Multiple sync configurations per user
Custom tags created by the user
- One-to-Many: Users can create multiple tags for organization
Votes on feature requests and discussions
- One-to-Many: Users can vote on multiple posts
Business subscriptions owned by the user
- One-to-Many: Multiple business subscriptions possible
Referral information for the user
- One-to-One: Each user has at most one referral record
Indexes
email- Fast lookup and authentication by email
DashboardLayout Model
Stores customized dashboard widget layouts for desktop and mobile views.Schema Fields
Unique identifier for the layout
- Constraint: Primary key
- Default: Auto-generated UUID
ID of the user who owns this layout
- Constraint: Unique (one layout per user)
- Foreign Key: References
User.auth_user_idwith cascade delete - Indexed: Yes
Timestamp when the layout was created
- Default: Current timestamp
Timestamp when the layout was last updated
- Auto-updated: Updates automatically on modification
Desktop layout configuration
- Default: Empty array ”[]”
- JSON structure defining widget positions and sizes
Mobile layout configuration
- Default: Empty array ”[]”
- JSON structure defining widget positions for mobile
Indexes
userId- Fast lookup of layout by user
Relationships
The user who owns this layout
- Foreign Key:
userId→User.auth_user_id - Delete Behavior: Cascade
Synchronization Model
Manages automated synchronization of trading data from external platforms.Schema Fields
Unique identifier for the sync record
- Constraint: Primary key
- Default: Auto-generated UUID
ID of the user who owns this sync
- Foreign Key: References
User.idwith cascade delete - Indexed: Yes
Name of the external service
- Indexed: Yes
- Examples: “TopstepTrader”, “Rithmic”, “TradeStation”
External account identifier
- Account ID on the external platform
Timestamp of the last successful sync
- Used to determine incremental sync windows
Timestamp when the sync was created
- Default: Current timestamp
Timestamp when the sync was last updated
- Auto-updated: Updates automatically on modification
OAuth or API token for the service
- Encrypted access token
Expiration time for the token
- Used to trigger token refresh
Scheduled time for daily automatic sync
- Optional field for scheduled syncs
Indexes
userId- Fast lookup of syncs by userservice- Filter syncs by service type
Unique Constraints
- Combination of
userId,service, andaccountIdmust be unique (prevents duplicate sync configurations)
Relationships
The user who owns this synchronization
- Foreign Key:
userId→User.id - Delete Behavior: Cascade
Notification Model
Stores user notifications for important events and updates.Schema Fields
Unique identifier for the notification
- Constraint: Primary key
- Default: Auto-generated CUID
ID of the user who receives this notification
- Foreign Key: References
User.idwith cascade delete - Indexed: Yes
Notification title
- Brief summary of the notification
Detailed notification message
- Full notification content
Timestamp when the notification was created
- Default: Current timestamp
Timestamp when the notification was read
nullindicates unread notification
Indexes
userId- Fast lookup of notifications by user
Relationships
The user who receives this notification
- Foreign Key:
userId→User.id - Delete Behavior: Cascade
Referral Model
Tracks referral program participation and referred users.Schema Fields
Unique identifier for the referral record
- Constraint: Primary key
- Default: Auto-generated UUID
ID of the user who owns this referral
- Constraint: Unique (one referral record per user)
- Foreign Key: References
User.idwith cascade delete - Indexed: Yes
Unique referral slug/code
- Constraint: Unique
- Indexed: Yes
- Used in referral URLs
Array of user IDs who signed up via this referral
- Default: Empty array
- Tracks all successful referrals
Timestamp when the referral was created
- Default: Current timestamp
Timestamp when the referral was last updated
- Auto-updated: Updates automatically on modification
Indexes
userId- Fast lookup by userslug- Fast lookup by referral code
Relationships
The user who owns this referral
- Foreign Key:
userId→User.id - Delete Behavior: Cascade