# lisagheclys/sokoban_2021-epitech architecture

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

- Interactive diagram: https://gitdiagram.com/lisagheclys/sokoban_2021-epitech
- Repository: https://github.com/lisagheclys/sokoban_2021-epitech

## Overview

##### Main Components
- Entry Point & Command Processing: Represented by src/main.c, which parses the command-line arguments (e.g., a map file or the -h flag) and sets the stage for the game.
- Initialization & Map Loading: The initialization module (src/init.c) and map validation (src/is_the_right_map.c) work together to load and verify the map file coming from the maps/ directory. This component is responsible for setting up the initial game state.
- Core Game Logic: The heart of the application is in src/my_sokoban.c along with other logic files (src/movement.c, src/lose.c, src/win.c, src/reload.c) that implement player movement, check for win/lose conditions, and refresh the game state.
- Utility and Display Functions: Utility libraries in lib (especially under lib/my such as my_printf.c and its related functions) provide functions for console output, string handling, and number formatting. These support the game’s display and debugging.
- Header Declarations: The include/ directory (with files like myprintf.h and mysokoban.h) defines the interfaces for the functions used throughout the project.
- Build & Documentation: The Makefile and the usage help text (usages/help.txt) define the build process and assist users in understanding how to run the game.

##### Relationships and Interactions
- The Main Component (src/main.c) invokes the Initialization Module, which in turn calls the Map Loader/Validator to read and verify the map file.
- Once initialized, control passes to the Game Loop implemented via the core game logic files. This module handles player input (e.g., moves) that update the game state.
- After each state change, display functions from the Utility Library (lib/my) are used to refresh the visual output on the console.
- The header files in include/ ensure consistent function declarations across modules, maintaining clear interfaces.
- Build scripts (Makefile) integrate these pieces during compilation, while the README and help text provide operational guidance.

##### Architectural Patterns & Design Principles
- Separation of Concerns: There’s a clear division between initialization/map loading, core game logic (movement, win/lose checks), and utility functions for display/output.
- Modular Design: Each directory (src, lib, include) contains logically grouped code. The design favors maintainability with specialized modules handling specific tasks (e.g., map validation vs. movement).
- Layered Interaction: The game consists of layers—from input/initialization to game processing and finally to output and feedback—with well-defined interaction points (via function calls and header interfaces).

##### Technologies & Frameworks
- Language: C (using standard libraries and custom implementations for printing and string manipulations).
- Build Tools: Makefile for building the project.
- Resources: Simple text-based maps that serve as game levels.
- Console I/O: Custom my_printf and related functions provide enhanced output handling on the terminal.

##### Final Assembly
- Key components and their relationships are present.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Components
    subgraph "Core Components"
        A["Entry/Main (src/main.c)"]:::core
        subgraph "Initialization & Map Loading"
            B["Init (src/init.c)"]:::core
            C["Map Validator (src/is_the_right_map.c)"]:::core
        end
        subgraph "Game Loop & State Management"
            D["Sokoban Core (src/my_sokoban.c)"]:::core
            E["Movement (src/movement.c)"]:::core
            F["Lose Condition (src/lose.c)"]:::core
            G["Win Condition (src/win.c)"]:::core
            H["Reload (src/reload.c)"]:::core
        end
    end

    %% Supporting Components
    subgraph "Supporting Components"
        I["Utility & Display (lib/my)"]:::support
        J["Header Interfaces (include/)"]:::support
    end

    %% External Resources
    subgraph "External Resources"
        subgraph "Map Resources"
            K["Map Files (maps/)"]:::external
        end
        subgraph "Build & Documentation"
            L["Makefile"]:::external
            M["Usage Help (usages/help.txt)"]:::external
        end
    end

    %% Connections
    A -->|"parses_args"| B
    B -->|"calls_validator"| C
    B -->|"initializes_game"| D
    D -->|"handles_movement"| E
    D -->|"checks_lose"| F
    D -->|"checks_win"| G
    D -->|"reloads_state"| H
    D -->|"updates_output"| I
    D -->|"uses_interfaces"| J
    B -->|"loads_map"| K
    L -->|"builds"| A
    M -->|"guides_usage"| A

    %% Styles
    classDef core fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef support fill:#ccffcc,stroke:#009900,stroke-width:2px;
    classDef external fill:#cce5ff,stroke:#003366,stroke-width:2px;

    %% Click Events
    click A "https://github.com/lisagheclys/sokoban_2021-epitech/blob/master/src/main.c"
    click B "https://github.com/lisagheclys/sokoban_2021-epitech/blob/master/src/init.c"
    click C "https://github.com/lisagheclys/sokoban_2021-epitech/blob/master/src/is_the_right_map.c"
    click D "https://github.com/lisagheclys/sokoban_2021-epitech/blob/master/src/my_sokoban.c"
    click E "https://github.com/lisagheclys/sokoban_2021-epitech/blob/master/src/movement.c"
    click F "https://github.com/lisagheclys/sokoban_2021-epitech/blob/master/src/lose.c"
    click G "https://github.com/lisagheclys/sokoban_2021-epitech/blob/master/src/win.c"
    click H "https://github.com/lisagheclys/sokoban_2021-epitech/blob/master/src/reload.c"
    click I "https://github.com/lisagheclys/sokoban_2021-epitech/tree/master/lib/my"
    click J "https://github.com/lisagheclys/sokoban_2021-epitech/tree/master/include/"
    click K "https://github.com/lisagheclys/sokoban_2021-epitech/tree/master/maps/"
    click L "https://github.com/lisagheclys/sokoban_2021-epitech/tree/master/Makefile"
    click M "https://github.com/lisagheclys/sokoban_2021-epitech/blob/master/usages/help.txt"
```
