# lavenir7/jev2048 architecture

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

- Interactive diagram: https://gitdiagram.com/lavenir7/jev2048
- Repository: https://github.com/lavenir7/jev2048

## Overview

Jev2048 is a browser-based two-sided 2048 match: each side can be played manually or controlled by Jev, with synchronized stepping and an automatic race mode. The browser manages controls, board presentation, and move progression; shared rules support both the UI and server-side candidate evaluation. For Jev turns, the server validates the board, prepares deterministic candidate features, obtains model judgements, combines them into a move, and returns decision and usage details. README documents status and model-list endpoints as well. The UI excerpt is partial, so unshown request and orchestration details are represented only where the server or documentation supports them.

Main entry points: [`server/index.js`](https://github.com/lavenir7/jev2048/blob/master/server/index.js) (HTTP API), [`server/jev.js`](https://github.com/lavenir7/jev2048/blob/master/server/jev.js) (Move evaluation), [`public/app.js`](https://github.com/lavenir7/jev2048/blob/master/public/app.js) (Match and boards), [`shared/engine.js`](https://github.com/lavenir7/jev2048/blob/master/shared/engine.js) (2048 rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser game"]
  node_web["Browser UI<br/>[index.html]"]
  node_app["Match and boards<br/>[app.js]"]
end

subgraph group_server["Server API"]
  node_api["HTTP API<br/>[index.js]"]
end

subgraph group_decision["Jev decision"]
  node_jevlogic["Move evaluation<br/>[jev.js]"]
end

node_player(("Player"))
node_engine["2048 rules<br/>[engine.js]"]
node_typesafe{{"TypeSafe service"}}
node_models["Model catalogue"]

node_player -->|"uses"| node_web
node_web -->|"hosts UI"| node_app
node_app -->|"applies rules"| node_engine
node_app -->|"requests status, models, moves"| node_api
node_api -->|"validates board"| node_engine
node_api -->|"requests decision"| node_jevlogic
node_jevlogic -->|"computes candidates"| node_engine
node_jevlogic -->|"requests judgement"| node_typesafe
node_jevlogic -->|"lists models"| node_models
node_api -->|"returns API data"| node_app
node_typesafe -->|"returns judgement"| node_jevlogic
node_models -->|"returns model list"| node_api

click node_web "https://github.com/lavenir7/jev2048/blob/master/public/index.html"
click node_app "https://github.com/lavenir7/jev2048/blob/master/public/app.js"
click node_engine "https://github.com/lavenir7/jev2048/blob/master/shared/engine.js"
click node_api "https://github.com/lavenir7/jev2048/blob/master/server/index.js"
click node_jevlogic "https://github.com/lavenir7/jev2048/blob/master/server/jev.js"

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_web,node_app toneBlue
class node_api toneAmber
class node_jevlogic toneMint
class node_player,node_typesafe,node_models toneIndigo
class node_engine toneTeal
```

## Components

### Browser game

- [Browser UI](https://github.com/lavenir7/jev2048/blob/master/public/index.html): `public/index.html`
- [Match and boards](https://github.com/lavenir7/jev2048/blob/master/public/app.js): `public/app.js`

### Server API

- [HTTP API](https://github.com/lavenir7/jev2048/blob/master/server/index.js): `server/index.js`

### Jev decision

- [Move evaluation](https://github.com/lavenir7/jev2048/blob/master/server/jev.js): `server/jev.js`

### Other components

- **Player**
- [2048 rules](https://github.com/lavenir7/jev2048/blob/master/shared/engine.js): `shared/engine.js`
- **TypeSafe service**
- **Model catalogue**

## Connections

- Player → Browser UI: uses
- Browser UI → Match and boards: hosts UI
- Match and boards → 2048 rules: applies rules
- Match and boards → HTTP API: requests status, models, moves
- HTTP API → 2048 rules: validates board
- HTTP API → Move evaluation: requests decision
- Move evaluation → 2048 rules: computes candidates
- Move evaluation → TypeSafe service: requests judgement
- Move evaluation → Model catalogue: lists models
- HTTP API → Match and boards: returns API data
- TypeSafe service → Move evaluation: returns judgement
- Model catalogue → HTTP API: returns model list
