# farhansklcric/bluff-game architecture

> Architecture diagram of the GitHub repository farhansklcric/bluff-game, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/farhansklcric/bluff-game
- Repository: https://github.com/farhansklcric/bluff-game

## Overview

This is a multiplayer bluff card game: players enter or create a room, join a live game, play turns and challenge claims, with optional voice chat. The sampled server code shows room membership, game state, turn handling, bluff resolution, and voice signaling; the client includes room and game views plus WebRTC voice handling. The home-to-room navigation and several client event handlers were not shown, so those connections are left unverified rather than asserted.

Main entry points: [`server/index.js`](https://github.com/farhansklcric/bluff-game/blob/main/server/index.js) (Socket server), [`src/hooks/useVoiceChat.ts`](https://github.com/farhansklcric/bluff-game/blob/main/src/hooks/useVoiceChat.ts) (Voice hook), [`src/app/room/page.tsx`](https://github.com/farhansklcric/bluff-game/blob/main/src/app/room/page.tsx) (Room lobby), [`src/app/lib/socket.ts`](https://github.com/farhansklcric/bluff-game/blob/main/src/app/lib/socket.ts) (Socket client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Game client"]
  node_home["Entry page<br/>[page.tsx]"]
  node_room["Room lobby<br/>[page.tsx]"]
  node_board["Game board<br/>[gameboard.tsx]"]
  node_socketclient["Socket client<br/>[socket.ts]"]
end

subgraph group_server["Realtime game server"]
  node_server["Socket server<br/>[index.js]"]
  node_roomstate[("Room state<br/>[index.js]")]
  node_gameplay["Game rules<br/>[index.js]"]
  node_turns["Turns and rankings<br/>[index.js]"]
end

subgraph group_voice["Voice chat"]
  node_voicehook["Voice hook<br/>[useVoiceChat.ts]"]
  node_webrtc["Peer audio<br/>[useVoiceChat.ts]"]
end

node_player(("Player"))

node_player -->|"enters game"| node_home
node_home -.->|"navigates to"| node_room
node_room -->|"renders"| node_board
node_room -.->|"uses socket"| node_socketclient
node_board -->|"uses hook"| node_voicehook
node_voicehook -->|"manages peers"| node_webrtc
node_voicehook -->|"signals peers"| node_socketclient
node_socketclient -.->|"exchanges events"| node_server
node_server -->|"updates rooms"| node_roomstate
node_server -->|"handles play"| node_gameplay
node_server -->|"advances turns"| node_turns
node_server -.->|"relays voice signals"| node_voicehook

click node_home "https://github.com/farhansklcric/bluff-game/blob/main/src/app/page.tsx"
click node_room "https://github.com/farhansklcric/bluff-game/blob/main/src/app/room/page.tsx"
click node_board "https://github.com/farhansklcric/bluff-game/blob/main/src/components/gameboard.tsx"
click node_socketclient "https://github.com/farhansklcric/bluff-game/blob/main/src/app/lib/socket.ts"
click node_server "https://github.com/farhansklcric/bluff-game/blob/main/server/index.js"
click node_roomstate "https://github.com/farhansklcric/bluff-game/blob/main/server/index.js"
click node_gameplay "https://github.com/farhansklcric/bluff-game/blob/main/server/index.js"
click node_turns "https://github.com/farhansklcric/bluff-game/blob/main/server/index.js"
click node_voicehook "https://github.com/farhansklcric/bluff-game/blob/main/src/hooks/useVoiceChat.ts"
click node_webrtc "https://github.com/farhansklcric/bluff-game/blob/main/src/hooks/useVoiceChat.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_home,node_room,node_board,node_socketclient toneBlue
class node_server,node_roomstate,node_gameplay,node_turns toneAmber
class node_voicehook,node_webrtc toneMint
class node_player toneIndigo
```

## Components

### Game client

- [Entry page](https://github.com/farhansklcric/bluff-game/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Room lobby](https://github.com/farhansklcric/bluff-game/blob/main/src/app/room/page.tsx): `src/app/room/page.tsx`
- [Game board](https://github.com/farhansklcric/bluff-game/blob/main/src/components/gameboard.tsx): `src/components/gameboard.tsx`
- [Socket client](https://github.com/farhansklcric/bluff-game/blob/main/src/app/lib/socket.ts): `src/app/lib/socket.ts`

### Realtime game server

- [Socket server](https://github.com/farhansklcric/bluff-game/blob/main/server/index.js): `server/index.js`
- [Room state](https://github.com/farhansklcric/bluff-game/blob/main/server/index.js): `server/index.js`
- [Game rules](https://github.com/farhansklcric/bluff-game/blob/main/server/index.js): `server/index.js`
- [Turns and rankings](https://github.com/farhansklcric/bluff-game/blob/main/server/index.js): `server/index.js`

### Voice chat

- [Voice hook](https://github.com/farhansklcric/bluff-game/blob/main/src/hooks/useVoiceChat.ts): `src/hooks/useVoiceChat.ts`
- [Peer audio](https://github.com/farhansklcric/bluff-game/blob/main/src/hooks/useVoiceChat.ts): `src/hooks/useVoiceChat.ts`

### Other components

- **Player**

## Connections

- Player → Entry page: enters game
- Entry page → Room lobby: navigates to
- Room lobby → Game board: renders (evidence: `src/app/room/page.tsx`)
- Room lobby → Socket client: uses socket (evidence: `src/app/room/page.tsx`)
- Game board → Voice hook: uses hook (evidence: `src/components/gameboard.tsx`)
- Voice hook → Peer audio: manages peers (evidence: `src/hooks/useVoiceChat.ts`)
- Voice hook → Socket client: signals peers (evidence: `src/hooks/useVoiceChat.ts`)
- Socket client → Socket server: exchanges events
- Socket server → Room state: updates rooms (evidence: `server/index.js`)
- Socket server → Game rules: handles play (evidence: `server/index.js`)
- Socket server → Turns and rankings: advances turns (evidence: `server/index.js`)
- Socket server → Voice hook: relays voice signals
