# xenepherth/networkzones architecture

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

- Interactive diagram: https://gitdiagram.com/xenepherth/networkzones
- Repository: https://github.com/xenepherth/networkzones

## Overview

##### Main System Components
- Network Manager (Core)
- Network Zones
- Zone Portals
- Persistence Layer
- Scene Management
- Player Management

##### Components (Use Rectangles)
- NetworkManager (Central)
- NetworkZone (Multiple instances)
- NetworkZonePortal
- DontDestroyOnLoad Components
- Scene References

- Active Zones (Green)
- Inactive Zones (Gray)
- Transition States (Yellow)

##### Data Flow
- Player Transfer
- Scene Loading
- State Synchronization

Special Considerations:

##### Multi-Process Architecture
- Separate process instances for different zones
- Server-only vs. client instances
- Inter-process communication

##### Persistence
- Database connections (SQLite/MySQL)
- Data synchronization between zones

##### Networking
- Network boundaries
- Client-server communication
- Potential future chat server integration

- Abbreviations
- Connection types
- Document process boundaries

Level of Detail:
- Keep high-level architecture visible
- Critical implementation details
- System boundaries
- Maintain clarity in component relationships

##### Player state management

Remember to indicate current limitations:
- Cross-zone chat functionality
- Database concurrency considerations
- Scene management dependencies

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core
        NM[Network Manager]
        DDL[DontDestroyOnLoad]:::persistence
        Canvas[Canvas]
        MiniMap[MinimapCamera]
    end

    subgraph "Zone Management"
        NZ[Network Zones]:::zones
        World1[World Zone]:::activeZone
        World2[World Zone 2]:::inactiveZone
        ZoneState[Zone State Sync]
    end

    subgraph "Portal System"
        Portal[Network Zone Portal]:::portal
        PortalState[Portal Management]
    end

    subgraph "Scene Management"
        SceneRef[Scene Reference]
        SceneLoad[Scene Loading]
        SceneUnload[Scene Unloading]
    end

    subgraph "Player Layer"
        PlayerMgmt[Player Management]:::player
        PlayerState[Player State]
        PlayerData[Player Data]
    end

    subgraph "Persistence"
        DB[(Database)]
        DataSync[Data Synchronization]
    end

    %% Core Connections
    NM --> DDL
    DDL --> Canvas
    DDL --> MiniMap

    %% Zone Management
    NM --> NZ
    NZ --> World1
    NZ --> World2
    NZ --> ZoneState

    %% Portal Connections
    NZ --> Portal
    Portal --> PortalState
    Portal -.-> World1
    Portal -.-> World2

    %% Scene Management
    NM --> SceneRef
    SceneRef --> SceneLoad
    SceneRef --> SceneUnload

    %% Player Management
    NM --> PlayerMgmt
    PlayerMgmt --> PlayerState
    PlayerMgmt --> PlayerData

    %% Persistence Layer
    PlayerData --> DB
    DB --> DataSync
    DataSync --> NZ

    %% Click Events
    click NZ "https://github.com/Xenepherth/NetworkZones/blob/main/NetworkZone.cs"
    click Portal "https://github.com/Xenepherth/NetworkZones/blob/main/NetworkZonePortal.cs"
    click PlayerMgmt "https://github.com/Xenepherth/NetworkZones/blob/main/NetworkZone.Player.cs"
    click DDL "https://github.com/Xenepherth/NetworkZones/blob/main/DontDestroyOnLoad.cs"

    %% Styles
    classDef zones fill:#3498db,stroke:#2980b9,color:white
    classDef portal fill:#e74c3c,stroke:#c0392b,color:white
    classDef activeZone fill:#2ecc71,stroke:#27ae60,color:white
    classDef inactiveZone fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef persistence fill:#9b59b6,stroke:#8e44ad,color:white
    classDef player fill:#f1c40f,stroke:#f39c12,color:black

    %% Legend
    subgraph Legend
        L1[Active Zone]:::activeZone
        L2[Inactive Zone]:::inactiveZone
        L3[Portal System]:::portal
        L4[Zone Management]:::zones
        L5[Player System]:::player
        L6[Persistence]:::persistence
    end
```
