# pojavlauncherteam/pojavlauncher architecture

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

- Interactive diagram: https://gitdiagram.com/pojavlauncherteam/pojavlauncher
- Repository: https://github.com/pojavlauncherteam/pojavlauncher

## Overview

##### Main Components
a. Android Application UI & Activities (app_pojavlauncher):
- This is the primary Android module that handles the user interface. It contains all the activities, fragments (e.g., MainMenuFragment, Login Fragments, and various dialogs for file selection, mod installation, and preferences) and controls that let the user interact with the launcher.
- It includes resources like XML layouts, drawables, and strings for multiple locales.
b. Native & JNI Layers:
- The project includes a native code component under the “jni” directory inside the main app module, which includes various C files and native libraries. These interface with system components for graphics (OpenGL), input handling, and performance enhancements (such as custom input pipelines, native JNI bridges to the JRE, and native hooks).
c. JRE and LWJGL Components (jre_lwjgl3glfw and gl4es):
- The “jre_lwjgl3glfw” module acts as the custom Java Runtime Environment for Android (derived from OpenJDK 8 and configured with multiarch support). It integrates with LWJGL (Lightweight Java Game Library) to provide graphics and input support.
- The “gl4es” module, which is integrated into the launcher, provides OpenGL implementations on devices that may not natively support the targeted version.
d. Supporting Modules and Tools:
- Additional modules such as “arc_dns_injector” and “forge_installer” appear as separate subprojects. These are responsible for specialized tasks—one for DNS injection (likely for network redirection or mod management), and another for handling mod installation for modloaders.
- There are other directories and scripts (such as in “scripts”, “crowdin.yml”, “gradle”, etc.) which manage build processes, continuous integration, language localization, and dependency management.

##### Relationships & Interactions Between Components
- The Android UI (app_pojavlauncher) acts as the façade, receiving user input and displaying game progress, configuration, and mod installation dialogs.
- UI components communicate with background services (GameService, ProgressService) and native code via JNI bridges. These services handle tasks like game launching, downloading assets, and progress tracking.
- The JRE module (jre_lwjgl3glfw) provides the Java execution environment in which Minecraft runs. It interacts with the native code (through JNI calls) to manage the game loop, graphics rendering (using LWJGL/OpenGL), and input.
- The native libraries (found in jni and jniLibs directories) interface with system-level operations (such as GL contexts, input bridges, and performance optimizations).
- Additional modules (arc_dns_injector, forge_installer) are integrated into the asset pipeline; they might be loaded or referenced during mod installation or runtime configuration by the main app module.
- Utility packages and components (e.g., custom controls, progress listeners, custom views, file selectors, mod loaders, account management, and authentication components) are interwoven into the launcher’s service layer and controller logic.

##### Architectural Patterns and Design Principles
- Modularization: The project is clearly divided into several modules/subprojects (e.g., core launcher, JRE, mod installers, DNS injector) which makes it maintainable and scalable.
- Separation of Concerns: The UI layer (activities, fragments, custom controls) is distinctly separated from the business logic (services, tasks, progress tracking) and lower-level native modules.
- Cross-Layer Communication: Emphasize the use of JNI bridges to connect the Java Android code with native C/C++ code, ensuring performance-critical tasks (e.g., GLFW management, input handling) are managed natively.
- Support for Multiarchitecture: The approach to packaging the JRE (splitting platform-independent .jar and platform-dependent .so files) demonstrates careful attention to multiarchitectural support for Android devices.

##### Key Technologies, Frameworks, and Libraries
- Android SDK and Java for the main application.
- Gradle as the build system.
- Custom OpenJDK implementations (OpenJDK 8, 17) packaged for Android.
- LWJGL (via both the “jre_lwjgl3glfw” module and LWJGLx for backward compatibility).
- gl4es as a custom OpenGL layer.
- JNI for bridging Java and native code.
- External dependencies like Gson, exp4j, and Apache Commons for various functionalities.
- Crowdin for language localization.
- Various third-party components (e.g., pro-grade security manager, libepoxy, virglrenderer) integrated into the project.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% UI/Presentation Layer
    subgraph "UI/Presentation Layer"
        UI1("UI Logic"):::ui
        UI2("UI Resources"):::ui
    end

    %% Application/Service Layer
    subgraph "Application/Service Layer"
        S1("Service Layer"):::service
    end

    %% JRE & Integration Layer
    subgraph "JRE & Integration Layer"
        J1("JRE & LWJGL"):::jre
        J2("gl4es OpenGL"):::jre
    end

    %% Native/Runtime Layer
    subgraph "Native/Runtime Layer"
        N1("JNI Bridge"):::native
        N2("Native Libraries"):::native
    end

    %% Supporting Modules
    subgraph "Supporting Modules"
        M1("DNS Injector"):::support
        M2("Mod Installer"):::support
    end

    %% Connections
    UI2 -->|"loaded_by"| UI1
    UI1 -->|"user_input"| S1
    S1 -->|"launch_game"| J1
    J1 -->|"openGL_impl"| J2
    J1 -->|"JNI_call"| N1
    N1 -->|"load_native"| N2
    S1 -->|"network_mods"| M1
    S1 -->|"install_mod"| M2

    %% Click Events
    click UI1 "https://github.com/pojavlauncherteam/pojavlauncher/tree/v3_openjdk/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch"
    click UI2 "https://github.com/pojavlauncherteam/pojavlauncher/tree/v3_openjdk/app_pojavlauncher/src/main/res"
    click N1 "https://github.com/pojavlauncherteam/pojavlauncher/tree/v3_openjdk/app_pojavlauncher/src/main/jni"
    click N2 "https://github.com/pojavlauncherteam/pojavlauncher/tree/v3_openjdk/app_pojavlauncher/src/main/jniLibs"
    click J1 "https://github.com/pojavlauncherteam/pojavlauncher/tree/v3_openjdk/jre_lwjgl3glfw"
    click J2 "https://github.com/pojavlauncherteam/pojavlauncher/tree/v3_openjdk/gl4es"
    click M1 "https://github.com/pojavlauncherteam/pojavlauncher/tree/v3_openjdk/arc_dns_injector"
    click M2 "https://github.com/pojavlauncherteam/pojavlauncher/tree/v3_openjdk/forge_installer"

    %% Styles
    classDef ui fill:#aec6cf,stroke:#1f78b4,stroke-width:2px;
    classDef service fill:#b3e5fc,stroke:#0277bd,stroke-width:2px;
    classDef jre fill:#d1c4e9,stroke:#6a1b9a,stroke-width:2px;
    classDef native fill:#c5e1a5,stroke:#558b2f,stroke-width:2px;
    classDef support fill:#ffcc80,stroke:#f57c00,stroke-width:2px;
```
