# novum/vkquake architecture

> Architecture diagram of the GitHub repository novum/vkquake, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/novum/vkquake
- Repository: https://github.com/novum/vkquake

## Overview

##### Main Components Identification
The system should be divided into these major components:

a. Core Engine Components:
- Rendering System (Vulkan-based)
- Sound System
- Input System
- Network System
- Physics Engine
- Resource Management
- Game Logic

b. Platform-Specific Components:
- SDL2 Integration Layer
- Operating System Interfaces
- File System

##### Key Architectural Elements

a. Rendering Pipeline:
- Vulkan Implementation (gl_vidsdl.c)
- Shader Management (Shaders/ directory)
- Model/Texture Management
- Post-processing Effects

b. Audio Pipeline:
- Multiple Codec Support (FLAC, MP3, Opus, Vorbis)
- Sound Mixing System
- Music Playback System

c. Game Systems:
- Client/Server Architecture
- Physics and Collision
- Entity Management
- Resource Loading

**┌─────────────────────────────────────────────┐**
- Game Interface                 │
- (menu.c, console.c, cl_main.c, host.c)    │
- ┤
- Core Engine Systems               │
- ┬──────────────┬──────────────┤
- Renderer   │    Audio     │    Input     │
- (Vulkan)    │  (SDL_audio) │  (SDL_input) │
- ┴──────────────┴──────────────┤
- Platform Abstraction Layer          │
- (SDL2, sys_*.c)                │
- ┤
- Operating System Interface          │
- ┘

##### Component Relationships

Key interactions:
- Data flow between renderer and resource management
- Audio system integration with game events
- Network communication paths
- Input processing chain
- Resource loading and management flows

##### Special Features to Highlight

- Multithreaded rendering system
- Dynamic shadow ray tracing
- Mod support architecture
- Custom protocol improvements
- Shader pipeline for various effects

##### Technical Details

- Vulkan rendering pipeline stages
- Sound mixing and codec pipeline
- Network protocol flow
- Resource management system
- Threading model

##### Implementation Notes

- The modular architecture allowing for mod support
- The separation between platform-specific and core code
- The integration of modern features while maintaining compatibility
- The optimization systems for improved performance

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style definitions
    classDef core fill:#2b6cb0,stroke:#1a4971,color:white
    classDef platform fill:#2f855a,stroke:#1f5c3d,color:white
    classDef external fill:#718096,stroke:#4a5568,color:white
    classDef ui fill:#6b46c1,stroke:#553c9a,color:white
    classDef critical fill:#c53030,stroke:#9b2c2c,color:white

    subgraph GameInterface
        UI["User Interface"]:::ui
        click UI "https://github.com/Novum/vkQuake/blob/master/Quake/menu.c"
        Console["Console System"]:::ui
        click Console "https://github.com/Novum/vkQuake/blob/master/Quake/console.c"
        StatusBar["Status Bar"]:::ui
        click StatusBar "https://github.com/Novum/vkQuake/blob/master/Quake/sbar.c"
    end

    subgraph CoreSystems
        Host["Host System"]:::core
        click Host "https://github.com/Novum/vkQuake/blob/master/Quake/host.c"
        Client["Client System"]:::core
        click Client "https://github.com/Novum/vkQuake/blob/master/Quake/cl_main.c"
        Server["Server System"]:::core
        click Server "https://github.com/Novum/vkQuake/blob/master/Quake/sv_main.c"
        World["World Management"]:::core
        click World "https://github.com/Novum/vkQuake/blob/master/Quake/world.c"
    end

    subgraph RenderingSystem
        VulkanRenderer["Vulkan Renderer"]:::core
        click VulkanRenderer "https://github.com/Novum/vkQuake/blob/master/Quake/gl_vidsdl.c"
        ShaderMgmt["Shader Management"]:::core
        click ShaderMgmt "https://github.com/Novum/vkQuake/tree/master/Shaders/"
        TextureMgmt["Texture Management"]:::core
        click TextureMgmt "https://github.com/Novum/vkQuake/blob/master/Quake/gl_texmgr.c"
        ModelSystem["Model System"]:::core
        click ModelSystem "https://github.com/Novum/vkQuake/blob/master/Quake/gl_model.c"
        Lighting["Lighting System"]:::core
        click Lighting "https://github.com/Novum/vkQuake/blob/master/Quake/gl_rlight.c"
    end

    subgraph AudioSystem
        SoundMixer["Sound Mixer"]:::core
        click SoundMixer "https://github.com/Novum/vkQuake/blob/master/Quake/snd_mix.c"
        SoundMemory["Sound Memory"]:::core
        click SoundMemory "https://github.com/Novum/vkQuake/blob/master/Quake/snd_mem.c"
        CodecSystem["Codec System"]:::core
        click CodecSystem "https://github.com/Novum/vkQuake/blob/master/Quake/snd_codec.c"
        DMASound["DMA Sound"]:::core
        click DMASound "https://github.com/Novum/vkQuake/blob/master/Quake/snd_dma.c"
    end

    subgraph InputSystem
        SDLInput["SDL Input"]:::platform
        click SDLInput "https://github.com/Novum/vkQuake/blob/master/Quake/in_sdl.c"
        KeySystem["Key System"]:::core
        click KeySystem "https://github.com/Novum/vkQuake/blob/master/Quake/keys.c"
        ClientInput["Client Input"]:::core
        click ClientInput "https://github.com/Novum/vkQuake/blob/master/Quake/cl_input.c"
    end

    subgraph NetworkSystem
        NetMain["Network Main"]:::core
        click NetMain "https://github.com/Novum/vkQuake/blob/master/Quake/net_main.c"
        UDP["UDP System"]:::core
        click UDP "https://github.com/Novum/vkQuake/blob/master/Quake/net_udp.c"
        Datagram["Datagram System"]:::core
        click Datagram "https://github.com/Novum/vkQuake/blob/master/Quake/net_dgrm.c"
        LoopBack["Loopback System"]:::core
        click LoopBack "https://github.com/Novum/vkQuake/blob/master/Quake/net_loop.c"
    end

    subgraph PhysicsSystem
        Physics["Physics Engine"]:::core
        click Physics "https://github.com/Novum/vkQuake/blob/master/Quake/sv_phys.c"
        Movement["Movement System"]:::core
        click Movement "https://github.com/Novum/vkQuake/blob/master/Quake/sv_move.c"
    end

    subgraph PlatformLayer
        SDL["SDL2 System"]:::platform
        click SDL "https://github.com/Novum/vkQuake/tree/master/Windows/SDL2/"
        SysSDL["System SDL"]:::platform
        click SysSDL "https://github.com/Novum/vkQuake/blob/master/Quake/sys_sdl.c"
        Unix["Unix System"]:::platform
        click Unix "https://github.com/Novum/vkQuake/blob/master/Quake/sys_sdl_unix.c"
        Windows["Windows System"]:::platform
        click Windows "https://github.com/Novum/vkQuake/blob/master/Quake/sys_sdl_win.c"
    end

    %% Connections
    GameInterface --> CoreSystems
    CoreSystems --> RenderingSystem
    CoreSystems --> AudioSystem
    CoreSystems --> InputSystem
    CoreSystems --> NetworkSystem
    CoreSystems --> PhysicsSystem
    
    RenderingSystem --> PlatformLayer
    AudioSystem --> PlatformLayer
    InputSystem --> PlatformLayer
    NetworkSystem --> PlatformLayer

    %% Legend
    classDef legend fill:none,stroke:none
    subgraph Legend
        L1["Core Components"]:::core
        L2["Platform-Specific"]:::platform
        L3["External Dependencies"]:::external
        L4["User Interface"]:::ui
        L5["Critical Path"]:::critical
    end
```
