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
+13 -14
View File
@@ -1,9 +1,11 @@
import { Suspense } from "react"
import { COUNTRIES, countryTheme } from "@/lib/countries"
import { getArmyFeed } from "@/lib/lokilab-feed"
import { getCurrentMember } from "@/lib/member-auth"
import { listFollowedPicks } from "@/lib/follows"
import { CountryNav, CountryNavMobile } from "@/components/country-nav"
import { LotteryResultsPanel } from "@/components/lottery-results-panel"
import { LokiMark } from "@/components/loki-mark"
import { AppHeader } from "@/components/app-header"
import { Skeleton } from "@/components/ui/skeleton"
export const instant = false
@@ -26,25 +28,17 @@ export default async function Home({
)
}
function AppHeader() {
return (
<div className="h-14 border-b border-border/60 bg-card">
<div className="mx-auto flex h-full max-w-6xl items-center gap-2 px-4 sm:px-6">
<LokiMark className="h-8 w-8 shrink-0 text-accent" />
<span className="text-base font-bold tracking-tight">LokiLoto</span>
</div>
</div>
)
}
async function HomeContent({ activeCode }: { activeCode: string }) {
const feed = await getArmyFeed()
const [feed, member] = await Promise.all([getArmyFeed(), getCurrentMember()])
const theme = countryTheme(activeCode)
const lotteries = feed.lotteries.filter((l) => l.country === activeCode)
const totalWins = lotteries.reduce((sum, l) => sum + l.lifetime.wins, 0)
const totalTracked = lotteries.reduce((sum, l) => sum + l.lifetime.picksTracked, 0)
const countryMembers = feed.army.byCountry[activeCode] ?? 0
const follows = member ? await listFollowedPicks(member.id) : []
const followedKeys = new Set(follows.map((f) => `${f.lotteryId}:${f.targetDrawDate}`))
return (
<div
style={{ "--accent": theme.accent, "--accent-soft": theme.accentSoft } as React.CSSProperties}
@@ -78,7 +72,12 @@ async function HomeContent({ activeCode }: { activeCode: string }) {
</div>
{lotteries.length > 0 ? (
<LotteryResultsPanel lotteries={lotteries} />
<LotteryResultsPanel
lotteries={lotteries}
country={activeCode}
followedKeys={followedKeys}
isAuthenticated={!!member}
/>
) : (
<div className="rounded-md border border-dashed border-border py-16 text-center text-sm text-muted-foreground">
Aucune loterie suivie pour {theme.name} pour le moment.