# koide3/glim architecture

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

- Interactive diagram: https://gitdiagram.com/koide3/glim
- Repository: https://github.com/koide3/glim

## Overview

##### Project Type and Purpose
- GLIM is an open‐source, full‐featured 3D range‐based mapping framework written in C++.
- It comprises a core mapping engine (factor‐graph based, GTSAM integration), preprocessing and odometry modules, an interactive viewer, and extension points for plugins (ROS/ROS2, GPU acceleration, custom callbacks).

##### File Structure Analysis
- Top‐level:
- /glim – public headers (common, preprocess, odometry, mapping, viewer, util)
- src/glim – implementation files mirroring the include tree
- config – JSON configuration presets for sensors, odometry, mapping, viewer
- docker – Dockerfiles for building on various toolchains
- cmake, CMakeLists.txt – build system
- docs – user and developer documentation
- thirdparty – bundled nlohmann::json
- Patterns:
- Module‐based layering: preprocess → odometry → mapping → viewer
- Plugin mechanism via util/extension_module (ROS, ROS2)
- Factor‐graph back‐end (GTSAM) abstracted under mapping and odometry

##### Key README Insights
- Emphasizes accuracy (GTSAM, GPU), interactivity (viewer editing, loop closing), and extensibility (callback slots, extension modules).
- Lists mandatory dependencies (Eigen, nanoflann, GTSAM, gtsam_points) and optional ones (CUDA, OpenCV, ROS/ROS2).

a. Main Components
- Sensor Input (LiDAR, RGB‐D, etc.)
- Preprocessor Component
- Odometry Component
- Mapping Component (factor‐graph engine)
- Viewer Component (interactive editor, offline/standard viewers)
- Configuration Loader Component
- Extension Modules (ROS, ROS2, custom callbacks)
- Thirdparty Libraries (Eigen, nanoflann, GTSAM, gtsam_points, nlohmann::json)
b. Relationships and Data Flow
- Sensor Input → Preprocessor (cloud deskewing, filtering)
- Preprocessor → Odometry & Mapping (stream frames)
- Odometry & Mapping ↔ GTSAM Engine (insert factors, optimize)
- Mapping ↔ Extension Modules (global callback slots)
- Optimized Map Data → Viewer (render, edit, manual loop close)
- Configuration Loader → All Core Components (JSON parameters)
- Viewer → Mapping (on‐the‐fly corrections)
c. Architectural Patterns
- Layered pipeline: preprocess → odometry → mapping → viewer
- Plugin‐based extensibility via util/extension_module
- Asynchronous modules: async_odometry_estimation, async_global_mapping
- GPU acceleration paths (odometry_gpu, mapping GPU factors)
d. Technologies and Frameworks
- CMake, Docker for build/deploy
- Eigen, nanoflann for linear algebra and nearest‐neighbor searches
- GTSAM + gtsam_points for factor graphs
- CUDA (optional) for GPU modules
- ROS/ROS2 adapters under util/extension_module_ros
- nlohmann::json for config parsing

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Components
    SI["Sensor Input\n«glim::common»"]:::core
    PP["Preprocessor\n«glim::preprocess»"]:::core
    OD["Odometry\n«glim::odometry»"]:::core
    MP["Mapping\n«glim::mapping»"]:::core
    VW["Viewer\n«glim::viewer»"]:::core

    %% Utility and Extensions
    CL["Configuration Loader"]:::util
    UTIL["Utility Modules\n(common, callbacks, logging)"]:::util
    EM["Extension Modules\n(ROS/ROS2)"]:::extension

    %% Thirdparty Components
    GT["GTSAM Engine"]:::thirdparty
    TP["Thirdparty JSON\n(nlohmann::json)"]:::thirdparty

    %% Data Flow
    SI --> PP
    PP --> OD
    PP --> MP
    OD --> GT
    MP --> GT
    GT --> MP
    MP --> VW
    VW --> MP

    %% Configuration Dependencies
    CL -.-> SI
    CL -.-> PP
    CL -.-> OD
    CL -.-> MP
    CL -.-> VW

    %% Extensions and Utilities
    EM --> MP
    UTIL --> EM
    UTIL --> PP
    UTIL --> OD
    UTIL --> MP
    UTIL --> VW

    %% Thirdparty Links
    TP --> CL

    %% Click Events
    click SI "https://github.com/koide3/glim/tree/master/include/glim/common"
    click SI "https://github.com/koide3/glim/tree/master/src/glim/common"
    click PP "https://github.com/koide3/glim/tree/master/include/glim/preprocess"
    click PP "https://github.com/koide3/glim/tree/master/src/glim/preprocess"
    click OD "https://github.com/koide3/glim/tree/master/include/glim/odometry"
    click OD "https://github.com/koide3/glim/tree/master/src/glim/odometry"
    click MP "https://github.com/koide3/glim/tree/master/include/glim/mapping"
    click MP "https://github.com/koide3/glim/tree/master/src/glim/mapping"
    click VW "https://github.com/koide3/glim/tree/master/include/glim/viewer"
    click VW "https://github.com/koide3/glim/tree/master/src/glim/viewer"
    click CL "https://github.com/koide3/glim/blob/master/include/glim/util/config.hpp"
    click CL "https://github.com/koide3/glim/blob/master/config/*.json"
    click EM "https://github.com/koide3/glim/blob/master/include/glim/util/extension_module.hpp"
    click EM "https://github.com/koide3/glim/blob/master/include/glim/util/extension_module_ros.hpp"
    click EM "https://github.com/koide3/glim/blob/master/include/glim/util/extension_module_ros2.hpp"
    click EM "https://github.com/koide3/glim/blob/master/src/glim/util/extension_module.cpp"
    click UTIL "https://github.com/koide3/glim/tree/master/include/glim/util"
    click UTIL "https://github.com/koide3/glim/tree/master/src/glim/util"
    click TP "https://github.com/koide3/glim/tree/master/thirdparty/json/include/nlohmann"

    %% Styles
    classDef core fill:#cce5ff,stroke:#3399ff,color:#000;
    classDef extension fill:#d4edda,stroke:#28a745,color:#000;
    classDef util fill:#fff3cd,stroke:#ffc107,color:#000;
    classDef thirdparty fill:#e2e3e5,stroke:#6c757d,color:#000;
```
