# xanetic/dota-lastpick architecture

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

- Interactive diagram: https://gitdiagram.com/xanetic/dota-lastpick
- Repository: https://github.com/xanetic/dota-lastpick

## Overview

Guess the Last Pick is a Dota 2 draft-guessing game: players inspect a professional match with its final pick hidden, use optional hints, and choose a hero. Casual play runs in the browser; the backend adds ranked accounts, leaderboards, build guessing, and multiplayer. Supporting data pipelines collect match and player statistics and derive draft signals used by the reasoning engine. The main workflow and product capabilities are documented, but frontend source excerpts were not provided, so internal UI-to-data wiring is not asserted.

Main entry points: [`server/app.py`](https://github.com/xanetic/dota-lastpick/blob/main/server/app.py) (Backend API), [`server/analyze.py`](https://github.com/xanetic/dota-lastpick/blob/main/server/analyze.py) (Draft analyzer), [`data/hero_attributes.json`](https://github.com/xanetic/dota-lastpick/blob/main/data/hero_attributes.json) (Draft signal tables), [`attributes_bootstrap.py`](https://github.com/xanetic/dota-lastpick/blob/main/attributes_bootstrap.py) (Hero attributes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_play["Browser game"]
  node_game_ui["Game interface<br/>[app.js]"]
  node_game_api["Game API client<br/>[api.js]"]
  node_locale["Localization<br/>[i18n.js]"]
end

subgraph group_backend["Ranked and multiplayer"]
  node_backend_api["Backend API<br/>[app.py]"]
  node_account_store[("Account database<br/>[game.db]")]
end

subgraph group_reasoning["Draft reasoning"]
  node_analyzer["Draft analyzer<br/>[analyze.py]"]
end

subgraph group_data["Game data"]
  node_match_data["Match and hero data<br/>[matches.json]"]
  node_build_data["Build and item data<br/>[builds.json]"]
  node_engine_tables["Draft signal tables"]
  node_player_tables["Player and role data<br/>[players.json]"]
end

subgraph group_pipelines["Data pipelines"]
  node_match_fetch["Match collection<br/>[fetch_data.py]"]
  node_corpus_fetch["Draft corpus collection<br/>[fetch_explorer.py]"]
  node_attribute_build["Hero attributes"]
  node_position_build["Player positions"]
  node_interaction_build["Draft interactions"]
  node_build_collect["Build collection<br/>[build_builds.py]"]
end

node_player(("Player"))
node_opendota(("OpenDota"))

node_player -->|"plays"| node_game_ui
node_player -.->|"uses ranked features"| node_backend_api
node_game_ui -.->|"uses API client"| node_game_api
node_backend_api -->|"analyzes drafts"| node_analyzer
node_backend_api -->|"reads users"| node_account_store
node_match_fetch -->|"fetches matches"| node_opendota
node_corpus_fetch -->|"queries drafts"| node_opendota
node_attribute_build -->|"fetches statistics"| node_opendota
node_position_build -->|"queries player data"| node_opendota
node_interaction_build -->|"reads corpus"| node_corpus_fetch
node_build_collect -->|"reads matches"| node_match_data
node_build_collect -->|"queries inventories"| node_opendota
node_attribute_build -->|"writes attributes"| node_engine_tables
node_position_build -->|"writes player data"| node_player_tables
node_interaction_build -->|"writes signals"| node_engine_tables
node_analyzer -.->|"uses draft signals"| node_engine_tables
node_analyzer -.->|"uses player roles"| node_player_tables

click node_game_ui "https://github.com/xanetic/dota-lastpick/blob/main/app.js"
click node_game_api "https://github.com/xanetic/dota-lastpick/blob/main/api.js"
click node_locale "https://github.com/xanetic/dota-lastpick/blob/main/i18n.js"
click node_backend_api "https://github.com/xanetic/dota-lastpick/blob/main/server/app.py"
click node_account_store "https://github.com/xanetic/dota-lastpick/blob/main/data/game.db"
click node_analyzer "https://github.com/xanetic/dota-lastpick/blob/main/server/analyze.py"
click node_match_data "https://github.com/xanetic/dota-lastpick/blob/main/data/matches.json"
click node_build_data "https://github.com/xanetic/dota-lastpick/blob/main/data/builds.json"
click node_engine_tables "https://github.com/xanetic/dota-lastpick/blob/main/data/hero_attributes.json"
click node_player_tables "https://github.com/xanetic/dota-lastpick/blob/main/data/players.json"
click node_match_fetch "https://github.com/xanetic/dota-lastpick/blob/main/fetch_data.py"
click node_corpus_fetch "https://github.com/xanetic/dota-lastpick/blob/main/fetch_explorer.py"
click node_attribute_build "https://github.com/xanetic/dota-lastpick/blob/main/attributes_bootstrap.py"
click node_position_build "https://github.com/xanetic/dota-lastpick/blob/main/build_playerstats.py"
click node_interaction_build "https://github.com/xanetic/dota-lastpick/blob/main/build_interactions.py"
click node_build_collect "https://github.com/xanetic/dota-lastpick/blob/main/build_builds.py"

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_game_ui,node_game_api,node_locale toneBlue
class node_backend_api,node_account_store toneAmber
class node_analyzer toneMint
class node_match_data,node_build_data,node_engine_tables,node_player_tables toneRose
class node_match_fetch,node_corpus_fetch,node_attribute_build,node_position_build,node_interaction_build,node_build_collect,node_player,node_opendota toneIndigo
```

## Components

### Browser game

- [Game interface](https://github.com/xanetic/dota-lastpick/blob/main/app.js): `app.js`
- [Game API client](https://github.com/xanetic/dota-lastpick/blob/main/api.js): `api.js`
- [Localization](https://github.com/xanetic/dota-lastpick/blob/main/i18n.js): `i18n.js`

### Ranked and multiplayer

- [Backend API](https://github.com/xanetic/dota-lastpick/blob/main/server/app.py): `server/app.py`
- [Account database](https://github.com/xanetic/dota-lastpick/blob/main/data/game.db): `data/game.db`

### Draft reasoning

- [Draft analyzer](https://github.com/xanetic/dota-lastpick/blob/main/server/analyze.py): `server/analyze.py`

### Game data

- [Match and hero data](https://github.com/xanetic/dota-lastpick/blob/main/data/matches.json): `data/matches.json`
- [Build and item data](https://github.com/xanetic/dota-lastpick/blob/main/data/builds.json): `data/builds.json`
- [Draft signal tables](https://github.com/xanetic/dota-lastpick/blob/main/data/hero_attributes.json): `data/hero_attributes.json`
- [Player and role data](https://github.com/xanetic/dota-lastpick/blob/main/data/players.json): `data/players.json`

### Data pipelines

- [Match collection](https://github.com/xanetic/dota-lastpick/blob/main/fetch_data.py): `fetch_data.py`
- [Draft corpus collection](https://github.com/xanetic/dota-lastpick/blob/main/fetch_explorer.py): `fetch_explorer.py`
- [Hero attributes](https://github.com/xanetic/dota-lastpick/blob/main/attributes_bootstrap.py): `attributes_bootstrap.py`
- [Player positions](https://github.com/xanetic/dota-lastpick/blob/main/build_playerstats.py): `build_playerstats.py`
- [Draft interactions](https://github.com/xanetic/dota-lastpick/blob/main/build_interactions.py): `build_interactions.py`
- [Build collection](https://github.com/xanetic/dota-lastpick/blob/main/build_builds.py): `build_builds.py`

### Other components

- **Player**
- **OpenDota**

## Connections

- Player → Game interface: plays (evidence: `README.md`)
- Player → Backend API: uses ranked features
- Game interface → Game API client: uses API client
- Backend API → Draft analyzer: analyzes drafts (evidence: `server/app.py`)
- Backend API → Account database: reads users (evidence: `server/app.py`)
- Match collection → OpenDota: fetches matches (evidence: `fetch_data.py`)
- Draft corpus collection → OpenDota: queries drafts (evidence: `fetch_explorer.py`)
- Hero attributes → OpenDota: fetches statistics (evidence: `attributes_bootstrap.py`)
- Player positions → OpenDota: queries player data (evidence: `build_playerstats.py`)
- Draft interactions → Draft corpus collection: reads corpus (evidence: `build_interactions.py`)
- Build collection → Match and hero data: reads matches (evidence: `build_builds.py`)
- Build collection → OpenDota: queries inventories (evidence: `build_builds.py`)
- Hero attributes → Draft signal tables: writes attributes (evidence: `attributes_bootstrap.py`)
- Player positions → Player and role data: writes player data (evidence: `build_playerstats.py`)
- Draft interactions → Draft signal tables: writes signals (evidence: `build_interactions.py`)
- Draft analyzer → Draft signal tables: uses draft signals
- Draft analyzer → Player and role data: uses player roles
