Add member accounts, follow-based leaderboard, and dedicated Postgres

Members register via email+password (scrypt) or Google OAuth — same
signed-cookie + scrypt pattern as LokiLab (lib/auth.ts, member-password.ts,
member-auth.ts, google-oauth.ts), own AUTH_SECRET and own OAuth client,
own dedicated Postgres database (lokiloto-db on Coolify), fully isolated
from LokiLab's own DB and auth.

Leaderboard tracks who follows Loki's picks most accurately — members
star a pick from the results panel (FollowButton), resolution reuses
LokiLab's own lastDraw.won, no money or pooled play involved anywhere.
Leaderboard page renders a horizontal bar chart (recharts) plus a ranked
list.

Profile page: public nickname (required to appear on the leaderboard),
list of followed picks. Header now carries nav + a user menu (avatar
dropdown when signed in, "Connexion" button otherwise).

Dockerfile runs prisma migrate deploy at container start via
docker-entrypoint.sh, same pattern as LokiLab.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Nazim Kri
2026-10-30 09:02:26 -04:00
co-authored by Claude Sonnet 5
parent fc69d4a668
commit c3a0a7b765
36 changed files with 2419 additions and 27 deletions
+52
View File
@@ -0,0 +1,52 @@
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
/// A member account, created on email+password signup or Google sign-in —
/// same dual-path pattern as LokiLab (lib/member-password.ts / google-oauth.ts).
model User {
id String @id @default(cuid())
email String @unique
name String
avatarUrl String?
googleSub String? @unique
/// scrypt hash, format `scrypt$<salt>$<hex>`. Null when the account was
/// created via Google only.
passwordHash String?
/// Shown instead of name/email anywhere this member's activity is public
/// (leaderboard, follow counts). Must be set before a member appears
/// publicly.
publicNickname String?
/// Last country tab the member viewed, restored on next visit.
favoriteCountry String @default("CA-QC")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
follows FollowedPick[]
}
/// A member "following" one of Loki's picks for a specific upcoming draw —
/// the leaderboard is built from how many of these resolve as wins. No
/// money, no pooled play: this only records that a member said "I'm
/// tracking this one," same spirit as LokiLab's "je joue aussi" copy but
/// without a numbers payload (the pick itself lives in LokiLab's feed).
model FollowedPick {
id String @id @default(cuid())
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
/// Matches LokiLab's lottery id (e.g. "lotto-max", "q4").
lotteryId String
country String
targetDrawDate String
createdAt DateTime @default(now())
@@unique([userId, lotteryId, targetDrawDate])
@@index([userId])
@@index([lotteryId, targetDrawDate])
}