Skip to main content

User Model

The User model is the central entity representing a Deltalytix user with authentication, preferences, and relationships to all user-owned data.

Schema Fields

id
String
required
Unique identifier for the user
  • Constraint: Primary key
  • Default: Auto-generated CUID
email
String
required
User’s email address
  • Constraint: Unique
  • Indexed: Yes (performance optimization)
  • Used for authentication and notifications
auth_user_id
String
required
External authentication provider user ID
  • Constraint: Unique
  • Links to authentication service (e.g., Auth0, Clerk)
isFirstConnection
Boolean
required
Whether this is the user’s first login
  • Default: true
  • Used to trigger onboarding flows
etpToken
String
Token for ETP (External Trading Platform) integration
  • Optional field for third-party integrations
isBeta
Boolean
required
Whether the user has beta access to new features
  • Default: false
language
String
required
User’s preferred language
  • Default: “en”
  • ISO language code (e.g., “en”, “fr”, “es”)
thorToken
String
Token for Thor integration
  • Optional field for Thor platform access

Relationships

The User model has extensive relationships with other entities:
accounts
Account[]
All trading accounts owned by the user
  • One-to-Many: One user can have multiple accounts
businesses
Business[]
All businesses created by the user
  • One-to-Many: One user can own multiple businesses
teams
Team[]
All teams created by the user
  • One-to-Many: One user can create multiple teams
teamSubscriptions
TeamSubscription[]
Team subscriptions associated with the user
  • One-to-Many: Multiple team subscriptions possible
comments
Comment[]
All comments made by the user
  • One-to-Many: Users can make multiple comments
dashboardLayout
DashboardLayout
User’s custom dashboard layout
  • One-to-One: Each user has one dashboard layout
groups
Group[]
Account groups created by the user
  • One-to-Many: Users can organize accounts into multiple groups
moods
Mood[]
Mood journal entries by the user
  • One-to-Many: Daily mood tracking entries
notifications
Notification[]
Notifications for the user
  • One-to-Many: Users receive multiple notifications
orders
Order[]
Trading orders placed by the user
  • One-to-Many: Users can place multiple orders
posts
Post[]
Feature requests, bug reports, and discussions posted by the user
  • One-to-Many: Users can create multiple posts
subscriptions
Subscription
Individual subscription for the user
  • One-to-One: Each user has at most one individual subscription
synchronizations
Synchronization[]
Account synchronization records
  • One-to-Many: Multiple sync configurations per user
tags
Tag[]
Custom tags created by the user
  • One-to-Many: Users can create multiple tags for organization
votes
Vote[]
Votes on feature requests and discussions
  • One-to-Many: Users can vote on multiple posts
businessSubscriptions
BusinessSubscription[]
Business subscriptions owned by the user
  • One-to-Many: Multiple business subscriptions possible
referral
Referral
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

id
String
required
Unique identifier for the layout
  • Constraint: Primary key
  • Default: Auto-generated UUID
userId
String
required
ID of the user who owns this layout
  • Constraint: Unique (one layout per user)
  • Foreign Key: References User.auth_user_id with cascade delete
  • Indexed: Yes
createdAt
DateTime
required
Timestamp when the layout was created
  • Default: Current timestamp
updatedAt
DateTime
required
Timestamp when the layout was last updated
  • Auto-updated: Updates automatically on modification
desktop
Json
required
Desktop layout configuration
  • Default: Empty array ”[]”
  • JSON structure defining widget positions and sizes
mobile
Json
required
Mobile layout configuration
  • Default: Empty array ”[]”
  • JSON structure defining widget positions for mobile

Indexes

  • userId - Fast lookup of layout by user

Relationships

user
User
required
The user who owns this layout
  • Foreign Key: userIdUser.auth_user_id
  • Delete Behavior: Cascade

Synchronization Model

Manages automated synchronization of trading data from external platforms.

Schema Fields

id
String
required
Unique identifier for the sync record
  • Constraint: Primary key
  • Default: Auto-generated UUID
userId
String
required
ID of the user who owns this sync
  • Foreign Key: References User.id with cascade delete
  • Indexed: Yes
service
String
required
Name of the external service
  • Indexed: Yes
  • Examples: “TopstepTrader”, “Rithmic”, “TradeStation”
accountId
String
required
External account identifier
  • Account ID on the external platform
lastSyncedAt
DateTime
required
Timestamp of the last successful sync
  • Used to determine incremental sync windows
createdAt
DateTime
required
Timestamp when the sync was created
  • Default: Current timestamp
updatedAt
DateTime
required
Timestamp when the sync was last updated
  • Auto-updated: Updates automatically on modification
token
String
OAuth or API token for the service
  • Encrypted access token
tokenExpiresAt
DateTime
Expiration time for the token
  • Used to trigger token refresh
dailySyncTime
DateTime
Scheduled time for daily automatic sync
  • Optional field for scheduled syncs

Indexes

  • userId - Fast lookup of syncs by user
  • service - Filter syncs by service type

Unique Constraints

  • Combination of userId, service, and accountId must be unique (prevents duplicate sync configurations)

Relationships

user
User
required
The user who owns this synchronization
  • Foreign Key: userIdUser.id
  • Delete Behavior: Cascade

Notification Model

Stores user notifications for important events and updates.

Schema Fields

id
String
required
Unique identifier for the notification
  • Constraint: Primary key
  • Default: Auto-generated CUID
userId
String
required
ID of the user who receives this notification
  • Foreign Key: References User.id with cascade delete
  • Indexed: Yes
title
String
required
Notification title
  • Brief summary of the notification
description
String
required
Detailed notification message
  • Full notification content
createdAt
DateTime
required
Timestamp when the notification was created
  • Default: Current timestamp
readAt
DateTime
Timestamp when the notification was read
  • null indicates unread notification

Indexes

  • userId - Fast lookup of notifications by user

Relationships

user
User
required
The user who receives this notification
  • Foreign Key: userIdUser.id
  • Delete Behavior: Cascade

Referral Model

Tracks referral program participation and referred users.

Schema Fields

id
String
required
Unique identifier for the referral record
  • Constraint: Primary key
  • Default: Auto-generated UUID
userId
String
required
ID of the user who owns this referral
  • Constraint: Unique (one referral record per user)
  • Foreign Key: References User.id with cascade delete
  • Indexed: Yes
slug
String
required
Unique referral slug/code
  • Constraint: Unique
  • Indexed: Yes
  • Used in referral URLs
referredUserIds
String[]
required
Array of user IDs who signed up via this referral
  • Default: Empty array
  • Tracks all successful referrals
createdAt
DateTime
required
Timestamp when the referral was created
  • Default: Current timestamp
updatedAt
DateTime
required
Timestamp when the referral was last updated
  • Auto-updated: Updates automatically on modification

Indexes

  • userId - Fast lookup by user
  • slug - Fast lookup by referral code

Relationships

user
User
required
The user who owns this referral
  • Foreign Key: userIdUser.id
  • Delete Behavior: Cascade

Build docs developers (and LLMs) love