# smcameron/space-nerds-in-space architecture

> Architecture diagram of the GitHub repository smcameron/space-nerds-in-space, 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/smcameron/space-nerds-in-space
- Repository: https://github.com/smcameron/space-nerds-in-space

## Overview

##### Main Components

a. Core Server Components:
- Lobby Server (handles client-server discovery)
- Multiverse Server (manages player ship data across systems)
- Game Server (manages individual solar system instances)
- Server Tracker (coordinates multiple server instances)

b. Client Components:
- Main Game Client
- Limited Client (non-OpenGL version)
- Multiple Bridge Stations:
- Navigation
- Weapons
- Engineering
- Damage Control
- Communications
- Science
- Game Master

c. Asset Management:
- 3D Models
- Textures
- Sounds
- Shaders
- Solar System Configurations

d. Scripting System:
- Lua Script Engine
- Mission Scripts
- Interactive Fiction System

##### Component Relationships

- Clients ←→ Lobby Server (initial connection)
- Lobby Server ←→ Game Servers (registration)
- Clients ←→ Game Server (gameplay)
- Game Servers ←→ Multiverse Server (ship data sync)
- Lua Script Engine ←→ Game Server (mission control)

##### Technical Implementation Details

Specialized subsystems:
**Network Layer:**
- Socket I/O (snis_socket_io)
- Protocol Handling (snis_packet.h)
- Bridge Updates (snis_bridge_update_packet)

**Graphics Pipeline:**
- OpenGL Rendering
- Shader Management
- Model Loading
- Texture Handling

**Audio System:**
- Voice Chat
- Sound Effects
- Text-to-Speech

**Top Layer:**
- Client Applications
- User Interface Components

**Middle Layer:**
- Network Communication
- Game Logic
- Physics Engine

**Bottom Layer:**
- Asset Management
- Data Storage
- System Configuration

##### Additional Elements

Annotations for:
- Network protocols and data flow
- Asset loading paths
- Bridge station interactions
- Solar system instance management
- Voice chat and audio routing

##### Implementation Notes

- The distributed nature of the system
- Real-time networking requirements
- Multiple bridge station coordination
- Asset management and loading
- Mission scripting integration

This system design should reflect SNIS's architecture as a multiplayer space simulation game with multiple coordinated interfaces and real-time networking requirements.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef server fill:#b3d1ff,stroke:#333
    classDef client fill:#90EE90,stroke:#333
    classDef network fill:#FFE5B4,stroke:#333
    classDef asset fill:#FFA07A,stroke:#333
    classDef script fill:#DDA0DD,stroke:#333
    classDef core fill:#FF6B6B,stroke:#333
    classDef audio fill:#98FB98,stroke:#333
    classDef graphics fill:#87CEEB,stroke:#333

    subgraph ServerLayer["Server Components"]
        LS["Lobby Server"]:::server
        MS["Multiverse Server"]:::server
        GS["Game Server"]:::server
        ST["Server Tracker"]:::server
    end

    subgraph ClientLayer["Client Components"]
        MC["Main Game Client"]:::client
        subgraph Stations["Bridge Stations"]
            NAV["Navigation"]:::client
            WEP["Weapons"]:::client
            ENG["Engineering"]:::client
            DMG["Damage Control"]:::client
            COM["Communications"]:::client
            SCI["Science"]:::client
            GM["Game Master"]:::client
        end
    end

    subgraph NetworkLayer["Network Layer"]
        SIO["Socket I/O"]:::network
        PH["Protocol Handler"]:::network
        BU["Bridge Updates"]:::network
    end

    subgraph AssetLayer["Asset Management"]
        Models["3D Models"]:::asset
        Tex["Textures"]:::asset
        Sounds["Sounds"]:::asset
        Shaders["Shaders"]:::asset
        SysCfg["Solar System Configs"]:::asset
    end

    subgraph ScriptLayer["Scripting System"]
        LSE["Lua Script Engine"]:::script
        MS_["Mission Scripts"]:::script
        IFS["Interactive Fiction System"]:::script
    end

    subgraph GraphicsLayer["Graphics Pipeline"]
        OGL["OpenGL Rendering"]:::graphics
        SM["Shader Management"]:::graphics
    end

    subgraph AudioLayer["Audio System"]
        VC["Voice Chat"]:::audio
        SFX["Sound Effects"]:::audio
        TTS["Text-to-Speech"]:::audio
    end

    %% Connections
    MC --> SIO
    LS --> SIO
    GS --> SIO
    MS --> SIO
    
    LSE --> GS
    MS_ --> LSE
    IFS --> LSE
    
    MC --> OGL
    OGL --> SM
    SM --> Shaders
    
    MC --> VC
    MC --> SFX
    MC --> TTS

    %% Click events
    click LS "https://github.com/smcameron/space-nerds-in-space/blob/master/ssgl/ssgl_server.c"
    click MS "https://github.com/smcameron/space-nerds-in-space/blob/master/snis_multiverse.c"
    click GS "https://github.com/smcameron/space-nerds-in-space/blob/master/snis_server.c"
    click ST "https://github.com/smcameron/space-nerds-in-space/blob/master/snis_server_tracker.c"
    click MC "https://github.com/smcameron/space-nerds-in-space/blob/master/snis_client.c"
    click NAV "https://github.com/smcameron/space-nerds-in-space/blob/master/help_text_nav_screen.txt"
    click WEP "https://github.com/smcameron/space-nerds-in-space/blob/master/help_text_weapons_screen.txt"
    click ENG "https://github.com/smcameron/space-nerds-in-space/blob/master/help_text_engineering_screen.txt"
    click DMG "https://github.com/smcameron/space-nerds-in-space/blob/master/help_text_damage_control_screen.txt"
    click COM "https://github.com/smcameron/space-nerds-in-space/blob/master/help_text_comms_screen.txt"
    click SCI "https://github.com/smcameron/space-nerds-in-space/blob/master/help_text_science_screen.txt"
    click Models "https://github.com/smcameron/space-nerds-in-space/tree/master/share/snis/models/"
    click Tex "https://github.com/smcameron/space-nerds-in-space/tree/master/share/snis/textures/"
    click Sounds "https://github.com/smcameron/space-nerds-in-space/tree/master/share/snis/sounds/"
    click Shaders "https://github.com/smcameron/space-nerds-in-space/tree/master/share/snis/shader/"
    click MS_ "https://github.com/smcameron/space-nerds-in-space/tree/master/share/snis/luascripts/MISSIONS/"
    click IFS "https://github.com/smcameron/space-nerds-in-space/blob/master/share/snis/luascripts/MISSIONS/lib/interactive_fiction.lua"
    click SIO "https://github.com/smcameron/space-nerds-in-space/blob/master/snis_socket_io.c"
    click PH "https://github.com/smcameron/space-nerds-in-space/blob/master/snis_packet.h"
    click BU "https://github.com/smcameron/space-nerds-in-space/blob/master/snis_bridge_update_packet.c"
    click OGL "https://github.com/smcameron/space-nerds-in-space/blob/master/graph_dev_opengl.c"
    click SM "https://github.com/smcameron/space-nerds-in-space/blob/master/shader.c"
    click VC "https://github.com/smcameron/space-nerds-in-space/blob/master/snis_voice_chat.c"
```
