Skip to main content

Database Schema

Current State Summary

ServiceCurrent implementationProduction target
IdentityPostgreSQL schema with Alembic migrationsManaged PostgreSQL
CustomerSQLite tables for invites and relationshipsManaged PostgreSQL
GameSQLite tables for invites and sessionsManaged PostgreSQL
ChatSQLite tables for conversations, messages, and auditsManaged PostgreSQL

Identity Service

The identity schema currently includes:

TablePurpose
usersUser identity, credentials, role, phone state, WHOT account type, distributor link, VIP flag
refresh_tokensRefresh-token persistence and revocation
user_login_attemptsAuthentication attempt audit trail
user_otpsOne-time password records
influencers, referrals, earnings, user_influencer_codesLegacy seed-domain tables retained in the repository but not part of the active WHOT runtime surface

Key WHOT-specific additions on users are username, account_type, distributor_id, and vip_enabled.

Customer Service

TableKey columns
invitestoken, distributor_id, distributor_alias, expires_at, redeemed_by_user_id
relationshipscustomer_id, distributor_id, customer_username

Game Service

TableKey columns
invitesid, sender_id, recipient_username, status
sessionsid, both player IDs, top card, current player, reconnect tokens, scores

Chat Service

TableKey columns
conversationsconversation ID, distributor/customer IDs, legal-hold state and reason
messagesciphertext, timestamps, expiry, delivery/read sets, participant deletion marker
auditsconversation ID, moderator ID, reason

Data Design Notes

  • Current local storage is intentionally pragmatic for evaluation and development.
  • Production readiness requires migrating customer, game, and chat persistence to managed PostgreSQL and introducing production-grade migration workflows.
  • The chat store is the most sensitive persistence area because it combines ciphertext, retention timestamps, legal hold, and moderator audit records.