# hussainanjar/play-with-jev architecture

> Architecture diagram of the GitHub repository hussainanjar/play-with-jev, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hussainanjar/play-with-jev
- Repository: https://github.com/hussainanjar/play-with-jev

## Overview

Play with Jev is a browser arcade for Heist, Chess, and Minesweeper. Players enter through the arcade, play locally in each game interface, and—where applicable—send moves or visible board clues to server routes that validate state, apply game rules, and request Jev’s choice. Heist and Chess use signed server-returned sessions; Minesweeper keeps its field in browser memory and asks the server only for optional hints. The README documents keyboard/touch play, probabilities, chess resume/export, and game rules; unsampled routes and components are represented only where that documentation and the tree support them.

Main entry points: [`src/app/chess/chess-game.tsx`](https://github.com/hussainanjar/play-with-jev/blob/main/src/app/chess/chess-game.tsx) (Chess interface), [`src/app/page.tsx`](https://github.com/hussainanjar/play-with-jev/blob/main/src/app/page.tsx) (Arcade homepage), [`src/app/api/turn/route.ts`](https://github.com/hussainanjar/play-with-jev/blob/main/src/app/api/turn/route.ts) (Heist turn), [`src/app/api/chess/move/route.ts`](https://github.com/hussainanjar/play-with-jev/blob/main/src/app/api/chess/move/route.ts) (Chess move)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_arcade["Arcade entry"]
  node_home["Arcade homepage<br/>[page.tsx]"]
end

subgraph group_games["Game interfaces"]
  node_heist_ui["Heist interface<br/>[heist-game.tsx]"]
  node_chess_ui["Chess interface<br/>[chess-game.tsx]"]
  node_mine_ui["Minesweeper interface"]
end

subgraph group_server["Game services"]
  node_heist_start["Start Heist<br/>[route.ts]"]
  node_heist_turn["Heist turn<br/>[route.ts]"]
  node_chess_start["Start Chess<br/>[route.ts]"]
  node_chess_move["Chess move<br/>[route.ts]"]
  node_mine_hint["Minesweeper hint<br/>[route.ts]"]
end

subgraph group_core["Rules and sessions"]
  node_heist_rules["Heist rules<br/>[game.ts]"]
  node_chess_rules["Chess rules<br/>[chess-game.ts]"]
  node_mine_rules["Minesweeper rules<br/>[minesweeper.ts]"]
  node_session["Signed sessions<br/>[session.ts]"]
  node_chess_service["Chess evaluation<br/>[chess-server.ts]"]
end

subgraph group_external["External services"]
  node_jev{{"TypeSafe Jev"}}
  node_gateway{{"Vercel AI Gateway"}}
  node_browser_storage[("Browser storage")]
end

node_player(("Player"))

node_player -->|"opens arcade"| node_home
node_home -->|"opens Heist"| node_heist_ui
node_home -->|"opens Chess"| node_chess_ui
node_home -->|"opens Minesweeper"| node_mine_ui
node_player -->|"plays"| node_heist_ui
node_player -->|"plays"| node_chess_ui
node_player -->|"plays"| node_mine_ui
node_heist_ui -->|"requests session"| node_heist_start
node_heist_ui -->|"sends action"| node_heist_turn
node_heist_start -->|"creates game"| node_heist_rules
node_heist_turn -->|"verifies and signs"| node_session
node_heist_turn -->|"applies turns"| node_heist_rules
node_heist_turn -->|"evaluates guard move"| node_gateway
node_gateway -->|"requests choice"| node_jev
node_chess_ui -->|"starts game"| node_chess_start
node_chess_ui -->|"sends move"| node_chess_move
node_chess_ui -->|"saves and resumes"| node_browser_storage
node_chess_start -->|"chooses opening"| node_chess_service
node_chess_move -->|"requests reply"| node_chess_service
node_chess_move -->|"replays and checks"| node_chess_rules
node_chess_start -->|"signs session"| node_session
node_chess_move -->|"signs and validates session"| node_chess_service
node_chess_service -->|"evaluates legal moves"| node_gateway
node_gateway -->|"requests choice"| node_jev
node_mine_ui -->|"runs board rules"| node_mine_rules
node_mine_ui -->|"sends visible clues"| node_mine_hint
node_mine_hint -->|"builds clue options"| node_mine_rules
node_mine_hint -->|"evaluates hint"| node_gateway
node_gateway -->|"requests choice"| node_jev
node_heist_start -->|"signs session"| node_session

click node_home "https://github.com/hussainanjar/play-with-jev/blob/main/src/app/page.tsx"
click node_heist_ui "https://github.com/hussainanjar/play-with-jev/blob/main/src/app/heist/heist-game.tsx"
click node_chess_ui "https://github.com/hussainanjar/play-with-jev/blob/main/src/app/chess/chess-game.tsx"
click node_mine_ui "https://github.com/hussainanjar/play-with-jev/blob/main/src/app/minesweeper/minesweeper-game.tsx"
click node_heist_start "https://github.com/hussainanjar/play-with-jev/blob/main/src/app/api/start/route.ts"
click node_heist_turn "https://github.com/hussainanjar/play-with-jev/blob/main/src/app/api/turn/route.ts"
click node_chess_start "https://github.com/hussainanjar/play-with-jev/blob/main/src/app/api/chess/start/route.ts"
click node_chess_move "https://github.com/hussainanjar/play-with-jev/blob/main/src/app/api/chess/move/route.ts"
click node_mine_hint "https://github.com/hussainanjar/play-with-jev/blob/main/src/app/api/minesweeper/hint/route.ts"
click node_heist_rules "https://github.com/hussainanjar/play-with-jev/blob/main/src/lib/game.ts"
click node_chess_rules "https://github.com/hussainanjar/play-with-jev/blob/main/src/lib/chess-game.ts"
click node_mine_rules "https://github.com/hussainanjar/play-with-jev/blob/main/src/lib/minesweeper.ts"
click node_session "https://github.com/hussainanjar/play-with-jev/blob/main/src/lib/session.ts"
click node_chess_service "https://github.com/hussainanjar/play-with-jev/blob/main/src/lib/chess-server.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 toneBlue
class node_heist_ui,node_chess_ui,node_mine_ui toneAmber
class node_heist_start,node_heist_turn,node_chess_start,node_chess_move,node_mine_hint toneMint
class node_heist_rules,node_chess_rules,node_mine_rules,node_session,node_chess_service toneRose
class node_jev,node_gateway,node_browser_storage,node_player toneIndigo
```

## Components

### Arcade entry

- [Arcade homepage](https://github.com/hussainanjar/play-with-jev/blob/main/src/app/page.tsx): `src/app/page.tsx`

### Game interfaces

- [Heist interface](https://github.com/hussainanjar/play-with-jev/blob/main/src/app/heist/heist-game.tsx): `src/app/heist/heist-game.tsx`
- [Chess interface](https://github.com/hussainanjar/play-with-jev/blob/main/src/app/chess/chess-game.tsx): `src/app/chess/chess-game.tsx`
- [Minesweeper interface](https://github.com/hussainanjar/play-with-jev/blob/main/src/app/minesweeper/minesweeper-game.tsx): `src/app/minesweeper/minesweeper-game.tsx`

### Game services

- [Start Heist](https://github.com/hussainanjar/play-with-jev/blob/main/src/app/api/start/route.ts): `src/app/api/start/route.ts`
- [Heist turn](https://github.com/hussainanjar/play-with-jev/blob/main/src/app/api/turn/route.ts): `src/app/api/turn/route.ts`
- [Start Chess](https://github.com/hussainanjar/play-with-jev/blob/main/src/app/api/chess/start/route.ts): `src/app/api/chess/start/route.ts`
- [Chess move](https://github.com/hussainanjar/play-with-jev/blob/main/src/app/api/chess/move/route.ts): `src/app/api/chess/move/route.ts`
- [Minesweeper hint](https://github.com/hussainanjar/play-with-jev/blob/main/src/app/api/minesweeper/hint/route.ts): `src/app/api/minesweeper/hint/route.ts`

### Rules and sessions

- [Heist rules](https://github.com/hussainanjar/play-with-jev/blob/main/src/lib/game.ts): `src/lib/game.ts`
- [Chess rules](https://github.com/hussainanjar/play-with-jev/blob/main/src/lib/chess-game.ts): `src/lib/chess-game.ts`
- [Minesweeper rules](https://github.com/hussainanjar/play-with-jev/blob/main/src/lib/minesweeper.ts): `src/lib/minesweeper.ts`
- [Signed sessions](https://github.com/hussainanjar/play-with-jev/blob/main/src/lib/session.ts): `src/lib/session.ts`
- [Chess evaluation](https://github.com/hussainanjar/play-with-jev/blob/main/src/lib/chess-server.ts): `src/lib/chess-server.ts`

### External services

- **TypeSafe Jev**
- **Vercel AI Gateway**
- **Browser storage**

### Other components

- **Player**

## Connections

- Player → Arcade homepage: opens arcade
- Arcade homepage → Heist interface: opens Heist
- Arcade homepage → Chess interface: opens Chess
- Arcade homepage → Minesweeper interface: opens Minesweeper
- Player → Heist interface: plays
- Player → Chess interface: plays
- Player → Minesweeper interface: plays
- Heist interface → Start Heist: requests session
- Heist interface → Heist turn: sends action
- Start Heist → Heist rules: creates game
- Heist turn → Signed sessions: verifies and signs
- Heist turn → Heist rules: applies turns
- Heist turn → Vercel AI Gateway: evaluates guard move
- Vercel AI Gateway → TypeSafe Jev: requests choice
- Chess interface → Start Chess: starts game
- Chess interface → Chess move: sends move
- Chess interface → Browser storage: saves and resumes
- Start Chess → Chess evaluation: chooses opening
- Chess move → Chess evaluation: requests reply
- Chess move → Chess rules: replays and checks
- Start Chess → Signed sessions: signs session
- Chess move → Chess evaluation: signs and validates session
- Chess evaluation → Vercel AI Gateway: evaluates legal moves
- Vercel AI Gateway → TypeSafe Jev: requests choice
- Minesweeper interface → Minesweeper rules: runs board rules
- Minesweeper interface → Minesweeper hint: sends visible clues
- Minesweeper hint → Minesweeper rules: builds clue options
- Minesweeper hint → Vercel AI Gateway: evaluates hint
- Vercel AI Gateway → TypeSafe Jev: requests choice
- Start Heist → Signed sessions: signs session
