# mc-wiki/minecraft-mod-heywiki architecture

> Architecture diagram of the GitHub repository mc-wiki/minecraft-mod-heywiki, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mc-wiki/minecraft-mod-heywiki
- Repository: https://github.com/mc-wiki/minecraft-mod-heywiki

## Overview

##### Project’s Main Type and Purpose
- Project Type: A Minecraft client mod that extends game functionality.
- Purpose: To allow players to press a key (default “H”) to retrieve wiki pages (or search results) for blocks, items, or entities they are interacting with. The mod provides several commands (like /wiki, /whatbiome, etc.), integrates with external APIs (wiki endpoints, in-game browser support with MCBrowser/MCEF), and supports configurable behaviors.
- Key Technologies: It is built using Java with Gradle, employs mixins to modify Minecraft behavior, uses Fabric and NeoForge mod loaders, and integrates with external mod APIs (Architectury API, Cloth Config, Mod Menu, etc.).

##### And Break Down the File Structure
- Top-Level Modules:
- common: Contains the shared business logic, core classes (HeyWikiClient, config, command handling, resource management, mixins, GUI screens, etc.)
- fabric: Fabric-specific integration and entry point (HeyWikiFabric), Fabric mixins, and gametests.
- neoforge: NeoForge-specific integration (HeyWikiNeoForge) and resources for NeoForge.
- Directory Patterns Indicating Architecture:
- Use of “src/main/java/wiki/minecraft/heywiki” across modules points to a layered design:
- Entry point and initialization classes handle startup.
- Command packages deal with user interactions via commands.
- GUI and widget packages implement in-game UI elements.
- Mixins are used to inject/modify behavior in Minecraft’s existing classes.
- Resource and extension packages support localization and API integration for external wikis.
- Presence of Gradle build scripts, GitHub workflows, and resource directories indicates a robust build, deployment, and continuous integration system.

a. Main Components:
- Minecraft Client: The platform on which the mod operates.
- Common Module:
- Core Business Logic: Contains key classes (HeyWikiClient, command classes, suggestion providers, and utilities such as HttpUtil, CachedDebouncer).
- Command Handler: Implements commands like /wiki, /imfeelinglucky, etc.
- GUI Manager: Handles custom screens, widgets, and GUI pop-ups (e.g., WikiSearchScreen, ConfirmWikiPageScreen).
- Mixins: Modify Minecraft’s existing screens and behavior to integrate mod functionality (e.g., ChatScreenMixin, GameMenuScreenMixin).
- Resource Management: Loads assets including language files and wiki family JSON configurations.
- Fabric Integration Module:
- Fabric-specific Initialization: Entry classes (HeyWikiFabric) and fabric mixins.
- Gametest: Module for verifying mod behaviors.
- Interactions with Fabric API (for mod configuration and lifecycle management).
- NeoForge Integration Module:
- NeoForge-specific Initialization: Entry classes (HeyWikiNeoForge).
- Resources required by NeoForge (pack.mcmeta, mods.toml).
- External Services/APIs:
- Minecraft Wiki and other supported wikis (via URL APIs for search and random article).
- External mod integrations: Architectury API, Cloth Config, Mod Menu, REI/JEI/EMI integration.
- (Optional) In-game browsing via MCBrowser/MCEF.

b. Relationships and Interactions:
- That the mod’s entry components (from Fabric or NeoForge modules) delegate to the common module for core functionality.
- That GUI components interact with the resource management system to load asset files (language JSON files, wiki family configurations).
- Command handler pathways: the processing of key events (e.g., H key or commands typed into chat) flows into the command subsystem which fetches wiki information and displays it via the GUI.
- How mixins modify base game screens and inject mod functionality.

c. Architectural Patterns and Design Principles:
- Modular Layering: Separation between the common (business logic) and platform-specific (integration) layers.
- Aspect-Oriented Programming: Use of mixins to inject or alter Minecraft’s original behavior.
- Dependency Injection/Delegation: Integration modules instantiate or call upon common functionality and share configuration setups.
- Resource-driven Customization: Separate resource files (assets, localization, configuration JSONs) that externalize and drive mod behavior.

d. Technologies, Frameworks, and Libraries:
- Java, Gradle, and architectural tools (Architectury API) for cross-mod loader compatibility.
- Fabric API and NeoForge APIs as the primary modding frameworks.
- Mixins for runtime bytecode manipulation.
- Cloth Config and Mod Menu for configuration management.
- External wiki APIs that support HTTP requests and response handling within classes like HttpUtil.

- Minecraft Client (base game)
- Common Module (with sub-components: Command Handler, GUI Manager, Mixins, Resource Manager)
- Fabric Module (entry point, Fabric-specific mixins, gametests)
- NeoForge Module (entry point, platform-specific resources)
- External Services (wiki APIs, configuration and dependency services)
- Core logic components (could be rectangles),
- Integration or platform-specific components (e.g., rounded rectangles),

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Minecraft Client
    MC["Minecraft Client"]:::minecraft

    %% Common Module Subgraph
    subgraph "Common Module"
        Core["Core Business Logic"]:::core
        CH["Command Handler"]:::core
        GUIS["GUI Screens"]:::core
        GUIW["GUI Widgets"]:::core
        Mix["Mixins"]:::core
        Assets["Assets Management"]:::core
        Res["Resource Loader"]:::core
    end

    %% Fabric Integration Subgraph
    subgraph "Fabric Integration"
        FabricInit["Fabric Initialization"]:::integration
        FabricMixin["Fabric Mixins"]:::integration
        FabricTest["Fabric Gametest"]:::integration
    end

    %% NeoForge Integration Subgraph
    subgraph "NeoForge Integration"
        NeoInit["NeoForge Initialization"]:::integration
        NeoRes["NeoForge Resources"]:::integration
    end

    %% External Services Subgraph
    subgraph "External Services"
        WikiAPI["Wiki_API_&_In-game_Browser"]:::external
        ExtMods["External_Mod_Integrations"]:::external
    end

    %% Relationships
    MC -->|"initialization"| FabricInit
    MC -->|"initialization"| NeoInit
    FabricInit -->|"delegate_call"| Core
    NeoInit -->|"delegate_call"| Core
    MC -.->|"mixin_injection"| Mix

    Core -->|"handles_commands"| CH
    CH -->|"API_request"| WikiAPI
    CH -->|"render_update"| GUIS
    Core -->|"calls_screens"| GUIS
    Core -->|"calls_widgets"| GUIW
    Core -->|"applies_mixins"| Mix
    Core -->|"loads_assets"| Assets
    Core -->|"loads_resources"| Res
    Core -->|"config_dependency"| ExtMods

    FabricMixin -->|"extends_mixins"| Mix
    FabricInit -->|"triggers_validation"| FabricTest

    %% Class Definitions
    classDef minecraft fill:#ffebcd,stroke:#333,stroke-width:2px;
    classDef core fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef integration fill:#d1ffd1,stroke:#333,stroke-width:2px;
    classDef external fill:#ffe6e6,stroke:#333,stroke-width:2px;

    %% Click Events
    click Core "https://github.com/mc-wiki/minecraft-mod-heywiki/tree/master/common/src/main/java/wiki/minecraft/heywiki/"
    click CH "https://github.com/mc-wiki/minecraft-mod-heywiki/tree/master/common/src/main/java/wiki/minecraft/heywiki/command/"
    click GUIS "https://github.com/mc-wiki/minecraft-mod-heywiki/tree/master/common/src/main/java/wiki/minecraft/heywiki/gui/screen/"
    click GUIW "https://github.com/mc-wiki/minecraft-mod-heywiki/tree/master/common/src/main/java/wiki/minecraft/heywiki/gui/widget/"
    click Mix "https://github.com/mc-wiki/minecraft-mod-heywiki/tree/master/common/src/main/java/wiki/minecraft/heywiki/mixin/"
    click Assets "https://github.com/mc-wiki/minecraft-mod-heywiki/tree/master/common/src/main/resources/assets/heywiki/"
    click Res "https://github.com/mc-wiki/minecraft-mod-heywiki/tree/master/common/src/main/java/wiki/minecraft/heywiki/resource/"
    click FabricInit "https://github.com/mc-wiki/minecraft-mod-heywiki/blob/master/fabric/src/main/java/wiki/minecraft/heywiki/fabric/HeyWikiFabric.java"
    click FabricMixin "https://github.com/mc-wiki/minecraft-mod-heywiki/tree/master/fabric/src/main/java/wiki/minecraft/heywiki/fabric/mixin/"
    click FabricTest "https://github.com/mc-wiki/minecraft-mod-heywiki/tree/master/fabric/src/gametest/"
    click NeoInit "https://github.com/mc-wiki/minecraft-mod-heywiki/blob/master/neoforge/src/main/java/wiki/minecraft/heywiki/neoforge/HeyWikiNeoForge.java"
    click NeoRes "https://github.com/mc-wiki/minecraft-mod-heywiki/tree/master/neoforge/src/main/resources/"
```
