# the3dfxdude/7kaa architecture

> Architecture diagram of the GitHub repository the3dfxdude/7kaa, 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/the3dfxdude/7kaa
- Repository: https://github.com/the3dfxdude/7kaa

## Overview

##### Main Components

a. Core Game Engine Components:
- Game Logic Layer (OGAME.cpp and related files)
- Graphics Engine (OVGA.cpp, OVGABUF.cpp)
- Audio System (OpenAL implementation)
- Input System (OMOUSE.cpp)
- Resource Management (ORES.cpp)

b. Game Elements:
- Nations System (ONATION*.cpp)
- Unit Management (OUNIT*.cpp)
- Building System (OFIRM*.cpp)
- World/Map System (OWORLD*.cpp)
- AI System (OAI_*.cpp files)

c. Networking Layer:
- Multiplayer System (enet implementation)
- Web Services Integration (WebService.cpp)

##### Architectural Patterns to Highlight

- Component-based architecture (evident from the O* prefix naming convention)
- Resource management system (data/RESOURCE directory structure)
- Event-driven system for game updates
- Client-server model for multiplayer

**[User Interface Layer]**
- ↑↓
**[Game Logic Layer]**
- ↑↓
**[Core Systems Layer]**
- ↑↓
**[Resource/Data Layer]**

##### Key Relationships

- Data flow between resource files and game systems
- Communication paths between multiplayer components
- Interaction between AI systems and game state
- Resource loading pipeline
- Audio/Visual output flow

##### Implementation Details

- File format handlers (.ICN, .COL, etc.)
- Sound system integration (SOUND directory)
- Scenario management (SCENARIO directory)
- Encyclopedia system (ENCYC directory)

##### External Dependencies

Integration points with:
- SDL 2.24.0+
- enet networking
- OpenAL-soft
- libcurl (optional)

This system design should be drawn using standard UML notation where appropriate, but feel free to use custom notations where they better express the game's unique architecture. Keep the focus on the major systems while providing enough detail to understand the data flow and component interactions.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interface Layer"
        UI_Input["Input System"]:::input
        UI_Graphics["Graphics Engine"]:::graphics
        UI_Audio["Audio System"]:::audio
    end

    subgraph "Game Logic Layer"
        GL_Game["Game Logic"]:::gamelogic
        GL_Nations["Nations System"]:::gamelogic
        GL_Units["Unit Management"]:::gamelogic
        GL_Buildings["Building System"]:::gamelogic
        GL_World["World/Map System"]:::gamelogic
        GL_AI["AI System"]:::gamelogic
    end

    subgraph "Core Systems Layer"
        CS_Resource["Resource Management"]:::core
        CS_Network["Multiplayer System"]:::network
        CS_Web["Web Services"]:::network
    end

    subgraph "Resource/Data Layer"
        RD_Sound["Sound Resources"]:::resource
        RD_Sprite["Sprite Resources"]:::resource
        RD_Image["Image Resources"]:::resource
        RD_Scenario["Scenario Resources"]:::resource
        RD_Encyclopedia["Encyclopedia"]:::resource
        RD_Tutorial["Tutorials"]:::resource
    end

    subgraph "External Dependencies"
        EXT_SDL["SDL 2.24.0+"]:::external
        EXT_ENET["enet"]:::external
        EXT_OPENAL["OpenAL-soft"]:::external
        EXT_CURL["libcurl"]:::external
    end

    %% Connections
    UI_Input --> GL_Game
    UI_Graphics --> GL_Game
    UI_Audio --> GL_Game

    GL_Game --> GL_Nations
    GL_Game --> GL_Units
    GL_Game --> GL_Buildings
    GL_Game --> GL_World
    GL_Game --> GL_AI

    GL_Game --> CS_Resource
    GL_Game --> CS_Network
    CS_Network --> CS_Web

    CS_Resource --> RD_Sound
    CS_Resource --> RD_Sprite
    CS_Resource --> RD_Image
    CS_Resource --> RD_Scenario
    CS_Resource --> RD_Encyclopedia
    CS_Resource --> RD_Tutorial

    EXT_SDL --> UI_Graphics
    EXT_ENET --> CS_Network
    EXT_OPENAL --> UI_Audio
    EXT_CURL --> CS_Web

    %% Click Events
    click UI_Input "https://github.com/the3dfxdude/7kaa/blob/master/src/OMOUSE.cpp"
    click UI_Graphics "https://github.com/the3dfxdude/7kaa/blob/master/src/OVGA.cpp"
    click UI_Audio "https://github.com/the3dfxdude/7kaa/blob/master/src/openal/openal_audio.cpp"
    click GL_Game "https://github.com/the3dfxdude/7kaa/blob/master/src/OGAME.cpp"
    click GL_Nations "https://github.com/the3dfxdude/7kaa/blob/master/src/ONATIONA.cpp"
    click GL_Units "https://github.com/the3dfxdude/7kaa/blob/master/src/OUNIT.cpp"
    click GL_Buildings "https://github.com/the3dfxdude/7kaa/blob/master/src/OFIRM.cpp"
    click GL_World "https://github.com/the3dfxdude/7kaa/blob/master/src/OWORLD.cpp"
    click GL_AI "https://github.com/the3dfxdude/7kaa/blob/master/src/OAI_MAIN.cpp"
    click CS_Resource "https://github.com/the3dfxdude/7kaa/blob/master/src/ORES.cpp"
    click CS_Network "https://github.com/the3dfxdude/7kaa/blob/master/src/enet/multiplayer.cpp"
    click CS_Web "https://github.com/the3dfxdude/7kaa/blob/master/src/curl/WebService.cpp"
    click RD_Sound "https://github.com/the3dfxdude/7kaa/tree/master/data/SOUND/"
    click RD_Sprite "https://github.com/the3dfxdude/7kaa/tree/master/data/SPRITE/"
    click RD_Image "https://github.com/the3dfxdude/7kaa/tree/master/data/IMAGE/"
    click RD_Scenario "https://github.com/the3dfxdude/7kaa/tree/master/data/SCENARIO/"
    click RD_Encyclopedia "https://github.com/the3dfxdude/7kaa/tree/master/data/ENCYC/"
    click RD_Tutorial "https://github.com/the3dfxdude/7kaa/tree/master/data/TUTORIAL/"

    %% Styles
    classDef input fill:#9370DB
    classDef graphics fill:#4169E1
    classDef audio fill:#8A2BE2
    classDef gamelogic fill:#3CB371
    classDef core fill:#4682B4
    classDef network fill:#DC143C
    classDef resource fill:#DAA520
    classDef external fill:#808080

    %% Legend
    subgraph Legend
        L_Input["Input Systems"]:::input
        L_Graphics["Graphics Systems"]:::graphics
        L_Audio["Audio Systems"]:::audio
        L_GameLogic["Game Logic"]:::gamelogic
        L_Core["Core Systems"]:::core
        L_Network["Network Systems"]:::network
        L_Resource["Resources"]:::resource
        L_External["External Dependencies"]:::external
    end
```
