PAM architecture β their domain
15 minutes of fluent iGaming-architecture talk and you're ahead of 90% of candidates.
1 Β· What is a PAM?
PAM = Player Account Management. The operational core of any iGaming platform:
- Accounts, sessions, login
- KYC tiers (light verification β full verification)
- Wallet (deposits, withdrawals, balance)
- Limits (daily/weekly deposit caps, self-exclusion)
- Bonus engine
- Compliance / audit trail
Sportsbook + casino + payment providers all plug into the PAM, not the other way round.
2 Β· The system diagram
ββββββββββββββββββββββββββββββββββββββ
β FRONTEND β
β Next.js Β· per-tenant theme Β· WS β
ββββββββββββββββ¬ββββββββββββββββββββββ
β
ββββββββββββββββΌβββββββββββββββ
β BFF (Next API / Nest) β β auth, aggregation, WS hub
ββββββββββββββββ¬βββββββββββββββ
β
ββββββββββββββββββββΌββββββββββββββββββββββ
βΌ βΌ βΌ
βββββββββββ ββββββββββββ βββββββββββββββ
β PAM βββββββΊ β Wallet β βββββββΊ β Sportsbook β
β accountsβ β ledger β β + casino β
β KYC β β idempotentβ β vendor β
ββββββ¬βββββ βββββββ²βββββ βββββββββββββββ
β β
βΌ β
βββββββββββ βββββ΄βββββ
βcomplianceβ βpayment β
β + audit β β PSPs β
βββββββββββ ββββββββββ3 Β· Whitelabel multi-tenancy β switch operator live
Click each operator below. Watch the brand color, currency, and feature visibility change. Notice how βLive Bettingβ is greyed out for the UK operator β that's a feature flag, not different code.
// 1. Middleware resolves tenant from host
export function middleware(req: NextRequest) {
const host = req.headers.get("host"); // operator-a.com
const tenant = resolveTenant(host);
req.headers.set("x-tenant", tenant.id);
}
// 2. Theme loaded server-side, injected as CSS vars
async function RootLayout({ children, params: { tenant } }) {
const theme = await getTenantTheme(tenant);
return (
<html style={{
"--brand-primary": theme.primary,
"--brand-radius": theme.radius,
} as CSSProperties}>{children}</html>
);
}
// 3. Flags evaluated server-side per tenant + region
const flags = await flagsClient.evaluate({ tenant, user, country });
// flags = { liveBetting: false, casino: true }
{flags.liveBetting && <LiveBettingTab />}4 Β· Money operations β idempotency
Step through it line-by-line. Watch the BAD wallet hit $200 (overcharged), watch the GOOD wallet stay at $150 because the server stores the idempotency key and returns the cached result on retry:
6 Β· Cache stampede β the senior trap
This is the question that separates seniors from mid-levels. βYou have Redis caching profiles. The cache for a popular profile expires. 1000 users hit it within the same second. What happens?β
Step through the BAD path β no lock, every request hits the DB:
Now the senior fix β stale-while-revalidate plus a Redis SETNX lock so only ONE request rebuilds:
5 Β· The non-negotiables for money
π Smart questions to ask Wednesday
- βSingle multi-tenant codebase or per-operator deployments?β
- βFeature flags β build-time, edge middleware, or runtime client?β
- βWallet ops β UUID idempotency from the client, or BFF dedup?β
- βWhat's the SSR / RSC split for the game lobby?β
- βTanStack Query, SWR, or custom cache?β
- βRUM provider? How do you alert on INP regressions?β
- βWebSockets vs SSE for real-time? Multiplexed or per-feature?β
- βBFF β Next API routes, Nest service, or GraphQL gateway?β