# criomby/pokeget-plus architecture

> Architecture diagram of the GitHub repository criomby/pokeget-plus, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/criomby/pokeget-plus
- Repository: https://github.com/criomby/pokeget-plus

## Overview

##### Project type and purpose
- pokeget-plus is a standalone Rust CLI application that embeds Pokémon/item sprites and displays them in the terminal.
- It is built and distributed via Cargo, uses a Git submodule for the `pokesprite` asset library, and runs fully offline, reading embedded data assets.

##### File structure
- Top-level:
- `.github/workflows/build.yml` → CI/CD build pipeline
- `Cargo.toml`/`Cargo.lock` → Rust project manifest
- `src/` → Rust source modules
– `main.rs` → binary entry point
– `cli.rs` → command-line argument parsing and help text
– `data.rs` → data-list loading (items.json, items-list.txt, pokedex-list.txt)
– `sprites.rs` → sprite selection logic & embedding
– `utils.rs` → helper functions (randomization, path resolution)
– `lib.rs` → core library interfaces shared between `main.rs` and tests
- `data/` → static data files (item lists, JSON metadata, raw sprite assets via submodule)
- `scripts/` → tooling (e.g., `dirs.py` to build directory indices)
- `.gitmodules` → references the `pokesprite` submodule

##### Key README insights
- Purpose: “Display Pokémon or items in your terminal” with options for random selection, categories, retro Gen7 sprites.
- Sprites are embedded into the binary at compile time (no runtime download).
- Provides both prebuilt binaries and source installation via `cargo install`.
- Configuration flags to enable/disable features (`--gen7`, `--no-default-features`).

##### Main components
a. User & Environment
- Terminal / Shell (user input and output rendering)
b. CLI Layer
- `main.rs` + `cli.rs` → parse arguments, dispatch commands (pokemon vs. item, random vs. specific)
c. Core Library Layer
- `lib.rs` → common interfaces and business logic
- `utils.rs` → helpers for random selection and I/O
d. Data Management Layer
- `data.rs` → loads JSON/text metadata from embedded resources
- Embedded data assets (items.json, items-list.txt, pokedex-list.txt)
e. Sprite Management Layer
- `sprites.rs` → selects correct sprite path/bytes based on CLI args
- Submodule: `pokesprite` (embedded at compile time via `include_bytes!`)
f. Output Renderer
- Terminal output (print ANSI sequences or raw bytes for sprite images)
g. Build & Deployment
- Cargo build pipeline (Cargo.toml features, submodule initialization, embedding assets)
- CI Workflow (.github/workflows/build.yml) producing release artifacts

##### Relationships and interactions
- Data Layer → returns metadata
- Sprite Layer → returns sprite bytes
→ Core Library → Renderer → Terminal

##### Architectural patterns/design principles
- Layered design: clear separation between CLI parsing, business logic, data access, and rendering
- Single binary distribution, embedding all assets (offline first)
- Feature flags for modular inclusion/exclusion of asset sets
- Use of a submodule to separate third-party sprite assets from application code

##### Essential elements
- Clear labels on each component
- Call out feature-flag inputs (`--gen7`, `--no-default-features`) and how they alter embedding

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Run-time Flow
    subgraph "Run-time Flow"
        direction TB
        User["User"]:::external
        Terminal["Terminal UI"]:::ui
        subgraph "CLI Layer"
            direction TB
            Main["main.rs"]:::cli
            CLIParser["cli.rs"]:::cli
        end
        subgraph "Core Library Layer"
            direction TB
            Lib["lib.rs"]:::core
            Utils["utils.rs"]:::core
        end
        subgraph "Data Management Layer"
            direction TB
            DataModule["data.rs"]:::data
            ItemsJSON["items.json"]:::data
            ItemsList["items-list.txt"]:::data
            PokedexList["pokedex-list.txt"]:::data
        end
        subgraph "Sprite Management Layer"
            direction TB
            Sprites["sprites.rs"]:::sprite
            PokeSpriteSubmodule["pokesprite (submodule)"]:::external
        end
        Renderer["Output Renderer"]:::renderer

        User --> Terminal
        Terminal --> Main
        Main --> CLIParser
        CLIParser --> Lib
        Lib --> Utils
        Utils --> DataModule
        DataModule --> ItemsJSON
        DataModule --> ItemsList
        DataModule --> PokedexList
        Lib --> Sprites
        Sprites --> PokeSpriteSubmodule
        Lib --> Renderer
        Renderer --> Terminal
    end

    %% Build-time Flow
    subgraph "Build-time Flow"
        direction TB
        CargoToml["Cargo.toml"]:::build
        GitModules[".gitmodules"]:::build
        CI[".github/workflows/build.yml"]:::build
        BuildPipeline["Cargo Build Pipeline"]:::build
        Binary["pokeget-plus Binary"]:::external
        FeatureFlags["Feature Flags"]:::build

        CargoToml -.-> FeatureFlags
        CargoToml --> BuildPipeline
        GitModules --> BuildPipeline
        CI --> BuildPipeline
        BuildPipeline -.-> Binary
        FeatureFlags -.-> BuildPipeline
    end

    classDef external fill:#EEEEEE,stroke:#999999,stroke-width:1px
    classDef ui fill:#D0E8FF,stroke:#0366D6,stroke-width:1px
    classDef cli fill:#E2F0D9,stroke:#22863A,stroke-width:1px
    classDef core fill:#FFF5B1,stroke:#735C0F,stroke-width:1px
    classDef data fill:#D1FAE5,stroke:#059669,stroke-width:1px
    classDef sprite fill:#FFEDD5,stroke:#C2410C,stroke-width:1px
    classDef renderer fill:#F0F8FF,stroke:#1E90FF,stroke-width:1px
    classDef build fill:#F3E8FF,stroke:#7D3C98,stroke-width:1px

    %% Click Events
    click Main "https://github.com/criomby/pokeget-plus/blob/main/src/main.rs"
    click CLIParser "https://github.com/criomby/pokeget-plus/blob/main/src/cli.rs"
    click Lib "https://github.com/criomby/pokeget-plus/blob/main/src/lib.rs"
    click Utils "https://github.com/criomby/pokeget-plus/blob/main/src/utils.rs"
    click DataModule "https://github.com/criomby/pokeget-plus/blob/main/src/data.rs"
    click ItemsJSON "https://github.com/criomby/pokeget-plus/blob/main/data/items.json"
    click ItemsList "https://github.com/criomby/pokeget-plus/blob/main/data/items-list.txt"
    click PokedexList "https://github.com/criomby/pokeget-plus/blob/main/data/pokedex-list.txt"
    click Sprites "https://github.com/criomby/pokeget-plus/blob/main/src/sprites.rs"
    click PokeSpriteSubmodule "https://github.com/criomby/pokeget-plus/tree/main/data/pokesprite/"
    click CargoToml "https://github.com/criomby/pokeget-plus/blob/main/Cargo.toml"
    click CI "https://github.com/criomby/pokeget-plus/blob/main/.github/workflows/build.yml"
    click GitModules "https://github.com/criomby/pokeget-plus/blob/main/.gitmodules"
```
