# guinhx/bomb-me architecture

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

- Interactive diagram: https://gitdiagram.com/guinhx/bomb-me
- Repository: https://github.com/guinhx/bomb-me

## Overview

- A REST API and authentication layer implemented in bomb-me-api (using NestJS and TypeScript) that provides endpoints for features like simulated OTP login, static server list and news, and initial game stage operations.
- A game-server written in TypeScript that handles gameplay logic, room/arena management, network protocols, and game sessions. This module includes subdirectories for network communications, core utilities, database migrations, command processing, and game logic.
- A crypt module that serves as a tool for encrypting and decrypting the game’s LUA code. This utility includes many LUA mission definitions and additional core scripts as well as a Node.js script (index.js) that is invoked via command-line to encrypt or decrypt files.
- Assets and UI resources that include compiled UI files (possibly generated from .plist and graphical assets) and a supporting APK editor (apkeditor.jar) suggesting that mobile client packaging is part of the workflow.

- Mobile / Game Client and Assets: Represent the game’s UI assets, compiled resources (assets, assets/compiled_ui, assets/ui) and any client-side packages.
- bomb-me-api: The Node.js/NestJS-based REST API layer which handles user authentication (simulated OTP), static screens (news and server list), and game initialization endpoints.
- game-server: The backend “game logic” server responsible for handling game sessions, network traffic, room management, and real-time gameplay operations. Include submodules such as network (TCP server, packet processing), game session management, logging, and database interaction.
- Crypt / Encryption Tool: A utility component used for encryption/decryption of LUA scripts (which include many mission definitions and AI components) for the game.
- External Tools: For example, the apkeditor.jar and the reference to GD Splitter for editing plist assets – these can be indicated as external artifact tools that interact with the project workflow.

##### Relationships and data flows
- Mobile clients (or the game client UI) communicate with bomb-me-api for authentication and news updates, receiving static data (like the server list).
- Bomb-me-api may serve as the front-facing entry point to the backend, with client requests directed there via HTTP/HTTPS.
- Game-server modules then handle more interactive, real-time game sessions. Although not necessarily directly connected to bomb-me-api, they share common resources (such as database files or configuration) and likely communicate with clients (or tunnel through the API).
- The crypt tool is used offline or during deployment to process/encrypt LUA scripts before they are deployed into the game assets.

##### Important architectural patterns and design principles
- Modular design: Notice how both bomb-me-api and game-server are organized into clearly defined controllers, services, and utilities.
- Separation of concerns: One module is responsible for general authentication and API endpoints (bomb-me-api), while another handles real-time gameplay and session management (game-server).
- Utility integration: The crypt folder represents a utility layer which supports content protection (encryption/decryption), showing the design’s concern for code security and asset preparation.
- Language and technology mix: The use of NestJS, TypeScript, and LUA (for game missions) indicates a multi-stack approach where different languages are purpose‐specific.

##### Additional details to capture
- How database interactions (e.g., the “game.db” file and migration scripts in game-server) support persistent state.
- External configuration files (such as knexfile.ts, tsconfig.json, and network enums) to show that the architecture is configurable.
- Importance of testability and modularity (the bomb-me-api test directory, separation into controllers, services, modules).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer"
        M1["Mobile/Game Client & Assets (UI, APK Packaging)"]:::client
    end

    subgraph "API Gateway"
        A1["bomb-me-api (NestJS/TypeScript REST API)"]:::backend
    end

    subgraph "Game Server"
        G1["Network Module (TCP,Packet Processing)"]:::backend
        G2["Game Session Management"]:::backend
        G3["Command Processing & Game Logic"]:::backend
        G4["Database Migrations & Configuration"]:::backend
    end

    subgraph "Utilities"
        U1["Crypt Tool (Node.js,LUA Encryption)"]:::utility
        U2["External APK Editor"]:::utility
    end

    M1 -->|"auth,staticdata"| A1
    A1 -->|"initgamesession"| G2
    U1 -->|"encryptLUA"| M1
    U2 -->|"packageAPK"| M1

    click A1 "https://github.com/guinhx/bomb-me/tree/main/bomb-me-api/"
    click G2 "https://github.com/guinhx/bomb-me/tree/main/game-server/"
    click U1 "https://github.com/guinhx/bomb-me/tree/main/crypt/"
    click M1 "https://github.com/guinhx/bomb-me/tree/main/assets/"
    click U2 "https://github.com/guinhx/bomb-me/blob/main/apkeditor.jar"

    classDef client fill:#a2d9ff,stroke:#1f618d,stroke-width:2px;
    classDef backend fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef utility fill:#f9e79f,stroke:#f1c40f,stroke-width:2px;
```
