# glob3mobile/g3m architecture

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

- Interactive diagram: https://gitdiagram.com/glob3mobile/g3m
- Repository: https://github.com/glob3mobile/g3m

## Overview

This project – “g3m” – is a multiplatform advanced visualization framework built to power high-performance mobile (and desktop) map apps and real–time 2D/2.5D/3D visualization. Its core architecture centers around a C++ engine that is then “translated” (via automated tools or manual bridges) into other languages and APIs for Android (Java), WebGL (via GWT/JavaScript, Emscripten) and iOS (Objective-C/Swift). The system “splits” into a core, cross–platform logic layer and platform–specific libraries that implement abstract interfaces for device–dependent features such as rendering, file I/O, and input handling.

##### Main Layers/Components
- Core Engine (C++):
– The heart of the framework which contains algorithms for rendering, geometry processing, camera management, scene construction, and general visualization.
- Platform Translation/Bridging Layer:
– Tools and processes that translate core C++ code to Java (“G3MAndroidSDK”, “JavaDesktop” modules) and JavaScript (through GWT and Emscripten for WebGL).
- Platform–Specific Implementations:
– Each target platform has its native implementations of a set of abstract interfaces. For instance:
∙ Android: Code under Android/G3MAndroidDemo and related Android-specific libraries.
∙ iOS: Code under iOS/G3MApp, with dedicated implementations of device handling and rendering.
∙ WebGL/HTML5: Modules under WebGL/G3MWebGLDemo, G3MWebGLSDK among others which use GWT, Emscripten.
∙ Desktop: JavaDesktop modules build native desktop versions.
- Tools and Utilities:
– Additional modules or tools such as Blender plugin (for exporting), point-cloud processing, extruders, and others which assist in converting and processing input data (e.g. for generating buildings, textures, point clouds).

##### Data Flow and Dependencies
- The Core C++ Layer provides a unified engine and algorithms.
- Abstract interfaces (declared in the core) define methods that “bridge” to the platform–specific functionality.
- For each platform, the translated core is integrated with that platform’s native libraries (Android: Java wrappers; iOS: Objective-C implementations; WebGL: GWT/JavaScript code compiled by Emscripten).
- Tools such as converters and extruders (found under “tools/…” and “converter”) process raw input data (geospatial formats, textures, point cloud data) and feed them into the core engine.

##### Architectural Patterns and Design Principles
- Multilayer/Modular architecture: Separate core logic from platform implementations.
- Abstraction / Interface design:
– Abstract classes/interfaces defined in the core that are implemented natively per platform.
- Cross-compilation/translation:
– The core is “translated” into Java and JavaScript (via GWT and Emscripten), ensuring maximum code reuse.
- High performance emphasis:
- Extensibility:
– New platforms can be added by implementing the abstract interfaces.

##### Technologies and Libraries
- Languages: C++ (core), Java, JavaScript (via GWT/Emscripten), Objective-C for iOS.
- Platforms: Android, iOS, WebGL (HTML5/Javascript), Desktop.
- SDKs and frameworks: support libraries like android-support-v4.jar on Android, WebGL shaders, and iOS specific rendering (OpenGL ES).
- Tools: Compilation scripts for Emscripten, Blender plugin for exporting scenes, tools for handling point-clouds, extruders.

##### Details Pertinent to This Project
- Unique multi–platform translation aspect:
"The engine is written once in C++ and then automatically translated to Java (Android) and JavaScript (via GWT/Emscripten for web), with native iOS wrappers created."
- Integration points for real–time and offline data (cache management) in the engine.
- Modular examples that exist in the file tree: they are present in directories such as “Android”, “iOS”, “WebGL”, “JavaDesktop”, “Emscripten”, and “Commons”.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Core Layer
    subgraph "Core Layer"
        CoreEngine["Core Engine (C++)"]:::core
        AbstractInterface["Abstract Interface Layer"]:::core
    end

    %% Tools and Utilities
    subgraph "Tools and Utilities"
        BlenderNode["Blender Exporter"]:::tools
        Converter["Converter"]:::tools
        Extruder["Extruder"]:::tools
        PointCloudOctree["Point-Cloud Octree"]:::tools
        ShadersProcessor["Shaders Processor"]:::tools
        JSONBSONConverter["JSON-BSON Converter"]:::tools
    end

    %% Android Implementation
    subgraph "Android Implementation"
        AndroidSDK["G3MAndroidSDK"]:::platform
        AndroidDemo["G3MAndroidDemo"]:::platform
        AndroidTesting["G3MAndroidTestingApplication"]:::platform
    end

    %% iOS Implementation
    subgraph "iOS Implementation"
        iOSSDK["G3MiOSSDK"]:::platform
        iOSApp["G3MApp"]:::platform
        iOSDemo["G3MiOSDemo"]:::platform
    end

    %% WebGL Implementation
    subgraph "WebGL Implementation"
        WebGLSDK["G3MWebGLSDK"]:::platform
        WebGLDemo["G3MWebGLDemo"]:::platform
        WebGLTemplate["G3MWebGLTemplate"]:::platform
        WebGLTesting["G3MWebGLTestingApplication"]:::platform
    end

    %% Desktop Implementation
    subgraph "Desktop Implementation"
        JavaDesktop["G3MJavaDesktopSDK"]:::platform
    end

    %% Data Flow Arrows
    %% Tools feed into the Core Engine
    BlenderNode -->|"processes"| CoreEngine
    Converter -->|"processes"| CoreEngine
    Extruder -->|"processes"| CoreEngine
    PointCloudOctree -->|"processes"| CoreEngine
    ShadersProcessor -->|"processes"| CoreEngine
    JSONBSONConverter -->|"processes"| CoreEngine

    %% Core Layer communicates with Abstract Interface
    CoreEngine -->|"defines"| AbstractInterface

    %% Abstract Interface bridges to Platform Implementations
    AbstractInterface -->|"implements"| AndroidSDK
    AbstractInterface -->|"implements"| iOSSDK
    AbstractInterface -->|"implements"| WebGLSDK
    AbstractInterface -->|"implements"| JavaDesktop

    %% Android internal relationships
    AndroidSDK -->|"adapts"| AndroidDemo
    AndroidSDK -->|"adapts"| AndroidTesting

    %% iOS internal relationships
    iOSSDK -->|"adapts"| iOSApp
    iOSSDK -->|"adapts"| iOSDemo

    %% WebGL internal relationships
    WebGLSDK -->|"adapts"| WebGLDemo
    WebGLSDK -->|"adapts"| WebGLTemplate
    WebGLSDK -->|"adapts"| WebGLTesting

    %% Styling Classes
    classDef core fill:#f9e79f,stroke:#e67e22,stroke-width:2px;
    classDef platform fill:#aed6f1,stroke:#5dade2,stroke-width:2px;
    classDef tools fill:#d5f5e3,stroke:#82e0aa,stroke-width:2px;

    %% Click Events
    click CoreEngine "https://github.com/glob3mobile/g3m/tree/purgatory/cpp/G3M"
    click AndroidDemo "https://github.com/glob3mobile/g3m/tree/purgatory/Android/G3MAndroidDemo"
    click AndroidSDK "https://github.com/glob3mobile/g3m/tree/purgatory/Android/G3MAndroidSDK"
    click AndroidTesting "https://github.com/glob3mobile/g3m/tree/purgatory/Android/G3MAndroidTestingApplication"
    click iOSApp "https://github.com/glob3mobile/g3m/tree/purgatory/iOS/G3MApp"
    click iOSDemo "https://github.com/glob3mobile/g3m/tree/purgatory/iOS/G3MiOSDemo"
    click iOSSDK "https://github.com/glob3mobile/g3m/tree/purgatory/iOS/G3MiOSSDK"
    click WebGLDemo "https://github.com/glob3mobile/g3m/tree/purgatory/WebGL/G3MWebGLDemo"
    click WebGLSDK "https://github.com/glob3mobile/g3m/tree/purgatory/WebGL/G3MWebGLSDK"
    click WebGLTemplate "https://github.com/glob3mobile/g3m/tree/purgatory/WebGL/G3MWebGLTemplate"
    click WebGLTesting "https://github.com/glob3mobile/g3m/tree/purgatory/WebGL/G3MWebGLTestingApplication"
    click JavaDesktop "https://github.com/glob3mobile/g3m/tree/purgatory/JavaDesktop/G3MJavaDesktopSDK"
    click BlenderNode "https://github.com/glob3mobile/g3m/tree/purgatory/Blender"
    click Converter "https://github.com/glob3mobile/g3m/tree/purgatory/converter"
    click Extruder "https://github.com/glob3mobile/g3m/tree/purgatory/tools/extruder"
    click PointCloudOctree "https://github.com/glob3mobile/g3m/tree/purgatory/tools/point-cloud-octree"
    click ShadersProcessor "https://github.com/glob3mobile/g3m/tree/purgatory/tools/ShadersProcessor"
    click JSONBSONConverter "https://github.com/glob3mobile/g3m/tree/purgatory/tools/json-bson-converters"
```
