# namkiet/datastructuresvisualizer architecture

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

- Interactive diagram: https://gitdiagram.com/namkiet/datastructuresvisualizer
- Repository: https://github.com/namkiet/datastructuresvisualizer

## Overview

##### Project Type and Purpose
- It’s an SFML-based application built with CMake. The purpose is to provide a fast, modular starting point for building an SFML game or multimedia project.
- The README clearly directs users on setting up, building, and even modifying SFML options.

##### File Structure
- Core: Located in include/Core and src/Core, this module contains the main application (App.cpp/main.cpp), action handling (Action, ActionQueue), resource management (ResourceHolder) and game world logic (World).
- Data Structures: Custom implementations (AVLTree, HeapTree, LinkedList) for handling data; these likely support other subsystems.
- GUI: Contains headers and implementations for various GUI components like Button, TextBox, Carousel, Container, and even a file reader. This module forms the user input and display overlay.
- SceneNode: Contains definitions for nodes, edges, pseudo-code views, and different hierarchical elements representing game objects or scene entities.
- State: Implements the game’s state management with different states (MenuState, TitleState, InApp) and a state stack.
- Assets and Shader: The assets folder (with images and fonts) provides static resources, and the shader directory includes shader code (like colormode.frag) used with SFML’s graphics module.
- Build Files: CMakeLists.txt defines the build process, incorporating SFML via CMake’s FetchContent.

##### Main Components and Their Relationships
- Core Module – The heart of the application, responsible for launching the game loop, processing events, and coordinating interactions.
- State Management – The State and StateStack classes control the flow of the application between menus, titles, and the in-app/gameplay screens.
- GUI System – Provides interactive components which are used within states to create game interfaces.
- SceneNode System – Represents game objects in a scene graph pattern; nodes (like CircleNode, TreeNode) can be used for rendering and spatial organization.
- Data Structures – Support various modules (e.g., using LinkedList for the scene nodes or state stack).
- Resource Management – The ResourceHolder and related utility classes manage loading and caching of fonts, images, and other assets.
- External Dependencies – SFML is the primary external library for graphics, audio, and window management. CMake builds and configures the project.

##### Architectural Patterns and Details
- Modular separation: each major directory represents a component/module.
- Use of state management and scene graph patterns (for scene nodes) as well as custom data structures to support dynamic data organization.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Main Application<br>(main.cpp, App.cpp)"]:::core
    S["State Management<br>(State.hpp,StateStack.hpp,TitleState,MenuState,InApp)"]:::state
    G["GUI System<br>(Button,TextBox,Carousel)"]:::gui
    N["SceneNode System<br>(SceneNode,CircleNode,Edge,TreeNode)"]:::scene
    D["Custom Data Structures<br>(AVLTree,HeapTree,LinkedList)"]:::datastruct
    R["Resource Management<br>(ResourceHolder,ResourceIdentifiers)"]:::resource
    AS["Assets & Shaders<br>(assets,colormode.frag)"]:::asset
    B["CMake Build<br>(CMakeLists.txt)"]:::build
    F["SFML Library"]:::external

    %% Connections
    A -->|"initState"| S
    A -->|"manages"| R
    A -->|"utilizes"| F
    S -->|"calls"| G
    S -->|"renders"| N
    D -->|"supports"| S
    D -->|"supports"| N
    G -->|"loads"| R
    G -->|"requires"| F
    N -->|"requires"| F
    R ---|"providedBy"| AS
    B -->|"builds"| A
    B -->|"builds"| S
    B -->|"builds"| G
    B -->|"builds"| N
    B -->|"builds"| R
    B -->|"builds"| D

    %% Click Events
    click A "https://github.com/namkiet/datastructuresvisualizer/tree/main/include/Core"
    click S "https://github.com/namkiet/datastructuresvisualizer/tree/main/include/State"
    click G "https://github.com/namkiet/datastructuresvisualizer/tree/main/include/GUI"
    click N "https://github.com/namkiet/datastructuresvisualizer/tree/main/include/SceneNode"
    click D "https://github.com/namkiet/datastructuresvisualizer/tree/main/include/DataStructures"
    click R "https://github.com/namkiet/datastructuresvisualizer/blob/main/include/Core/ResourceHolder.hpp"
    click AS "https://github.com/namkiet/datastructuresvisualizer/tree/main/assets"
    click B "https://github.com/namkiet/datastructuresvisualizer/blob/main/CMakeLists.txt"

    %% Styles
    classDef core fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef state fill:#FFB6C1,stroke:#000,stroke-width:1px;
    classDef gui fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef scene fill:#FFD700,stroke:#000,stroke-width:1px;
    classDef datastruct fill:#FFA07A,stroke:#000,stroke-width:1px;
    classDef resource fill:#DDA0DD,stroke:#000,stroke-width:1px;
    classDef asset fill:#F0E68C,stroke:#000,stroke-width:1px;
    classDef build fill:#E0FFFF,stroke:#000,stroke-width:1px;
    classDef external fill:#FFDEAD,stroke:#000,stroke-width:1px;
```
