# twohoursonelife/onelife architecture

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

- Interactive diagram: https://gitdiagram.com/twohoursonelife/onelife
- Repository: https://github.com/twohoursonelife/onelife

## Overview

##### Main Components Overview
The system should be divided into these primary components:

a) Client-Side Components:
- Game Client (in gameSource/)
- Data Editor Client (in gameSource/)
- User Interface Layer
- Graphics Engine
- Sound System
- Network Communication Layer

b) Server-Side Components:
- Game Server (in server/)
- Database Systems (Multiple DB types: KISSDB, LinearDB, StackDB)
- Player Management System
- Management System
- Life Token System
- Curse System
- Lineage System

c) Additional Services:
- Discord Integration (Authentication/Community)
- Stats Server
- Fitness Server
- Photo Server
- Curse Server
- Arc Server

##### Component Relationships

a) Primary Data Flow:
**Client <-> Network Layer <-> Game Server <-> Database Layer**

b) External Services Integration:
**Game Server <-> Additional Services (Discord, Stats, etc.)**

##### Architectural Patterns to Highlight

- Component-based architecture (evident in gameSource/ structure)
- Service-oriented architecture (for external services)
- Database abstraction layer (multiple DB implementations)
- Event-driven system (for game mechanics)

##### Key Technical Elements

a) Client Architecture:
- Graphics pipeline (SpriteBank, AnimationBank)
- Sound system (SoundBank, MusicPlayer)
- Input handling system

b) Server Architecture:
- Management system
- Player state management
- Database interactions
- External service communications

##### Specific Implementation Details

- External services (clouds)
- Client components (rounded rectangles)
- Server components (hexagons)

##### Important Subsystems

Specialized systems:
- Life token management
- Curse system
- Lineage tracking
- Player spawning mechanism
- Generation and management
- Community features

##### Cross-Cutting Concerns

Shared components:
- Configuration management
- Logging system
- Security features
- Build system
- Resource management

##### The build and deployment pipeline

This architecture reflects both the game's multiplayer nature and its focus on community-building features, which are central to 2HOL's design philosophy.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef client fill:#e1f5fe,stroke:#01579b
    classDef server fill:#fff3e0,stroke:#e65100
    classDef database fill:#f3e5f5,stroke:#4a148c,shape:cylinder
    classDef service fill:#e8f5e9,stroke:#1b5e20
    classDef system fill:#fbe9e7,stroke:#bf360c
    classDef ui fill:#f3e5f5,stroke:#4a148c
    
    subgraph ClientSide["Client-Side Components"]
        GameClient["Game Client"]:::client
        DataEditor["Data Editor"]:::client
        UI["User Interface"]:::ui
        Graphics["Graphics Engine"]:::client
        Sound["Sound System"]:::client
        Network["Network Layer"]:::client
        Animation["Animation System"]:::client
        Objects["Object Management"]:::client
        Discord["Discord Controller"]:::client
        Settings1["Settings Manager"]:::client
    end

    subgraph ServerSide["Server-Side Components"]
        GameServer["Game Server"]:::server
        PlayerMgmt["Player Management"]:::server
        MapMgmt["Map Management"]:::server
        LifeToken["Life Token System"]:::server
        CurseSystem["Curse System"]:::server
        LineageSystem["Lineage System"]:::server
        Language["Language System"]:::server
        Settings2["Settings Manager"]:::server
    end

    subgraph Databases["Database Layer"]
        KISSDB[(KISSDB)]:::database
        LinearDB[(LinearDB)]:::database
        StackDB[(StackDB)]:::database
    end

    subgraph ExternalServices["External Services"]
        StatsServer["Stats Server"]:::service
        FitnessServer["Fitness Server"]:::service
        PhotoServer["Photo Server"]:::service
        CurseServer["Curse Server"]:::service
        ArcServer["Arc Server"]:::service
        DiscordService["Discord Service"]:::service
    end

    %% Connections
    GameClient --> Network
    DataEditor --> Network
    Network --> GameServer
    GameServer --> PlayerMgmt
    GameServer --> MapMgmt
    GameServer --> LifeToken
    GameServer --> CurseSystem
    GameServer --> LineageSystem
    GameServer --> Language
    
    PlayerMgmt --> Databases
    MapMgmt --> Databases
    LifeToken --> Databases
    CurseSystem --> Databases
    LineageSystem --> Databases
    
    GameServer --> ExternalServices
    Discord --> DiscordService

    %% Component relationships
    GameClient --> UI
    GameClient --> Graphics
    GameClient --> Sound
    GameClient --> Animation
    GameClient --> Objects
    GameClient --> Discord
    GameClient --> Settings1
    GameServer --> Settings2

    %% Click events
    click GameClient "https://github.com/twohoursonelife/OneLife/blob/master/gameSource/game.cpp"
    click DataEditor "https://github.com/twohoursonelife/OneLife/blob/master/gameSource/editor.cpp"
    click UI "https://github.com/twohoursonelife/OneLife/blob/master/gameSource/PageComponent.cpp"
    click Graphics "https://github.com/twohoursonelife/OneLife/blob/master/gameSource/spriteBank.cpp"
    click Sound "https://github.com/twohoursonelife/OneLife/blob/master/gameSource/soundBank.cpp"
    click GameServer "https://github.com/twohoursonelife/OneLife/blob/master/server/server.cpp"
    click KISSDB "https://github.com/twohoursonelife/OneLife/blob/master/server/kissdb.cpp"
    click LinearDB "https://github.com/twohoursonelife/OneLife/blob/master/server/lineardb.cpp"
    click StackDB "https://github.com/twohoursonelife/OneLife/blob/master/server/stackdb.cpp"
    click MapMgmt "https://github.com/twohoursonelife/OneLife/blob/master/server/map.cpp"
    click LifeToken "https://github.com/twohoursonelife/OneLife/blob/master/server/lifeTokens.cpp"
    click CurseSystem "https://github.com/twohoursonelife/OneLife/blob/master/server/curses.cpp"
    click LineageSystem "https://github.com/twohoursonelife/OneLife/blob/master/server/lineageLog.cpp"
    click Discord "https://github.com/twohoursonelife/OneLife/blob/master/gameSource/DiscordController.cpp"
    click PlayerMgmt "https://github.com/twohoursonelife/OneLife/blob/master/server/playerStats.cpp"
    click Network "https://github.com/twohoursonelife/OneLife/blob/master/gameSource/serialWebRequests.cpp"
    click Animation "https://github.com/twohoursonelife/OneLife/blob/master/gameSource/animationBank.cpp"
    click Objects "https://github.com/twohoursonelife/OneLife/blob/master/gameSource/objectBank.cpp"
    click Settings1 "https://github.com/twohoursonelife/OneLife/tree/master/gameSource/settings/"
    click Settings2 "https://github.com/twohoursonelife/OneLife/tree/master/server/settings/"
    click Language "https://github.com/twohoursonelife/OneLife/blob/master/server/language.cpp"
```
