# dorukkicikoglu/bga-ninjan architecture

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

- Interactive diagram: https://gitdiagram.com/dorukkicikoglu/bga-ninjan
- Repository: https://github.com/dorukkicikoglu/bga-ninjan

## Overview

##### Project Type and Purpose
- Project Type: This is a game implementation for BoardGameArena (BGA) – a platform for online board games.
- Purpose: Implementing the rules, game state management, and client interactions for the “Ninjan” game on BoardGameArena.
- Key indicators include the README (which directly references Ninjan on boardgamearena.com) and the file structure with game configuration files (gameinfos.inc.php, gamepreferences.json) and separate modules for game logic.

##### File Structure to Determine Architectural Components
- Server-Side Game Logic:
- PHP files (ninjan.game.php, ninjan.action.php, states.inc.php, version.php) form the backbone of game state management.
- The “modules” directory contains submodules (e.g., NJNGlobalsManager.php, NJNHandManager.php, etc.) that modularize game functionalities.
- Game configuration is split across multiple files (gameinfos.inc.php, gameoptions.json, gamepreferences.json), which likely determine game rules and settings.
- Client-Side/Visual Components:
- Assets such as ninjan.js, ninjan.css, and a template file (ninjan_ninjan.tpl) represent the view layer.
- The “src” directory includes Typescript files (for animations, UI handlers, etc.), signifying richer client-side interactivity.
- Additional styling (ninjan.scss and src/ninjan.scss) and image resources (in img and misc directories) support the UI.
- Data and Asset Resources:
- The dbmodel.sql file shows that a database is involved to store game data or logs.
- Assets and media files (images, PSD files) indicate visual design components integrated within the game.

##### README File for Additional Context
- The README confirms that this is a BGA game implementation for Ninjan.
- While minimal, this README directs you to the BoardGameArena game panel which implies adherence to BGA’s integration patterns.
- This suggests that the architecture should model how game state and interactions are handled both on the server and client, as per BGA standards.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Layer
    subgraph "External Layer"
        A["BoardGameArena Platform"]:::external
    end

    %% Client Layer
    subgraph "Client Layer"
        B["Client UI (Browser)"]:::client
        subgraph "Client Files"
            B1["ninjan.js"]:::client
            B2["ninjan.css"]:::client
            B3["ninjan_ninjan.tpl"]:::client
            B4["src (TypeScript)"]:::client
        end
    end

    %% Server Layer
    subgraph "Server Layer"
        C["Game Engine (PHP)"]:::server
        subgraph "Server Files"
            C1["ninjan.game.php"]:::server
            C2["ninjan.action.php"]:::server
            C3["states.inc.php"]:::server
            C4["version.php"]:::server
        end
        D["Modular Game Logic Components"]:::server
        subgraph "Game Configuration"
            E1["gameinfos.inc.php"]:::config
            E2["gamepreferences.json"]:::config
            E3["gameoptions.json"]:::config
        end
    end

    %% Data Layer
    subgraph "Data Layer"
        F1["dbmodel.sql"]:::data
        F2["stats.json"]:::data
        subgraph "Assets & Resources"
            G1["img"]:::data
            G2["misc"]:::data
        end
    end

    %% Inter-layer Connections
    A -->|"sessionMgmt"| B
    B -->|"APIcalls"| C
    C -->|"invokes"| D
    C -->|"loadsConfig"| E1
    C -->|"dbAccess"| F1
    B -->|"loadsMedia"| G1
    B -->|"loadsMedia"| G2

    %% Internal Connections in Client Files
    B --> B1
    B1 --> B2
    B2 --> B3
    B3 --> B4

    %% Internal Connections in Server Files
    C --> C1
    C1 --> C2
    C2 --> C3
    C3 --> C4

    %% Click Events for Client-Side / UI Rendering
    click B1 "https://github.com/dorukkicikoglu/bga-ninjan/blob/main/ninjan.js"
    click B2 "https://github.com/dorukkicikoglu/bga-ninjan/blob/main/ninjan.css"
    click B3 "https://github.com/dorukkicikoglu/bga-ninjan/blob/main/ninjan_ninjan.tpl"
    click B4 "https://github.com/dorukkicikoglu/bga-ninjan/tree/main/src"

    %% Click Events for Server-Side Game Logic
    click C1 "https://github.com/dorukkicikoglu/bga-ninjan/blob/main/ninjan.game.php"
    click C2 "https://github.com/dorukkicikoglu/bga-ninjan/blob/main/ninjan.action.php"
    click C3 "https://github.com/dorukkicikoglu/bga-ninjan/blob/main/states.inc.php"
    click C4 "https://github.com/dorukkicikoglu/bga-ninjan/blob/main/version.php"

    %% Click Event for Modular Game Logic Components
    click D "https://github.com/dorukkicikoglu/bga-ninjan/tree/main/modules/php"

    %% Click Events for Game Configuration
    click E1 "https://github.com/dorukkicikoglu/bga-ninjan/blob/main/gameinfos.inc.php"
    click E2 "https://github.com/dorukkicikoglu/bga-ninjan/blob/main/gamepreferences.json"
    click E3 "https://github.com/dorukkicikoglu/bga-ninjan/blob/main/gameoptions.json"

    %% Click Events for Data Storage
    click F1 "https://github.com/dorukkicikoglu/bga-ninjan/blob/main/dbmodel.sql"
    click F2 "https://github.com/dorukkicikoglu/bga-ninjan/blob/main/stats.json"

    %% Click Events for Asset and Resource Management
    click G1 "https://github.com/dorukkicikoglu/bga-ninjan/tree/main/img"
    click G2 "https://github.com/dorukkicikoglu/bga-ninjan/tree/main/misc"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef server fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef config fill:#FFFACD,stroke:#333,stroke-width:2px;
    classDef data fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#333,stroke-width:2px;
```
