Speed Roulette Schema ERD¶
The speed_roulette Postgres schema (libs/_prisma/src/schema/speed_roulette.prisma)
contains only three tables and two enums — a deliberately minimal model that
keeps all transient game state in memory while persisting only settled results.
The speed-roulette app (apps/speed-roulette/) owns these tables exclusively.
Provable fairness uses an EOS blockchain block hash as the external entropy
source (speed_roulette.prisma:10-12). The game cycles through four states
(ACCEPTING_BETS -> WAITING_BLOCK -> ROLLING -> FINISHED) defined at
speed_roulette.prisma:54-60.
erDiagram
SpeedRouletteGame {
string id PK
datetime createdAt
datetime updatedAt
enum state
string secret
int roll
enum color
datetime endedAt
datetime eosBlockTimestamp
int eosBlockNum
string eosBlockId
}
SpeedRouletteBet {
string id PK
datetime createdAt
string gameId FK
string userId FK
string currencyId
decimal amount
enum color
boolean isSettled
}
SpeedRouletteUser {
string id PK
string username
boolean isPrivate
string avatar
int vipLevel
}
SpeedRouletteGame ||--o{ SpeedRouletteBet : "collects"
SpeedRouletteUser ||--o{ SpeedRouletteBet : "places"
Table reference¶
| Table | PK | Row count driver | Prisma line |
|---|---|---|---|
SpeedRouletteGame |
id (cuid) |
One per round, ~every 30s | speed_roulette.prisma:1 |
SpeedRouletteBet |
id (cuid) |
Multiple per game per user | speed_roulette.prisma:21 |
SpeedRouletteUser |
id (string) |
Mirrors public.user subset |
speed_roulette.prisma:42 |
Indexes¶
SpeedRouletteGame:state(Hash),createdAt(BTree) —speed_roulette.prisma:15-16.SpeedRouletteBet:gameId,(gameId, color),(gameId, userId),isSettled—speed_roulette.prisma:33-36.
Color enum¶
The SpeedRouletteGameColor enum (speed_roulette.prisma:65-72) includes RED_BAIT and
BLACK_BAIT variants — these are near-miss visual slots that resolve to the
opposite color, used for house-edge presentation.
Cross-references¶
- Settled roulette bets sync to
public.Betvia BullMQ queues in the speed-roulette app. SpeedRouletteUseris populated on first bet, copying fields frompublic.User.- Two BullMQ queues manage async work: one for bet settlement, one for game-state transitions.
- Flow doc:
docs/flows/speed-roulette.md.