# manuzxo/memory architecture

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

- Interactive diagram: https://gitdiagram.com/manuzxo/memory
- Repository: https://github.com/manuzxo/memory

## Overview

##### Project type and purpose
- This is a native, cross-platform Memory Game written in C. It uses Raylib (a simple C game library) and Raygui (an immediate-mode GUI extension).
- It compiles into a single executable that runs a graphical memory-matching game.

##### File structure
- Top-level files:
- CMakeLists.txt, build.sh, build.bat – build system and scripts
- README.md – project description & instructions
- Directories:
- /raylib, include/raylib/raygui.h – external headers bundled in-tree
- lib/(win, linux)/… – precompiled Raylib/Raygui libraries for each platform/architecture
- src/ – game source code, divided into:
– args.c/h: command-line argument parsing
– struct.h: core data structures (cards, board state)
– scene.c/h: game logic, state management
– render.c/h: drawing routines, GUI interaction
– main.c: program entry, main loop

##### README for additional insights
- Confirms Raylib and Raygui are the graphics layers.
- Explains build requirements (CMake or scripts) and supported platforms (Windows + Linux).

##### Elements
- From Build System → MemoryGame Executable (link)
- From MemoryGame Executable → Raylib/Raygui (API calls)
- From OS/Graphics Driver → Raylib/Raygui → Render Module (input events)
- Build-time artifacts (CMake, lib/) in gray
- Runtime modules (scene, render, args, Raylib) in blue
- External systems (OS/driver) in green

##### Detailing & capturing essentials
- Don’t split modules thinner than their C files; group related functions under their module name.
- Both compile-time (build scripts, libraries) and run-time flow (game loop, rendering, input).
- Use annotations or legends to note platform-specific library folders (win vs. linux).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Build-Time"
        direction TB
        subgraph "Build System"
            direction TB
            CMake["CMakeLists.txt"]:::build
            buildsh["build.sh"]:::build
            buildbat["build.bat"]:::build
        end
        subgraph "External Headers"
            direction TB
            header1["raylib.h"]:::build
            header2["raygui.h"]:::build
            header3["raymath.h"]:::build
            header4["rlgl.h"]:::build
        end
        subgraph "Precompiled Libraries"
            direction TB
            lib1["linux/x64/libraylib.a"]:::build
            lib2["linux/x86/libraylib.a"]:::build
            lib3["win/x64/raylib.lib"]:::build
            lib4["win/x64/raylibdll.lib"]:::build
            lib5["win/x86/raylib.lib"]:::build
            lib6["win/x86/raylibdll.lib"]:::build
        end
    end

    MemoryExec["MemoryGame Executable"]:::runtime

    CMake & buildsh & buildbat & header1 & header2 & header3 & header4 & lib1 & lib2 & lib3 & lib4 & lib5 & lib6 -->|"link"| MemoryExec

    subgraph "Runtime"
        direction TB
        subgraph "Executable Internals"
            direction TB
            mainc["main.c"]:::runtime
            subgraph "Args Module"
                direction TB
                args_c["args.c"]:::runtime
                args_h["args.h"]:::runtime
            end
            core["struct.h"]:::runtime
            subgraph "Scene Manager"
                direction TB
                scene_c["scene.c"]:::runtime
                scene_h["scene.h"]:::runtime
            end
            subgraph "Render Module"
                direction TB
                render_c["render.c"]:::runtime
                render_h["render.h"]:::runtime
            end
        end
        RayGuiLib["Raylib/Raygui"]:::runtime
        OS["OS/Graphics Driver"]:::external

        MemoryExec --> mainc
        mainc --> args_c
        args_c --> args_h
        mainc --> core
        mainc --> scene_c
        scene_c --> scene_h
        scene_c --> render_c
        render_c --> render_h
        mainc -->|"game loop start"| scene_c
        scene_c -->|"update state"| render_c
        render_c -->|"draw & GUI"| RayGuiLib
        OS -->|"input events"| RayGuiLib
        RayGuiLib -->|"forward input"| render_c
    end

    classDef build fill:#cccccc,stroke:#888888,color:#000000;
    classDef runtime fill:#add8e6,stroke:#0000ff,color:#000000;
    classDef external fill:#b6e6b0,stroke:#228B22,color:#000000;

    click CMake "https://github.com/manuzxo/memory/blob/main/CMakeLists.txt"
    click buildsh "https://github.com/manuzxo/memory/blob/main/build.sh"
    click buildbat "https://github.com/manuzxo/memory/blob/main/build.bat"
    click header1 "https://github.com/manuzxo/memory/blob/main/include/raylib/raylib.h"
    click header2 "https://github.com/manuzxo/memory/blob/main/include/raylib/raygui.h"
    click header3 "https://github.com/manuzxo/memory/blob/main/include/raylib/raymath.h"
    click header4 "https://github.com/manuzxo/memory/blob/main/include/raylib/rlgl.h"
    click lib1 "https://github.com/manuzxo/memory/blob/main/lib/linux/x64/libraylib.a"
    click lib2 "https://github.com/manuzxo/memory/blob/main/lib/linux/x86/libraylib.a"
    click lib3 "https://github.com/manuzxo/memory/blob/main/lib/win/x64/raylib.lib"
    click lib4 "https://github.com/manuzxo/memory/blob/main/lib/win/x64/raylibdll.lib"
    click lib5 "https://github.com/manuzxo/memory/blob/main/lib/win/x86/raylib.lib"
    click lib6 "https://github.com/manuzxo/memory/blob/main/lib/win/x86/raylibdll.lib"
    click args_c "https://github.com/manuzxo/memory/blob/main/src/args.c"
    click args_h "https://github.com/manuzxo/memory/blob/main/src/args.h"
    click core "https://github.com/manuzxo/memory/blob/main/src/struct.h"
    click scene_c "https://github.com/manuzxo/memory/blob/main/src/scene.c"
    click scene_h "https://github.com/manuzxo/memory/blob/main/src/scene.h"
    click render_c "https://github.com/manuzxo/memory/blob/main/src/render.c"
    click render_h "https://github.com/manuzxo/memory/blob/main/src/render.h"
    click mainc "https://github.com/manuzxo/memory/blob/main/src/main.c"
```
