# darkflameuniverse/darkflameserver architecture

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

- Interactive diagram: https://gitdiagram.com/darkflameuniverse/darkflameserver
- Repository: https://github.com/darkflameuniverse/darkflameserver

## Overview

##### Main Components Overview
The system consists of several key server components that should be represented as distinct blocks:

a. Server Components:
- AuthServer (Authentication)
- ChatServer (Chat services)
- MasterServer (Central coordination)
- WorldServer (Game world management)

b. Database Layer:
- Two database options:
- MariaDB/MySQL
- SQLite
- Both CDClient database and Game database

c. Core Systems:
- Entity Management
- Component System
- Networking Layer (RakNet)
- Game Systems (Missions, Inventory, etc.)

##### Architectural Patterns

- Use a layered architecture approach
- Clear separation between server components
- Database interactions
- Component-based game object system

##### Detailed Component Breakdown

Top Level:
**[Client] <---> [Auth Server] <---> [Master Server] <---> [World Server]**
- ^

- [Chat Server]

Database Layer:
**[Game Database]     [CDClient Database]**
- ^                    ^

**[Database Abstraction Layer]**

Game Systems:
**[Entity Manager]**
- ^

**[Component System] --- [Behaviors]**

**[Game Systems]**
- Inventory
- Missions
- Characters
- Combat
- etc.

##### Connection Types

Different types of connections:
- TCP/UDP connections (networking)
- Database connections
- Internal system communications
- Component relationships

##### Important Details

- Port numbers for different servers
- Database connection points
- File system interactions
- Client connection flow
- Authentication flow
- Game state management

##### Specific Implementation Notes

Notes for:
- RakNet implementation for networking
- Component-based architecture
- Database migration system
- Configuration management
- Script system integration

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Server Infrastructure"
        MS[MasterServer]
        AS[AuthServer]
        CS[ChatServer]
        WS[WorldServer]
    end

    subgraph "Database Layer"
        DB[Database System]
        MariaDB[MariaDB]
        SQLite[SQLite]
        DB --> MariaDB
        DB --> SQLite
    end

    subgraph "Game Systems"
        EM[Entity Manager]
        CS_[Component System]
        BS[Behavior System]
        MS_[Mission System]
        IS[Inventory System]
        ZM[Zone Manager]
    end

    subgraph "Network Layer"
        NL[Network Layer]
        Client[Client Connection]
    end

    %% Core Server Relationships
    Client --> AS
    AS --> MS
    MS --> WS
    MS --> CS
    
    %% Game Systems Relationships
    WS --> EM
    EM --> CS_
    CS_ --> BS
    WS --> MS_
    WS --> IS
    WS --> ZM
    
    %% Database Connections
    WS --> DB
    AS --> DB
    CS --> DB

    %% Network Layer
    NL --> MS
    NL --> AS
    NL --> CS
    NL --> WS

    %% Styling
    classDef server fill:#b3e0ff,stroke:#333,stroke-width:2px
    classDef database fill:#98FB98,stroke:#333,stroke-width:2px
    classDef game fill:#FFB366,stroke:#333,stroke-width:2px
    classDef network fill:#DDA0DD,stroke:#333,stroke-width:2px

    class MS,AS,CS,WS server
    class DB,MariaDB,SQLite database
    class EM,CS_,BS,MS_,IS,ZM game
    class NL,Client network

    %% Click Events
    click MS "https://github.com/DarkflameUniverse/DarkflameServer/tree/main/dMasterServer"
    click AS "https://github.com/DarkflameUniverse/DarkflameServer/tree/main/dAuthServer"
    click CS "https://github.com/DarkflameUniverse/DarkflameServer/tree/main/dChatServer"
    click WS "https://github.com/DarkflameUniverse/DarkflameServer/tree/main/dWorldServer"
    click DB "https://github.com/DarkflameUniverse/DarkflameServer/tree/main/dDatabase/GameDatabase"
    click MariaDB "https://github.com/DarkflameUniverse/DarkflameServer/tree/main/dDatabase/GameDatabase/MySQL"
    click SQLite "https://github.com/DarkflameUniverse/DarkflameServer/tree/main/dDatabase/GameDatabase/SQLite"
    click EM "https://github.com/DarkflameUniverse/DarkflameServer/blob/main/dGame/EntityManager.h"
    click CS_ "https://github.com/DarkflameUniverse/DarkflameServer/tree/main/dGame/dComponents"
    click BS "https://github.com/DarkflameUniverse/DarkflameServer/tree/main/dGame/dBehaviors"
    click MS_ "https://github.com/DarkflameUniverse/DarkflameServer/tree/main/dGame/dMission"
    click IS "https://github.com/DarkflameUniverse/DarkflameServer/tree/main/dGame/dInventory"
    click NL "https://github.com/DarkflameUniverse/DarkflameServer/tree/main/dNet"
    click ZM "https://github.com/DarkflameUniverse/DarkflameServer/tree/main/dZoneManager"

    %% Legend
    subgraph Legend
        L1[Server Components]:::server
        L2[Database Systems]:::database
        L3[Game Systems]:::game
        L4[Network Components]:::network
    end
```
