~/projects

Case Study

Mafia Minds

Multiplayer social-deduction platform

mafiaminds.com
  • Next.js
  • React
  • TypeScript
  • Tailwind CSS
  • PostgreSQL
  • Supabase
  • Vercel

Hidden roles only work if the server enforces them: against the UI, and against anyone who opens DevTools.

Problem

Secrets
Roles, private chat and night actions must stay hidden.
Real play
Timed phases and voting have to stay fair on any device.
Hostile clients
Hidden UI is not access control.

What shipped

Realtime multiplayer Mafia with server-enforced roles, phases and chat over Supabase.

Stack

Client
Next.js / React PWA on Vercel + Tailwind
Realtime
Supabase auth + subscriptions for state, chat and timers
Data
Relational tables with FKs, not a single game-state blob
Authz
Role membership checked in queries and API handlers

Decisions

  1. 01

    Never trust the client

    Roles and night actions validated server-side before they resolve.

  2. 02

    Chat scoped in the query

    Wrong role → no rows. Membership comes from the database.

  3. 03

    Hide existence

    Restricted channels can’t be enumerated from outside.

Hard parts

API bypass
Authorization at the data layer, not the UI.
Timers & races
Deterministic phase and vote resolution under latency.

Authorize at the data layer first. Clients are views that can be stale: never the source of truth.