# xonotic/xonotic architecture

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

- Interactive diagram: https://gitdiagram.com/xonotic/xonotic
- Repository: https://github.com/xonotic/xonotic

## Overview

##### Main Components

a. Core Game Engine Layer:
- DarkPlaces engine (indicated by the engine-specific files in the tree)
- Rendering system
- Physics engine (indicated by ODE library files)
- Sound system (indicated by Vorbis/OGG files)

b. Resource Management Layer:
- PK3 directory system (shown by .pk3dir folders)
- Asset management (fonts, textures, models)
- Compilation system

c. Networking Layer:
- Server component (shown by server/ directory)
- Client component
- RCON interface (shown by rcon2irc/)

d. Tools and Utilities:
- Compilation tools
- Demo recording system (NexuizDemoRecorder)
- Development tools (ImgToMap, ObjToMap)

##### Relationships and Data Flow

- Client-Server communication
- Resource loading paths
- Tool integration points
- Build system flow

##### Specific Implementation Details

- Configuration management (server.cfg, etc.)
- Build system (CMake files)
- Plugin architecture
- Asset pipeline

##### External Dependencies

Connections to:
- Graphics libraries (OpenGL)
- Audio libraries (Vorbis/OGG)
- Physics engine (ODE)
- Network stack

##### Development Infrastructure

Include:
- Build automation
- Continuous integration
- Resource compilation pipeline

**[Development Tools Layer]**
- ↕
**[Resource Management Layer]**
- ↕
**[Core Engine Layer]**
- ↕
**[Network Layer]**
- ↕
**[External Dependencies Layer]**

Key Considerations:

##### Modular nature of the system
- Clear separation between engine, game logic, and tools
- Plugin architecture
- Demonstrate resource management independence

##### Build and deployment flow
- How resources are compiled and packaged
- Development to release pipeline
- CI/CD integration points

##### Cross-platform aspects
- Platform-specific components
- Shared codebase elements
- Platform-specific build paths

##### Document tool integration
- How development tools connect to the main system
- Data flow for asset creation and management
- Points of developer interaction

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Development
        Tools[Development Tools]
        DemoRec[Demo Recorder]:::tool
        MapTools[Map Tools]:::tool
        ObjConv[Object Converter]:::tool
        MapComp[Map Compiler]:::tool
        BuildSystem[Build System]:::build
    end

    subgraph Resources
        PK3[PK3 Directory System]:::resource
        Assets[Asset Management]:::resource
        Fonts[Font Resources]:::resource
        Maps[Map Resources]:::resource
    end

    subgraph CoreEngine
        DarkPlaces[DarkPlaces Engine]:::core
        Render[Rendering System]:::core
        Physics[Physics Engine]:::core
        Sound[Sound System]:::core
    end

    subgraph Network
        Server[Server Component]:::network
        Client[Client Component]:::network
        RCON[RCON Interface]:::network
    end

    subgraph External
        OpenGL[OpenGL]:::external
        ODE[ODE Library]:::external
        Vorbis[Vorbis/OGG]:::external
        Network[Network Stack]:::external
    end

    %% Development Tools Relationships
    Tools --> DemoRec
    Tools --> MapTools
    Tools --> ObjConv
    Tools --> MapComp
    Tools --> BuildSystem

    %% Resource Management Relationships
    PK3 --> Assets
    PK3 --> Fonts
    PK3 --> Maps

    %% Core Engine Relationships
    DarkPlaces --> Render
    DarkPlaces --> Physics
    DarkPlaces --> Sound

    %% Network Relationships
    Server --> RCON
    Server --> Client

    %% Cross-Layer Relationships
    Resources --> CoreEngine
    CoreEngine --> Network
    CoreEngine --> External
    Development --> Resources

    %% External Dependencies
    Render --> OpenGL
    Physics --> ODE
    Sound --> Vorbis
    Network --> Network

    %% Click Events
    click Physics "https://github.com/xonotic/xonotic/blob/master/misc/buildfiles/osx/Xonotic.app/Contents/MacOS/libode.dylib"
    click Sound "https://github.com/xonotic/xonotic/blob/master/misc/buildfiles/osx/Xonotic.app/Contents/MacOS/libvorbis.dylib"
    click PK3 "https://github.com/xonotic/xonotic/tree/master/data/"
    click Fonts "https://github.com/xonotic/xonotic/tree/master/data/font-dejavu.pk3dir/"
    click Server "https://github.com/xonotic/xonotic/tree/master/server/"
    click RCON "https://github.com/xonotic/xonotic/tree/master/server/rcon2irc/"
    click DemoRec "https://github.com/xonotic/xonotic/tree/master/misc/tools/NexuizDemoRecorder/"
    click MapTools "https://github.com/xonotic/xonotic/tree/master/misc/tools/ImgToMap/"
    click ObjConv "https://github.com/xonotic/xonotic/tree/master/misc/tools/ObjToMap/"
    click MapComp "https://github.com/xonotic/xonotic/tree/master/misc/tools/xonotic-map-compiler"
    click BuildSystem "https://github.com/xonotic/xonotic/tree/master/misc/buildfiles/"

    %% Styling
    classDef core fill:#2374ab
    classDef resource fill:#47a025
    classDef network fill:#d62839
    classDef tool fill:#f77f00
    classDef external fill:#666
    classDef build fill:#9c6644

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Resource Management]:::resource
        L3[Network Components]:::network
        L4[Development Tools]:::tool
        L5[External Dependencies]:::external
        L6[Build System]:::build
    end
```
