# thepansmith/monifactory architecture

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

- Interactive diagram: https://gitdiagram.com/thepansmith/monifactory
- Repository: https://github.com/thepansmith/monifactory

## Overview

##### Main components
- Core Modpack Assets & Configuration – these include the “config”, “config-overrides” (with separate directories for normal, hardmode, and expert), defaultconfigs files, and override files. These components illustrate the modpack’s mechanism for supporting multiple progression modes.
- KubeJS Engine – The “kubejs” directory is the backbone for custom client and server scripts. It contains subdirectories for client_scripts, server_scripts, startup_scripts, data, assets, and even tooling (like dx, eslint config, package.json). These scripts control recipe changes, mod tweaks, and integration logic.
- Build & Packaging Tools – The “tools” directory (with its bootstrap and build subfolders) and the pack-mode-switcher scripts (pack-mode-switcher.bat and .sh) are responsible for packaging, building, and switching among game modes. They automate tasks such as modifying recipes and generating configuration files.
- CI/CD and Repository-Oriented Components – The presence of the .github folder (with issue templates, workflows, GitHub Actions for builds and linting) indicates automated tests and build pipelines.

##### Relationships and interactions
– “Config / Overrides” (which supply game settings, difficulty modes, and mod configurations)
– “KubeJS Scripts” (both client-side and server-side modifications that alter in-game behavior and recipes)
– “External Mods & Optional Compat Modules” (whose integration points are handled by KubeJS scripts and override configurations)
- “Build & Packaging Pipeline” which is responsible for assembling the modpack – from “tools” (build scripts and code generation) and the “pack-mode-switcher” that selects the correct mode based on user input. Illustrate that these tools feed the “Config / Overrides”.
- CI/CD process (GitHub workflows) as a supporting subsystem that automatically runs linting, tests, and builds whenever changes are pushed.

##### Important architectural patterns and design principles
- Modularity and Mode Switching – The separation of config overrides into “normal”, “hardmode”, and “expert” shows an architectural decision to support multiple difficulty/progression modes. Represent these as independent modules that merge into the overall configuration.
- Automated Build/Deployment – The integration of GitHub Actions, tools for code generation (including credits and language files), and pack-mode switcher utilities depicts a robust development and deployment pipeline.

##### Relevant technologies and libraries
- KubeJS (for in-game scripting)
- JavaScript (node.js used in the “tools” directory and within KubeJS scripts)
- Minecraft Forge server (for the dedicated server setup instructions)
- GitHub Actions for CI/CD
- Various configuration formats (JSON, TOML, YAML, SNBT) are used for mod configurations. Represent these file types as part of your “Configuration Store.”

## Diagram (Mermaid)

```mermaid
graph TD
    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        CICD["GitHub Actions"]:::cicd
    end

    %% Build & Packaging Pipeline
    subgraph "Build & Packaging Pipeline"
        Tools["Tools"]:::build
        PMB["Pack Mode Switcher (.bat)"]:::build
        PMS["Pack Mode Switcher (.sh)"]:::build
    end

    %% Configuration Store
    subgraph "Configuration Store"
        Conf["Config"]:::config
        ConfOverrides["Config Overrides"]:::config
        DefaultCfg["Default Configs"]:::config
    end

    %% KubeJS Engine
    subgraph "KubeJS Engine"
        KClient["Client Scripts"]:::kube
        KServer["Server Scripts"]:::kube
        KStartup["Startup Scripts"]:::kube
        KData["Data & Assets"]:::kube
        KTooling["KubeJS Tooling"]:::kube
    end

    %% External Mods
    subgraph "External Mods"
        Mods["Mods"]:::mods
    end

    %% Central Modpack Runtime
    Runtime["Modpack Runtime (Minecraft)"]:::runtime

    %% Relationships
    CICD -->|"autoTrigger"| Tools
    Tools -->|"buildPipeline"| ConfOverrides

    Conf -->|"configurationOverride"| Runtime
    ConfOverrides -->|"configurationOverride"| Runtime
    DefaultCfg -->|"configurationOverride"| Runtime

    KClient -->|"runtimeHook"| Runtime
    KServer -->|"runtimeHook"| Runtime
    KStartup -->|"runtimeHook"| Runtime
    KData -->|"runtimeHook"| Runtime
    KTooling -->|"scriptSetup"| Runtime

    Mods -->|"modIntegration"| Runtime

    %% Click Events for Core Modpack Assets & Configuration
    click Conf "https://github.com/thepansmith/monifactory/tree/main/config"
    click ConfOverrides "https://github.com/thepansmith/monifactory/tree/main/config-overrides"
    click DefaultCfg "https://github.com/thepansmith/monifactory/tree/main/defaultconfigs"

    %% Click Events for KubeJS Engine
    click KClient "https://github.com/thepansmith/monifactory/tree/main/kubejs/client_scripts"
    click KServer "https://github.com/thepansmith/monifactory/tree/main/kubejs/server_scripts"
    click KStartup "https://github.com/thepansmith/monifactory/tree/main/kubejs/startup_scripts"
    click KData "https://github.com/thepansmith/monifactory/tree/main/kubejs/assets"
    click KTooling "https://github.com/thepansmith/monifactory/tree/main/kubejs"

    %% Click Events for Build & Packaging Tools
    click Tools "https://github.com/thepansmith/monifactory/tree/main/tools"
    click PMB "https://github.com/thepansmith/monifactory/blob/main/pack-mode-switcher.bat"
    click PMS "https://github.com/thepansmith/monifactory/blob/main/pack-mode-switcher.sh"

    %% Click Event for Mod Integration & Compatibility
    click Mods "https://github.com/thepansmith/monifactory/tree/main/mods"

    %% Click Event for CI/CD and Repository Components
    click CICD "https://github.com/thepansmith/monifactory/blob/main/.github"

    %% Styles
    classDef cicd fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef build fill:#AED6F1,stroke:#5DADE2,stroke-width:2px;
    classDef config fill:#A9DFBF,stroke:#28B463,stroke-width:2px;
    classDef kube fill:#F5B7B1,stroke:#EC7063,stroke-width:2px;
    classDef mods fill:#D2B4DE,stroke:#AF7AC5,stroke-width:2px;
    classDef runtime fill:#FAD7A0,stroke:#F39C12,stroke-width:2px;
```
