Skip to content

Data Model — Prisma ERDs

Visual entity-relationship diagrams for the ebit-api database, organized by domain. Each file contains a Mermaid erDiagram, a table reference with Prisma line numbers, and cross-links to flow docs and security findings.

Schema layout

Prisma uses a split schema across three files in libs/_prisma/src/schema/ with prismaSchemaFolder + multiSchema preview features (api.prisma:3). Each file maps to a Postgres schema:

File Postgres schema Tables Owner app
api.prisma public ~50 models, 4 views, ~30 enums api, bo
blackjack.prisma blackjack 8 models, 2 enums bj
speed_roulette.prisma speed_roulette 3 models, 2 enums speed-roulette

ERDs by domain

ERD Scope Key tables
Auth & User Identity Registration, login, sessions, KYC, MFA, permissions, responsible gambling, fairness seeds User, UserSession, UserKyc, UserRole, UserFairnessSeeds
Bet & Accounting Bets, transactions, balances, deposits, withdrawals, game catalogue, tips, rakeback Bet, Transaction, UserBalance, Deposit, Withdraw, GameIdentity
Promo, Challenge & Affiliate Promo codes, deposit bonuses, challenges, leaderboards, affiliate referrals PromoCode, UserPromoCode, Challenge, Leaderboard, AffiliateCode
Admin & Platform Admin audit logs, site config, chat, support, bots, third-party integrations AdminActionLog, SiteConfig, ChatRoom, BotsCasino
Blackjack Multiplayer blackjack tables, games, hands, provably-fair seeds BlackjackTable, BlackjackGame, BlackjackBet
Speed Roulette Speed roulette rounds, bets, EOS-based provable fairness SpeedRouletteGame, SpeedRouletteBet

How to read

  • Diagrams use Mermaid erDiagram syntax — render in any Mermaid-compatible viewer (GitHub, GitLab, VS Code, Obsidian).
  • PK = primary key, FK = foreign key, UK = unique constraint.
  • Relationship notation: ||--o{ = one-to-many, ||--o| = one-to-zero-or-one, }o--|| = many-to-one.
  • The User model appears as a stub in multiple diagrams — only auth-relevant fields are in erd-auth.md; other ERDs show User with minimal fields to keep diagrams focused.

Conventions from the schema

  • @@map("snake_case") on every model/enum — Prisma model names are PascalCase, Postgres table names are snake_case.
  • @@schema("public"|"blackjack"|"speed_roulette") required on every model/enum due to the multiSchema preview feature.
  • @map("snake_case") on every field — Prisma fields are camelCase, Postgres columns are snake_case.
  • Decimal for money — all monetary amounts use Decimal (Prisma) / numeric (Postgres), never Float.
  • UUID PKs for high-write tablesBet, Transaction, Deposit, Withdraw use @default(uuid()). Low-write config tables use @default(autoincrement()).
  • Composite PKs for join tables — e.g. UserBalance(userId, currencyId), UserRole(userId, role).
  • Postgres viewsAffiliateAggregatedInfo, AffiliateStreamer, UserBalanceEvo, UserBalanceDbc, LeaderboardUserPositionView are view not model — they are read-only aggregations.