# zxsrxt-kebab-case/snake-game architecture

> Architecture diagram of the GitHub repository zxsrxt-kebab-case/snake-game, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zxsrxt-kebab-case/snake-game
- Repository: https://github.com/zxsrxt-kebab-case/snake-game

## Overview

This is a small C++ Snake game using Dear ImGui with a Win32/DirectX 11 presentation layer. The principal loop initializes the window and backend, reads arrow-key input, updates game state, renders the map and entities, then presents the frame. The game logic separates controller, snake, apple, and map responsibilities; rendering uses a small ImGui drawing helper. Edges follow the entry-point calls and documented/import references; the vendored ImGui internals are grouped as a framework rather than expanded into individual implementation files.

Main entry points: [`external/imgui/imgui.cpp`](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/imgui.cpp) (ImGui Core), [`src/App/main.cpp`](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/App/main.cpp) (Game Loop), [`src/GameRenderer/GameRenderer.cpp`](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/GameRenderer/GameRenderer.cpp) (Game Renderer), [`src/GameController/GameController.cpp`](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/GameController/GameController.cpp) (Game Controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_main["Game Loop<br/>[main.cpp]"]
  node_window["Win32 Window<br/>[Win.cpp]"]
  node_backend["DX11 Backend<br/>[ImGuiBackend.cpp]"]
end

subgraph group_game["Game State"]
  node_controller["Game Controller<br/>[GameController.cpp]"]
  node_snake["Snake<br/>[Snake.cpp]"]
  node_apple["Apple<br/>[Apple.cpp]"]
  node_map["Map Bounds<br/>[Map.cpp]"]
  node_vector["Grid Vector<br/>[Vector2.hpp]"]
end

subgraph group_render["Rendering"]
  node_renderer["Game Renderer<br/>[GameRenderer.cpp]"]
  node_draw["Draw Elements<br/>[RenderElements.cpp]"]
end

subgraph group_imgui["Dear ImGui"]
  node_imgui_core["ImGui Core<br/>[imgui.cpp]"]
  node_imgui_widgets["Widgets<br/>[imgui_widgets.cpp]"]
  node_imgui_tables["Tables<br/>[imgui_tables.cpp]"]
  node_imgui_draw["Draw And Fonts<br/>[imgui_draw.cpp]"]
  node_imgui_demo["Demo UI<br/>[imgui_demo.cpp]"]
  node_opengl_backend["OpenGL3 Backend"]
  node_glfw_backend["GLFW Backend"]
  node_vulkan_backend["Vulkan Backend"]
  node_freetype["FreeType Fonts<br/>[imgui_freetype.cpp]"]
end

node_player(("Player"))

node_player -->|"provides keys"| node_main
node_main -->|"polls events"| node_window
node_main -->|"starts frames"| node_backend
node_main -->|"sets input; updates"| node_controller
node_main -->|"renders state"| node_renderer
node_controller -->|"updates"| node_snake
node_controller -->|"manages"| node_apple
node_controller -.->|"checks bounds"| node_map
node_snake -->|"uses positions"| node_vector
node_apple -->|"uses position"| node_vector
node_map -->|"uses bounds"| node_vector
node_renderer -->|"draws elements"| node_draw
node_renderer -->|"reads state"| node_snake
node_renderer -->|"reads state"| node_apple
node_renderer -->|"reads bounds"| node_map
node_draw -->|"submits drawing"| node_imgui_core
node_backend -->|"uses handle"| node_window
node_backend -->|"initializes"| node_imgui_core
node_imgui_core -.->|"uses"| node_imgui_widgets
node_imgui_core -.->|"uses"| node_imgui_tables
node_imgui_core -.->|"uses"| node_imgui_draw
node_opengl_backend -->|"renders draw data"| node_imgui_core
node_glfw_backend -->|"integrates platform"| node_imgui_core
node_vulkan_backend -->|"renders draw data"| node_imgui_core
node_freetype -->|"builds fonts"| node_imgui_draw

click node_main "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/App/main.cpp"
click node_window "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/App/Win/Win.cpp"
click node_backend "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/App/ImGuiBackend/ImGuiBackend.cpp"
click node_controller "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/GameController/GameController.cpp"
click node_snake "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/Entity/Snake/Snake.cpp"
click node_apple "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/Entity/Apple/Apple.cpp"
click node_map "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/Map/Map.cpp"
click node_vector "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/Math/Vector2.hpp"
click node_renderer "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/GameRenderer/GameRenderer.cpp"
click node_draw "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/GameRenderer/RenderElements/RenderElements.cpp"
click node_imgui_core "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/imgui.cpp"
click node_imgui_widgets "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/imgui_widgets.cpp"
click node_imgui_tables "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/imgui_tables.cpp"
click node_imgui_draw "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/imgui_draw.cpp"
click node_imgui_demo "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/imgui_demo.cpp"
click node_opengl_backend "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/backends/imgui_impl_opengl3.cpp"
click node_glfw_backend "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/backends/imgui_impl_glfw.cpp"
click node_vulkan_backend "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/backends/imgui_impl_vulkan.cpp"
click node_freetype "https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/misc/freetype/imgui_freetype.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_window,node_backend toneBlue
class node_controller,node_snake,node_apple,node_map,node_vector toneAmber
class node_renderer,node_draw toneMint
class node_imgui_core,node_imgui_widgets,node_imgui_tables,node_imgui_draw,node_imgui_demo,node_opengl_backend,node_glfw_backend,node_vulkan_backend,node_freetype toneRose
class node_player toneIndigo
```

## Components

### Application

- [Game Loop](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/App/main.cpp): `src/App/main.cpp`
- [Win32 Window](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/App/Win/Win.cpp): `src/App/Win/Win.cpp`
- [DX11 Backend](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/App/ImGuiBackend/ImGuiBackend.cpp): `src/App/ImGuiBackend/ImGuiBackend.cpp`

### Game State

- [Game Controller](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/GameController/GameController.cpp): `src/GameController/GameController.cpp`
- [Snake](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/Entity/Snake/Snake.cpp): `src/Entity/Snake/Snake.cpp`
- [Apple](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/Entity/Apple/Apple.cpp): `src/Entity/Apple/Apple.cpp`
- [Map Bounds](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/Map/Map.cpp): `src/Map/Map.cpp`
- [Grid Vector](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/Math/Vector2.hpp): `src/Math/Vector2.hpp`

### Rendering

- [Game Renderer](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/GameRenderer/GameRenderer.cpp): `src/GameRenderer/GameRenderer.cpp`
- [Draw Elements](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/src/GameRenderer/RenderElements/RenderElements.cpp): `src/GameRenderer/RenderElements/RenderElements.cpp`

### Dear ImGui

- [ImGui Core](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/imgui.cpp): `external/imgui/imgui.cpp`
- [Widgets](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/imgui_widgets.cpp): `external/imgui/imgui_widgets.cpp`
- [Tables](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/imgui_tables.cpp): `external/imgui/imgui_tables.cpp`
- [Draw And Fonts](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/imgui_draw.cpp): `external/imgui/imgui_draw.cpp`
- [Demo UI](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/imgui_demo.cpp): `external/imgui/imgui_demo.cpp`
- [OpenGL3 Backend](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/backends/imgui_impl_opengl3.cpp): `external/imgui/backends/imgui_impl_opengl3.cpp`
- [GLFW Backend](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/backends/imgui_impl_glfw.cpp): `external/imgui/backends/imgui_impl_glfw.cpp`
- [Vulkan Backend](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/backends/imgui_impl_vulkan.cpp): `external/imgui/backends/imgui_impl_vulkan.cpp`
- [FreeType Fonts](https://github.com/zxsrxt-kebab-case/snake-game/blob/master/external/imgui/misc/freetype/imgui_freetype.cpp): `external/imgui/misc/freetype/imgui_freetype.cpp`

### Other components

- **Player**

## Connections

- Player → Game Loop: provides keys (evidence: `src/App/main.cpp`)
- Game Loop → Win32 Window: polls events (evidence: `src/App/main.cpp`)
- Game Loop → DX11 Backend: starts frames (evidence: `src/App/main.cpp`)
- Game Loop → Game Controller: sets input; updates (evidence: `src/App/main.cpp`)
- Game Loop → Game Renderer: renders state (evidence: `src/App/main.cpp`)
- Game Controller → Snake: updates
- Game Controller → Apple: manages
- Game Controller → Map Bounds: checks bounds
- Snake → Grid Vector: uses positions
- Apple → Grid Vector: uses position
- Map Bounds → Grid Vector: uses bounds
- Game Renderer → Draw Elements: draws elements
- Game Renderer → Snake: reads state
- Game Renderer → Apple: reads state
- Game Renderer → Map Bounds: reads bounds
- Draw Elements → ImGui Core: submits drawing
- DX11 Backend → Win32 Window: uses handle
- DX11 Backend → ImGui Core: initializes (evidence: `src/App/ImGuiBackend/ImGuiBackend.cpp`)
- ImGui Core → Widgets: uses
- ImGui Core → Tables: uses
- ImGui Core → Draw And Fonts: uses
- OpenGL3 Backend → ImGui Core: renders draw data (evidence: `external/imgui/backends/imgui_impl_opengl3.cpp`)
- GLFW Backend → ImGui Core: integrates platform (evidence: `external/imgui/backends/imgui_impl_glfw.cpp`)
- Vulkan Backend → ImGui Core: renders draw data (evidence: `external/imgui/backends/imgui_impl_vulkan.cpp`)
- FreeType Fonts → Draw And Fonts: builds fonts
