you-know

YOU KNOW

A futuristic, browser-based multiplayer colour-matching card game. Original YOU KNOW branding, a complete classic deck, solo AI, local pass-and-play, and server-authoritative online rooms.

No cloud database. This deployment intentionally does not connect to Supabase or any other external account/database service. Profiles live in browser storage; public arena data lives in the Node process. The Supabase SDK has been removed from both packages and no Supabase keys are read.


1. Quick start

Requirements

Install and run

npm run install:all
npm run dev

Open the frontend at http://localhost:5173. The backend starts alongside it at http://localhost:3001.

npm run dev uses concurrently to run both packages. Vite proxies /api and /socket.io to the backend, so the browser can use same-origin URLs during development.

Production build

npm run build
npm start

npm run build creates frontend/dist. npm start runs backend/server.js, which serves that build and the API/Socket.IO layer from a single origin on port 3001.

Tests

npm test

Runs the shared rules-engine, AI, and room-manager suites with Node’s built-in test runner.


2. What is included


3. Game rules

The shared engine in shared/game-engine.js is the single source of truth for solo, local and online play.


4. Architecture

you know/
├── frontend/
│   ├── src/
│   │   ├── components/       UI, game table, brand, layout
│   │   ├── context/          AuthContext (local-only), SoundContext
│   │   ├── game/             useLocalGame, useOnlineRoom
│   │   ├── pages/            Landing, Play, Game, Profile, Leaderboard, Info
│   │   ├── services/         api, profile, audio, socket
│   │   └── styles/           design system, game and page CSS
│   ├── public/               favicon and static assets
│   └── vite.config.js        dev proxy for /api and /socket.io
├── backend/
│   ├── game/rooms.js         authoritative room lifecycle and actions
│   ├── routes/api.js         public REST endpoints
│   ├── sockets/index.js      Socket.IO event handlers and flood guard
│   ├── lib/store.js          in-memory leaderboard and match archive
│   └── server.js             Express + Socket.IO + production static hosting
├── shared/
│   ├── game-engine.js        pure rules engine and redacted views
│   ├── constants.js          deck, colours, values, scoring
│   └── ai.js                 opponent decision-making
├── tests/                    Node test suites
└── package.json              root scripts

Client/server split


5. Environment variables

All variables are optional for local development.

Variable Used by Purpose
PORT backend API/Socket.IO port, default 3001
CLIENT_ORIGIN backend Comma-separated allowed origins for CORS. Recommended in production.
VITE_API_URL frontend Absolute REST base URL when frontend and API are on different origins. Default: same origin.
VITE_SOCKET_URL frontend Absolute Socket.IO URL when frontend and API are on different origins. Default: same origin.

Example production .env for the backend:

PORT=3001
CLIENT_ORIGIN=https://your-domain.example

Do not add Supabase URLs or keys. They are not read and no cloud client exists in this codebase.


6. REST API

Method Path Description
GET /api/health Uptime and service health
GET /api/leaderboard?range=all\|daily\|weekly&limit=25 Public leaderboard from the arena cache
GET /api/stats Public totals plus live rooms/players
POST /api/matches Best-effort update to the in-memory arena archive
GET /api/profile Returns 410; personal profiles are local-only

Match payload example:

{
  "result": "win",
  "mode": "online",
  "score": 420,
  "points": 28,
  "username": "CyanRift42",
  "avatar": "◈",
  "color": "cyan"
}

7. Socket.IO events

Client → server:

Event Payload Purpose
room:create { name, maxPlayers, targetScore, turnTimer } Create a private room
room:join { code, name } Join by room code
room:reconnect { code, token } Restore a seat after refresh/drop
room:leave — Leave/forfeit the room
room:ready { ready } Toggle readiness
room:addBot / room:removeBot { difficulty } / { botId } Host bot controls
room:start / room:rematch / room:voteRematch — Lifecycle controls
game:play { cardId, color, declareUno } Play a card; color required for wilds
game:draw / game:pass / game:uno — Draw, pass, declare UNO
game:catchUno / game:challenge { targetId } Catch missed UNO / challenge +4
game:declineChallenge — Target declines the challenge window
game:nextRound / game:forfeit — Continue match / forfeit

Server → client:

Event Purpose
session:ready Guest session acknowledgement
room:state Redacted room + game state for this viewer
room:error Validation/rate-limit errors with codes
game:fx Animation cues (deal, play, draw, wild colour, UNO, victory, etc.)

The socket layer applies an 8 KB payload ceiling and a coarse per-socket rate limit.


8. Data storage and privacy

Nothing is persisted to disk by the application, and no third-party database or auth provider is contacted. Clearing browser storage removes the local profile; restarting the backend clears rooms and arena totals.


9. Deployment

Single-origin Node service

npm run install:all
npm run build
CLIENT_ORIGIN=https://your-domain.example PORT=3001 npm start

Point your reverse proxy at http://127.0.0.1:3001. Keep WebSocket upgrade support enabled for /socket.io.

Split frontend/backend

Security notes


10. Known notes