# matheus0214/platform-game-raylib-c architecture

> Architecture diagram of the GitHub repository matheus0214/platform-game-raylib-c, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/matheus0214/platform-game-raylib-c
- Repository: https://github.com/matheus0214/platform-game-raylib-c

## Overview

##### Project Type and Purpose
- This is a small C “game” or interactive application structured around screens, player logic, assets (UI, fonts), and configuration.
- It uses a Makefile build system augmented by Bear (to generate compile_commands.json) and clangd as the language server.

##### Main Architectural Components
A. Build & Tooling
- Makefile + Bear
- clangd (language server)
B. Core Executable
- src/main.c
C. Module Layers
1. Configuration Module
– include/configs/config.h
– Holds global constants, build‐time flags
2. Asset Management Module
– src/assets.c, include/utils/assets.h
– Loads UI elements, fonts, other media from assets/
3. Screen Management Module
– src/screens.c, include/screens/screens.h
– Individual screens:
– Main menu (src/screens/main_menu.c, include/screens/main_menu.h)
– Level 1 (src/screens/level_1.c, include/screens/level_1.h)
4. Player Module
– src/player.c, include/player/player.h
– Player state, input handling, physics
D. Resources
– assets/ui/
– assets/fonts/

##### Component Relationships and Data Flow
- The Core Executable (“Main”) initializes subsystems in this order:
1. Config module → sets up global parameters
2. Asset Manager → loads assets into memory
3. Screen Manager → pushes initial screen (main menu)
4. Player Module (tied into screen update loops)

##### Architectural Patterns / Principles
- Layered architecture:
1. Presentation (Screens + Assets)
2. Domain (Player logic)
3. Configuration & Utilities
- Single‐entry point (main.c), separation of concerns for each module.
- Modularity: each feature lives in its own directory under include/ and src/.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build & Tooling
    subgraph "Build & Tooling"
        Makefile["Makefile"]:::build
        Bear["Bear"]:::build
        CCJSON["compile_commands.json"]:::build
        Clangd["clangd (.clang-format)"]:::build
    end
    Makefile -->|"runs"| Bear
    Bear -->|"generates"| CCJSON
    CCJSON -->|"used by"| Clangd

    %% Core Executable
    subgraph "Core Executable"
        Main["Main (src/main.c)"]:::core
    end
    Makefile -->|"builds"| Main

    %% Modules
    subgraph "Modules"
        subgraph "Configuration Module"
            Config["config.h"]:::module
        end
        subgraph "Asset Management Module"
            AssetsImpl["assets.c"]:::module
            AssetsHdr["assets.h"]:::module
        end
        subgraph "Screen Management Module"
            ScreenMgrImpl["screens.c"]:::module
            ScreenMgrHdr["screens.h"]:::module
            subgraph "Screens"
                MainMenuImpl["main_menu.c"]:::module
                MainMenuHdr["main_menu.h"]:::module
                Level1Impl["level_1.c"]:::module
                Level1Hdr["level_1.h"]:::module
            end
        end
        subgraph "Player Module"
            PlayerImpl["player.c"]:::module
            PlayerHdr["player.h"]:::module
        end
    end

    %% Resources
    subgraph "Resources"
        UI["assets/ui/"]:::resource
        Fonts["assets/fonts/"]:::resource
    end

    %% Initialization Flow
    Main -->|"init Config"| Config
    Main -->|"init Assets"| AssetsImpl
    Main -->|"init ScreenMgr"| ScreenMgrImpl
    Main -->|"init Player"| PlayerImpl

    %% Runtime Interactions
    ScreenMgrImpl -->|"load_assets() / draw UI"| AssetsImpl
    ScreenMgrImpl -->|"player callbacks"| PlayerImpl
    ScreenMgrImpl -->|"manages"| MainMenuImpl
    ScreenMgrImpl -->|"manages"| Level1Impl

    %% Dependencies
    Config -->|"dependency"| Main
    Config -->|"dependency"| AssetsImpl
    Config -->|"dependency"| ScreenMgrImpl
    Config -->|"dependency"| PlayerImpl
    AssetsImpl -->|"loads media from"| UI
    AssetsImpl -->|"loads media from"| Fonts

    %% Click Events
    click Makefile "https://github.com/matheus0214/platform-game-raylib-c/tree/main/./Makefile"
    click Clangd "https://github.com/matheus0214/platform-game-raylib-c/blob/main/./.clang-format"
    click Main "https://github.com/matheus0214/platform-game-raylib-c/blob/main/./src/main.c"
    click Config "https://github.com/matheus0214/platform-game-raylib-c/blob/main/./include/configs/config.h"
    click AssetsImpl "https://github.com/matheus0214/platform-game-raylib-c/blob/main/./src/assets.c"
    click AssetsHdr "https://github.com/matheus0214/platform-game-raylib-c/blob/main/./include/utils/assets.h"
    click UI "https://github.com/matheus0214/platform-game-raylib-c/tree/main/./assets/ui/"
    click Fonts "https://github.com/matheus0214/platform-game-raylib-c/tree/main/./assets/fonts/"
    click ScreenMgrImpl "https://github.com/matheus0214/platform-game-raylib-c/blob/main/./src/screens.c"
    click ScreenMgrHdr "https://github.com/matheus0214/platform-game-raylib-c/blob/main/./include/screens/screens.h"
    click MainMenuImpl "https://github.com/matheus0214/platform-game-raylib-c/blob/main/./src/screens/main_menu.c"
    click MainMenuHdr "https://github.com/matheus0214/platform-game-raylib-c/blob/main/./include/screens/main_menu.h"
    click Level1Impl "https://github.com/matheus0214/platform-game-raylib-c/blob/main/./src/screens/level_1.c"
    click Level1Hdr "https://github.com/matheus0214/platform-game-raylib-c/blob/main/./include/screens/level_1.h"
    click PlayerImpl "https://github.com/matheus0214/platform-game-raylib-c/blob/main/./src/player.c"
    click PlayerHdr "https://github.com/matheus0214/platform-game-raylib-c/blob/main/./include/player/player.h"

    %% Styles
    classDef build fill:#d5f5e3,stroke:#27ae60
    classDef core fill:#ebdef0,stroke:#8e44ad
    classDef module fill:#d6eaf8,stroke:#2980b9
    classDef resource fill:#fcf3cf,stroke:#f1c40f
```
