# ntut-open-source-club/practical-tools-for-simple-design architecture

> Architecture diagram of the GitHub repository ntut-open-source-club/practical-tools-for-simple-design, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ntut-open-source-club/practical-tools-for-simple-design
- Repository: https://github.com/ntut-open-source-club/practical-tools-for-simple-design

## Overview

##### Project type and purpose
- This is a C++ toolkit/library (“PTSD”) providing Core graphics primitives (OpenGL context, shaders, buffers, textures) and higher-level utilities (asset management, input, audio, game-object abstraction, text, animation).
- It ships as a static/shared library, with an example application and unit/interactive tests.
- It uses CMake as build system, targets cross-platform (Windows/macOS/Linux), and integrates CI (GitHub Actions) and Doxygen docs.

##### File structure
- Top-level modules/directories:
– cmake/ & CMakeLists.txt → build logic & dependency wiring
– include/Core & src/Core → low-level OpenGL wrappers
– include/Util & src/Util → utilities: AssetStore, Input, Audio (BGM/SFX), Renderer, GameObject, Text, Animation, Time, Transform
– assets/ → images, audio, fonts, shaders
– example/ → sample application that links the library and consumes assets
– test/ → unit & interactive tests that link the library
– docs/ → Doxygen configuration and custom CSS
– .github/ → CI workflows (build, check, docs, post)

##### Extract insights from README
- Dependencies: C/C++ compiler, CMake, OpenGL, optional Ninja build, optional Clang
- Quick-start: CMake configure & build, target IDEs (CLion, VSCode)
- Docs: generate with Doxygen
- CI: GitHub Actions for build/test/docs

##### Main components
a. Build System
– CMake + optional Ninja → drives compilation of Core and Util modules into a PTSD library artifact
– GitHub Actions workflows (build.yml, check.yml, docs.yml)
b. PTSD Library (Core + Util)
– Core Module
- Context manager (GL context creation)
- Shader & Program loaders
- VertexBuffer, IndexBuffer, VertexArray
- Texture & TextureUtils
- DebugMessageCallback
– Util Module
- AssetStore (loads images, audio, shaders, fonts)
- GameObject, Transform, Animation
- Input (keyboard/mouse)
- Audio: BGM & SFX
- Text rendering (font and text utilities)
c. Example Application
– Links PTSD Library
– Loads assets from assets/
– Runs game loop: input→update (GameObject, Animation, Time)→render (Core+Util)
– Plays audio (BGM/SFX)
d. Tests
– Unit tests (SimpleTest, TransformTest, NotSimpleTest) link PTSD Library
– Interactive tests for Audio
e. Documentation
– Source code → Doxygen (docs/Doxyfile) → HTML output
f. External Dependencies
– OpenGL implementation (system GPU drivers)
– Standard C++ library
– (Optionally) audio backend if used internally

##### Relationships & data flows
- Example/Test → depend on → PTSD Library
- PTSD Library (Util) → uses → Core Module interfaces
- Core Module → calls → OpenGL API
- AssetStore → loads → assets (audio, shaders, images)
- CMake → orchestrates → compile & link → produces → library + example + tests
- GitHub Actions → triggers → CMake build, run tests, generate docs
- Doxygen → consumes → source headers → produces → documentation

##### Architectural patterns & design principles
- Modular monolith (clear separation Core vs Util)
- Single codebase but split into reusable library + consumer (example/tests)
- Dependency injection via AssetStore and context objects
- Pipeline pattern in example: Input → Update → Render
- CI/CD pipeline for build, test, and docs

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Build System"
        CMake["CMake"]:::build
        CMakeModules["Dependencies.cmake"]:::build
    end

    subgraph "Continuous Integration"
        CI1["build.yml"]:::build
        CI2["check.yml"]:::build
        CI3["docs.yml"]:::build
        CI4["post.yml"]:::build
    end

    CMake -->|"configures builds"| PTSDLib
    CI1 -->|triggers| CMake
    CI2 -->|triggers| CMake
    CI3 -->|triggers| CMake
    CI4 -->|triggers| CMake

    subgraph "PTSD Library"
        subgraph Core
            Context["Context.hpp"]:::code
            Shader["Shader.hpp"]:::code
            Program["Program.hpp"]:::code
            VB["VertexBuffer.hpp"]:::code
            IB["IndexBuffer.hpp"]:::code
            VA["VertexArray.hpp"]:::code
            UB["UniformBuffer.hpp"]:::code
            Texture["Texture.hpp"]:::code
            TexUtil["TextureUtils.hpp"]:::code
            DebugCB["DebugMessageCallback.hpp"]:::code
        end
        subgraph Util
            AssetStore["AssetStore.hpp"]:::code
            Renderer["Renderer.hpp"]:::code
            GameObject["GameObject.hpp"]:::code
            Transform["Transform.hpp"]:::code
            TUtils["TransformUtils.hpp"]:::code
            Animation["Animation.hpp"]:::code
            Input["Input.hpp"]:::code
            Keycode["Keycode.hpp"]:::code
            BGM["BGM.hpp"]:::code
            SFX["SFX.hpp"]:::code
            TextUtil["Text.hpp"]:::code
            Image["Image.hpp"]:::code
            Logger["Logger.hpp"]:::code
            Time["Time.hpp"]:::code
            Color["Color.hpp"]:::code
            Position["Position.hpp"]:::code
            Base64["Base64.hpp"]:::code
            LoadText["LoadTextFile.hpp"]:::code
        end
    end

    subgraph "Example Application"
        ExampleApp["Example App"]:::consumer
    end

    Assets["assets/"]:::external

    subgraph "Tests"
        UnitTests["Unit Tests"]:::consumer
        InterTests["Interactive Tests"]:::consumer
    end

    subgraph "Documentation"
        DocsGen["Doxygen"]:::docs
        HTML["HTML Output"]:::docs
    end

    subgraph "External Dependencies"
        OpenGL["OpenGL"]:::external
        StdLib["C++ Standard Library"]:::external
        AudioBackend["Audio Backend"]:::external
    end

    ExampleApp -->|"links"| PTSDLib
    ExampleApp -->|"loads assets"| Assets
    UnitTests -->|"links"| PTSDLib
    InterTests -->|"links"| PTSDLib
    PTSDLib -->|"calls"| OpenGL
    PTSDLib -->|"links"| StdLib
    Util -->|"uses"| AudioBackend
    Assets -->|"loaded by"| AssetStore
    DocsGen -->|"consumes headers"| PTSDLib
    DocsGen -->|"produces"| HTML

    click CMake "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/CMakeLists.txt"
    click CMakeModules "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/cmake/Dependencies.cmake"
    click CI1 "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/.github/workflows/build.yml"
    click CI2 "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/.github/workflows/check.yml"
    click CI3 "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/.github/workflows/docs.yml"
    click CI4 "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/.github/workflows/post.yml"
    click Context "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Core/Context.hpp"
    click Shader "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Core/Shader.hpp"
    click Program "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Core/Program.hpp"
    click VB "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Core/VertexBuffer.hpp"
    click IB "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Core/IndexBuffer.hpp"
    click VA "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Core/VertexArray.hpp"
    click UB "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Core/UniformBuffer.hpp"
    click Texture "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Core/Texture.hpp"
    click TexUtil "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Core/TextureUtils.hpp"
    click DebugCB "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Core/DebugMessageCallback.hpp"
    click AssetStore "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Util/AssetStore.hpp"
    click Renderer "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Util/Renderer.hpp"
    click GameObject "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Util/GameObject.hpp"
    click Transform "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Util/Transform.hpp"
    click TUtils "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Util/TransformUtils.hpp"
    click Animation "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Util/Animation.hpp"
    click Input "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Util/Input.hpp"
    click Keycode "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Util/Keycode.hpp"
    click BGM "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Util/BGM.hpp"
    click SFX "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Util/SFX.hpp"
    click TextUtil "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Util/Text.hpp"
    click Image "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Util/Image.hpp"
    click Logger "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Util/Logger.hpp"
    click Time "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Util/Time.hpp"
    click Color "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Util/Color.hpp"
    click Position "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Util/Position.hpp"
    click Base64 "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Util/Base64.hpp"
    click LoadText "https://github.com/ntut-open-source-club/practical-tools-for-simple-design/blob/main/include/Util/LoadTextFile.hpp"

    classDef code fill:#B3CDE3,stroke:#6497B1,color:#03396C
    classDef consumer fill:#C7E9C0,stroke:#74C476,color:#238B45
    classDef build fill:#FDD0A2,stroke:#FC8D59,color:#D94801
    classDef external fill:#E0E0E0,stroke:#B0B0B0,color:#505050
    classDef docs fill:#DECBE4,stroke:#C994C7,color:#6A51A3
```
