# longht021189/game-maps architecture

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

- Interactive diagram: https://gitdiagram.com/longht021189/game-maps
- Repository: https://github.com/longht021189/game-maps

## Overview

##### Main components
- Frontend User Interface: Located in the “src” folder, built using SolidJS/TypeScript. This is the visual layer that gamers interact with.
- Tauri Shell/Integration Layer: Found in “src-tauri”. This Rust–based layer bridges the UI (webview) with the system resources and back–end logic.
- Core Business Logic: Implemented in Rust under “src-core”. This module encapsulates functionalities such as handling requests, responses, type definitions, and generating dynamic bindings.
- Native Module: In the “src-native” folder, this C/C++ component manages low–level operations including network requests, data handling (wraps cURL for HTTP operations), interfacing with LevelDB for local storage, and any performance–critical or OS–specific functionality.
- External Dependencies and Services: Map Genie’s API for retrieving map data, as well as integrations with external libraries like Catch2 for testing, and various C++ libraries from yaLanTingLibs.

##### Relationships and interactions
– The UI layer (SolidJS) interacts with the Tauri layer via JavaScript calls (or Tauri’s provided APIs) to invoke native operations.
– The Tauri layer orchestrates communication between the frontend and the back–end by calling into the core Rust logic (src-core).
– The Rust core might invoke native functions from the C/C++ module (src-native) through FFI (foreign function interface) for operations where performance or lower–level OS–integration is required.
– The native module communicates with local resources such as LevelDB (for handling saved game map data) and employs cURL for HTTP transfers with Map Genie.
– External APIs (Map Genie) act as data sources which are integrated via network operations managed by the native module.

##### Architectural patterns and design principles
– The design follows a layered approach separating concerns:
- Presentation Layer (UI in TypeScript/SolidJS)
- Application/Integration Layer (Tauri backend)
- Core Business Logic (Rust library in src-core)
- Low-level System/Native Operations (C/C++ code in src-native)
– Modularity is evident with clear separation between native and core logic layers facilitating ease of testing (using Catch2 in C++) and incremental improvements or porting (e.g., expanding support to other platforms).
– Use of FFI shows an integration pattern where Rust and C/C++ components interoperate.

##### Relevant technologies, frameworks, or libraries
– Tauri Framework for the desktop shell.
– SolidJS with TypeScript for the frontend.
– Rust (Cargo managed) for core functionality (src-core and src-tauri).
– C/C++ with CMake for the native module (src-native).
– LevelDB for storage and cURL for HTTP communication.
– Catch2 for testing, and yaLanTingLibs for JSON handling.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        UI["User Interface (SolidJS)"]:::ui
    end

    subgraph "Integration Layer"
        TAURI["Tauri Shell (Rust)"]:::tauri
    end

    subgraph "Core Business Logic"
        CORE["Core Business Logic (Rust)"]:::rust
    end

    subgraph "Native Module"
        NATIVE["Native Module (C/C++)"]:::native
    end

    subgraph "External Services"
        MG_API["Map Genie API"]:::external
        LEVELDB["LevelDB Storage"]:::external
        YALANTING["yaLanTingLibs"]:::external
    end

    UI -->|"JS_to_Tauri"| TAURI
    TAURI -->|"Invoke_Core"| CORE
    CORE -->|"FFI_call"| NATIVE
    NATIVE -->|"HTTP_Request"| MG_API
    NATIVE -->|"DB_Access"| LEVELDB
    NATIVE -->|"JSON_Handle"| YALANTING

    %% Click Events for Component Mapping
    click UI "https://github.com/longht021189/game-maps/blob/main/src/App.tsx"
    click TAURI "https://github.com/longht021189/game-maps/blob/main/src-tauri/src/main.rs"
    click CORE "https://github.com/longht021189/game-maps/blob/main/src-core/src/lib.rs"
    click NATIVE "https://github.com/longht021189/game-maps/blob/main/src-native/src/app.cpp"

    %% Styles
    classDef ui fill:#b3cde0,stroke:#03396c,stroke-width:2px;
    classDef tauri fill:#aef0d1,stroke:#008080,stroke-width:2px;
    classDef rust fill:#f7d0b3,stroke:#d35400,stroke-width:2px;
    classDef native fill:#f4a399,stroke:#c0392b,stroke-width:2px;
    classDef external fill:#dcd0ff,stroke:#6a0dad,stroke-width:2px;
```
