# shenmian/sokoban-rs architecture

> Architecture diagram of the GitHub repository shenmian/sokoban-rs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shenmian/sokoban-rs
- Repository: https://github.com/shenmian/sokoban-rs

## Overview

##### Key Components

Frontend Components (Top Layer):
- A "Rendering System" component (from systems/render.rs)
- A "Camera System" component (from plugins/camera.rs)
- An "Input Handler" component that processes keyboard/mouse/controller input (from systems/input.rs)

Core Game Logic (Middle Layer):
- A "Board Manager" component (from board.rs)
- An "Event System" component (from events.rs)
- "Audio System" component (from systems/audio.rs)

Backend Systems (Bottom Layer):
- A "Solver Engine" component (from solve/solver.rs)
- A "Configuration Manager" component (from plugins/config.rs)

##### Special Features to Highlight
- Auto-solve capability (plugins/auto_solve.rs)
- Auto-move system (plugins/auto_move.rs)
- Performance monitoring (plugins/performance_matrix.rs)

##### External Resources
- An "Assets" container showing:
- Audio files
- Texture resources
- Level files

##### Specific Implementation Details
- Separation between Bevy-specific code and pure game logic
- Plugin architecture used by the game
- Event system that coordinates between components

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef infra fill:#f1c40f,stroke:#f39c12,color:black
    classDef critical fill:#e74c3c,stroke:#c0392b,color:white

    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        C[Core Logic]:::core
        I[Infrastructure]:::infra
        CR[Critical Systems]:::critical
    end

    %% Frontend Layer
    subgraph Presentation
        UI["UI System"]:::frontend
        RS["Rendering System"]:::frontend
        CS["Camera System"]:::frontend
        IH["Input Handler"]:::frontend
    end

    %% Core Layer
    subgraph GameLogic
        GSM["Game State Manager"]:::core
        BM["Board Manager"]:::core
        ES["Event System"]:::core
        AS["Audio System"]:::core
        ATS["Auto-solve System"]:::core
        ATM["Auto-move System"]:::core
        PM["Performance Monitor"]:::core
    end

    %% Infrastructure Layer
    subgraph Infrastructure
        LD["Level Database"]:::infra
        SE["Solver Engine"]:::critical
        CM["Configuration Manager"]:::infra
        
        subgraph Assets
            AA["Audio Assets"]:::infra
            LA["Level Assets"]:::infra
            TA["Texture Assets"]:::infra
        end
    end

    %% Relationships
    IH --> ES
    ES --> GSM
    GSM --> BM
    BM --> RS
    UI --> RS
    CS --> RS
    AS --> AA
    GSM --> LD
    SE --> BM
    CM --> GSM
    ATS --> SE
    ATM --> BM
    PM --> GSM
    BM --> LD

    %% Click Events
    click UI "https://github.com/ShenMian/sokoban-rs/blob/main/src/plugins/ui.rs"
    click RS "https://github.com/ShenMian/sokoban-rs/blob/main/src/systems/render.rs"
    click CS "https://github.com/ShenMian/sokoban-rs/blob/main/src/plugins/camera.rs"
    click IH "https://github.com/ShenMian/sokoban-rs/blob/main/src/systems/input.rs"
    click GSM "https://github.com/ShenMian/sokoban-rs/blob/main/src/state.rs"
    click BM "https://github.com/ShenMian/sokoban-rs/blob/main/src/board.rs"
    click ES "https://github.com/ShenMian/sokoban-rs/blob/main/src/events.rs"
    click AS "https://github.com/ShenMian/sokoban-rs/blob/main/src/systems/audio.rs"
    click LD "https://github.com/ShenMian/sokoban-rs/blob/main/src/database.rs"
    click SE "https://github.com/ShenMian/sokoban-rs/blob/main/src/solve/solver.rs"
    click CM "https://github.com/ShenMian/sokoban-rs/blob/main/src/plugins/config.rs"
    click ATS "https://github.com/ShenMian/sokoban-rs/blob/main/src/plugins/auto_solve.rs"
    click ATM "https://github.com/ShenMian/sokoban-rs/blob/main/src/plugins/auto_move.rs"
    click PM "https://github.com/ShenMian/sokoban-rs/blob/main/src/plugins/performance_matrix.rs"
    click AA "https://github.com/ShenMian/sokoban-rs/tree/main/assets/audio"
    click LA "https://github.com/ShenMian/sokoban-rs/tree/main/assets/levels"
    click TA "https://github.com/ShenMian/sokoban-rs/tree/main/assets/textures"
```
