# r41ngee/dota-hero-grid architecture

> Architecture diagram of the GitHub repository r41ngee/dota-hero-grid, 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/r41ngee/dota-hero-grid
- Repository: https://github.com/r41ngee/dota-hero-grid

## Overview

This workspace provides a Rust library for building and serializing Dota 2 hero-grid configurations, plus a CLI that converts an image into a grid and writes or adds it to a JSON config. The main workflow is image input → hero-color matching → grid construction → JSON output. The library also exposes a recursive geometry layout feature; the CLI has a development-only portrait-generation command. The excerpts show these runtime paths, but provide no README capability descriptions, so unsampled behavior is not inferred.

Main entry points: [`crates/dotagrid-cli/src/main.rs`](https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dotagrid-cli/src/main.rs) (CLI workflow), [`crates/dota-hero-grid/src/models.rs`](https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dota-hero-grid/src/models.rs) (Grid models), [`crates/dota-hero-grid/src/serials.rs`](https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dota-hero-grid/src/serials.rs) (JSON serialization), [`crates/dotagrid-cli/src/portraits.toml`](https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dotagrid-cli/src/portraits.toml) (Portrait colors)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflows"]
  node_main["CLI workflow<br/>[main.rs]"]
  node_commands["CLI commands<br/>[cli.rs]"]
  node_mapping["Picture mapping<br/>[main.rs]"]
  node_portraitdata["Portrait colors<br/>[portraits.toml]"]
  node_devportrait["Portrait pixels<br/>[mod.rs]"]
end

subgraph group_domain["Grid domain"]
  node_models["Grid models<br/>[models.rs]"]
end

subgraph group_layout["Geometry and serialization"]
  node_geometry["Tree layout<br/>[geometry.rs]"]
  node_serialization["JSON serialization<br/>[serials.rs]"]
end

node_user(("CLI user"))
node_image["Input image"]
node_ffmpeg["ffmpeg"]
node_config["JSON config"]

node_user -->|"invokes"| node_main
node_main -->|"parses"| node_commands
node_user -->|"provides"| node_image
node_main -->|"processes"| node_mapping
node_mapping -->|"reads"| node_image
node_mapping -->|"matches colors"| node_portraitdata
node_main -->|"builds grid"| node_models
node_main -->|"serializes"| node_serialization
node_serialization -->|"converts"| node_models
node_main -->|"writes"| node_config
node_main -->|"reads existing"| node_config
node_main -->|"stores pixels"| node_devportrait
node_main -->|"extracts frames"| node_ffmpeg
node_main -->|"writes colors"| node_portraitdata
node_geometry -->|"lays out categories"| node_models

click node_main "https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dotagrid-cli/src/main.rs"
click node_commands "https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dotagrid-cli/src/cli.rs"
click node_mapping "https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dotagrid-cli/src/main.rs"
click node_portraitdata "https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dotagrid-cli/src/portraits.toml"
click node_devportrait "https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dotagrid-cli/src/dev/mod.rs"
click node_models "https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dota-hero-grid/src/models.rs"
click node_geometry "https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dota-hero-grid/src/geometry.rs"
click node_serialization "https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dota-hero-grid/src/serials.rs"

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_main,node_commands,node_mapping,node_portraitdata,node_devportrait,node_user toneBlue
class node_models toneAmber
class node_geometry,node_serialization toneMint
class node_image,node_ffmpeg,node_config toneIndigo
```

## Components

### CLI workflows

- [CLI workflow](https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dotagrid-cli/src/main.rs): `crates/dotagrid-cli/src/main.rs`
- [CLI commands](https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dotagrid-cli/src/cli.rs): `crates/dotagrid-cli/src/cli.rs`
- [Picture mapping](https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dotagrid-cli/src/main.rs): `crates/dotagrid-cli/src/main.rs`
- [Portrait colors](https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dotagrid-cli/src/portraits.toml): `crates/dotagrid-cli/src/portraits.toml`
- [Portrait pixels](https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dotagrid-cli/src/dev/mod.rs): `crates/dotagrid-cli/src/dev/mod.rs`

### Grid domain

- [Grid models](https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dota-hero-grid/src/models.rs): `crates/dota-hero-grid/src/models.rs`

### Geometry and serialization

- [Tree layout](https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dota-hero-grid/src/geometry.rs): `crates/dota-hero-grid/src/geometry.rs`
- [JSON serialization](https://github.com/r41ngee/dota-hero-grid/blob/main/crates/dota-hero-grid/src/serials.rs): `crates/dota-hero-grid/src/serials.rs`

### Other components

- **CLI user**
- **Input image**
- **ffmpeg**
- **JSON config**

## Connections

- CLI user → CLI workflow: invokes (evidence: `crates/dotagrid-cli/src/main.rs`)
- CLI workflow → CLI commands: parses (evidence: `crates/dotagrid-cli/src/main.rs`)
- CLI user → Input image: provides
- CLI workflow → Picture mapping: processes (evidence: `crates/dotagrid-cli/src/main.rs`)
- Picture mapping → Input image: reads (evidence: `crates/dotagrid-cli/src/main.rs`)
- Picture mapping → Portrait colors: matches colors (evidence: `crates/dotagrid-cli/src/main.rs`)
- CLI workflow → Grid models: builds grid (evidence: `crates/dotagrid-cli/src/main.rs`)
- CLI workflow → JSON serialization: serializes (evidence: `crates/dotagrid-cli/src/main.rs`)
- JSON serialization → Grid models: converts (evidence: `crates/dota-hero-grid/src/serials.rs`)
- CLI workflow → JSON config: writes (evidence: `crates/dotagrid-cli/src/main.rs`)
- CLI workflow → JSON config: reads existing (evidence: `crates/dotagrid-cli/src/main.rs`)
- CLI workflow → Portrait pixels: stores pixels (evidence: `crates/dotagrid-cli/src/main.rs`)
- CLI workflow → ffmpeg: extracts frames (evidence: `crates/dotagrid-cli/src/main.rs`)
- CLI workflow → Portrait colors: writes colors (evidence: `crates/dotagrid-cli/src/main.rs`)
- Tree layout → Grid models: lays out categories (evidence: `crates/dota-hero-grid/src/geometry.rs`)
