# zhang123dz/tower-defense architecture

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

- Interactive diagram: https://gitdiagram.com/zhang123dz/tower-defense
- Repository: https://github.com/zhang123dz/tower-defense

## Overview

##### Project type and purpose
- From the file tree and CMakeLists, this is a native C++ desktop game (a “TowerDefense” game) that uses SDL3 for windowing, input, rendering, audio, etc.
- It is not a web stack or microservice but a single-process real-time application/game.

##### File structure
- Top‐level:
- CMakeLists.txt – build orchestration
- src/main.cpp – entry point and game loop
- /SDL3, include/SDL3_image, include/SDL3_mixer, include/SDL3_ttf – bundled SDL3 headers
- lib/cmake & lib/pkgconfig – SDL3 CMake config and pkgconfig files
- lib/libSDL3_test.a – SDL3 test library
- build/ – auto‐generated build artifacts and the TowerDefense.exe
- Pattern:
- External dependencies (SDL3) are vendored under include/ and lib/
- Single‐binary architecture: code and assets link into one executable
- Standard game‐engine layering implied by SDL (input/render/audio)

##### README
- (No content provided, so we infer from file structure and naming: a Tower Defense game built in C++ using SDL3)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build Layer
    subgraph "Build Layer"
        CMake["CMake (CMakeLists.txt)"]:::build
        Compiler["Compiler & Linker"]:::build
        Executable["TowerDefense.exe"]:::build
    end

    %% Game Engine Layer
    subgraph "Game Engine Layer"
        Entry["Main Loop"]:::subsystem
        Input["Input Manager"]:::subsystem
        Logic["Game Logic"]:::subsystem
        Render["Rendering Engine"]:::subsystem
        Audio["Audio Engine"]:::subsystem
        Resource["Resource Loader"]:::subsystem
    end

    %% External Libraries
    subgraph "External Libraries"
        SDLcore["SDL3 Core"]:::external
        SDLimg["SDL_image"]:::external
        SDLmix["SDL_mixer"]:::external
        SDLttf["SDL_ttf"]:::external
        SDLcmake["SDL3 CMake Config"]:::external
        SDLpkg["SDL3 pkg-config"]:::external
        SDLcoreBin["SDL3 Core Lib"]:::external
    end

    %% OS / Hardware Layer
    subgraph "OS / Hardware"
        OSInput["OS Input Events"]:::os
        OSGraphics["OS Graphics Driver"]:::os
        OSAudio["OS Audio Driver"]:::os
        FileSystem["File System"]:::os
    end

    %% Build Flow
    CMake --> Compiler --> Executable
    Executable --> Entry

    %% Runtime Flow
    OSInput --> SDLcore --> Input --> Logic
    Logic --> Render --> SDLcore --> OSGraphics
    Logic --> Audio --> SDLmix --> OSAudio
    Logic --> Resource --> SDLimg --> FileSystem
    Logic --> Resource --> SDLttf --> FileSystem

    %% Linking to external libs
    Executable --> SDLcoreBin
    Executable --> SDLcmake
    Executable --> SDLpkg

    %% Click Events
    click CMake "https://github.com/zhang123dz/tower-defense/blob/main/CMakeLists.txt"
    click Executable "https://github.com/zhang123dz/tower-defense/blob/main/build/TowerDefense.exe"
    click Entry "https://github.com/zhang123dz/tower-defense/blob/main/src/main.cpp"
    click Input "https://github.com/zhang123dz/tower-defense/blob/main/include/SDL3/SDL_events.h"
    click Render "https://github.com/zhang123dz/tower-defense/blob/main/include/SDL3/SDL_gpu.h"
    click Render "https://github.com/zhang123dz/tower-defense/blob/main/include/SDL3/SDL_render.h"
    click Audio "https://github.com/zhang123dz/tower-defense/blob/main/include/SDL3_mixer/SDL_mixer.h"
    click Resource "https://github.com/zhang123dz/tower-defense/blob/main/include/SDL3_image/SDL_image.h"
    click Resource "https://github.com/zhang123dz/tower-defense/blob/main/include/SDL3_ttf/SDL_ttf.h"
    click SDLcore "https://github.com/zhang123dz/tower-defense/blob/main/include/SDL3/SDL.h"
    click SDLcoreBin "https://github.com/zhang123dz/tower-defense/blob/main/lib/libSDL3_test.a"
    click SDLcmake "https://github.com/zhang123dz/tower-defense/blob/main/lib/cmake/SDL3/SDL3Config.cmake"
    click SDLpkg "https://github.com/zhang123dz/tower-defense/blob/main/lib/pkgconfig/sdl3.pc"

    %% Styles
    classDef build fill:#cccccc,stroke:#333,stroke-width:1px;
    classDef subsystem fill:#bbdefb,stroke:#1e88e5,stroke-width:1px;
    classDef external fill:#c8e6c9,stroke:#2e7d32,stroke-width:1px;
    classDef os fill:#ffe0b2,stroke:#ef6c00,stroke-width:1px;
```
