# fabricmc/fabric-loom architecture

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

- Interactive diagram: https://gitdiagram.com/fabricmc/fabric-loom
- Repository: https://github.com/fabricmc/fabric-loom

## Overview

##### Main Components

a) Core Plugin Infrastructure
- LoomGradlePlugin (main entry point)
- LoomGradleExtension (configuration)
- ConfigContext (setup context)

b) Decompiler System
- Common decompiler interface
- Three implementations: CFR, Fernflower, and Vineflower
- To core with "uses" relationship

c) Mapping System
- Layered mapping system
- Multiple providers (Mojang, Yarn, Parchment)
- Intermediary mappings

d) Minecraft Processing
- MinecraftProvider
- Library management
- Jar splitting/merging
- To core with "processes" relationship

e) Development Environment Support
- Run configurations
- Project generation
- To core with "generates" relationship

##### Important Architectural Patterns to Highlight

a) Service Layer
- Service architecture used for mappings, remapping, and decompilation
- Factory pattern used for service creation

b) Extension System
- Plugin's extension mechanism
- How it integrates with Gradle's lifecycle

c) Processing Pipeline
- Demonstrate the transformation pipeline for Minecraft jars
- Flow from raw to processed artifacts

##### Additional Elements

a) Configuration
- Configuration files and their relationship to components
- Gradle.properties and settings.gradle integration

b) Cache System
- Caching mechanism for processed artifacts
- How it integrates with Gradle's cache

##### Notes

Notes for:
- Java version compatibility
- Gradle version requirements
- Key external dependencies

- Clear hierarchical layouts
- Custom styling
- Export to various formats
- Version control friendly formats

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Core Plugin Infrastructure
    subgraph Core
        LoomPlugin[LoomGradlePlugin]
        LoomExt[LoomGradleExtension]
        ConfigCtx[ConfigContext]
        
        LoomPlugin --> LoomExt
        LoomExt --> ConfigCtx
    end
    
    %% Decompiler System
    subgraph Decompilers
        DecompInterface[LoomInternalDecompiler]
        CFR[CFR Decompiler]
        FernFlower[FernFlower Decompiler]
        VineFlower[VineFlower Decompiler]
        
        DecompInterface --> CFR
        DecompInterface --> FernFlower
        DecompInterface --> VineFlower
    end
    
    %% Mapping System
    subgraph Mappings
        MappingSystem[Layered Mapping System]
        MojangMap[Mojang Mappings]
        YarnMap[Yarn Mappings]
        ParchmentMap[Parchment Mappings]
        IntermediaryMap[Intermediary Mappings]
        
        MappingSystem --> MojangMap
        MappingSystem --> YarnMap
        MappingSystem --> ParchmentMap
        MappingSystem --> IntermediaryMap
    end
    
    %% Minecraft Processing
    subgraph MCProcessing
        MCProvider[MinecraftProvider]
        LibMgmt[Library Management]
        JarSplit[Jar Splitter]
        JarMerge[Jar Merger]
        
        MCProvider --> LibMgmt
        MCProvider --> JarSplit
        MCProvider --> JarMerge
    end
    
    %% IDE Support
    subgraph IDESupport
        RunConfigs[Run Configurations]
        ProjGen[Project Generation]
        IdeaConfig[IDEA Configuration]
        
        RunConfigs --> IdeaConfig
        ProjGen --> IdeaConfig
    end
    
    %% Relationships between components
    Core <--> Mappings
    Core --> Decompilers
    Core --> MCProcessing
    Core --> IDESupport
    MCProcessing --> Mappings
    
    %% Styling
    classDef core fill:#a8d1f0
    classDef decompiler fill:#ffe599
    classDef mapping fill:#d4a6e9
    classDef processing fill:#a8e6a8
    classDef ide fill:#ffb366
    
    class LoomPlugin,LoomExt,ConfigCtx core
    class DecompInterface,CFR,FernFlower,VineFlower decompiler
    class MappingSystem,MojangMap,YarnMap,ParchmentMap,IntermediaryMap mapping
    class MCProvider,LibMgmt,JarSplit,JarMerge processing
    class RunConfigs,ProjGen,IdeaConfig ide
    
    %% Click events for component mapping
    click LoomPlugin "https://github.com/fabricmc/fabric-loom/blob/dev/1.9/src/main/java/net/fabricmc/loom/LoomGradlePlugin.java"
    click LoomExt "https://github.com/fabricmc/fabric-loom/blob/dev/1.9/src/main/java/net/fabricmc/loom/LoomGradleExtension.java"
    click ConfigCtx "https://github.com/fabricmc/fabric-loom/blob/dev/1.9/src/main/java/net/fabricmc/loom/configuration/ConfigContext.java"
    click DecompInterface "https://github.com/fabricmc/fabric-loom/blob/dev/1.9/src/decompilers/common/net/fabricmc/loom/decompilers/LoomInternalDecompiler.java"
    click CFR "https://github.com/fabricmc/fabric-loom/blob/dev/1.9/src/decompilers/cfr/net/fabricmc/loom/decompilers/cfr/LoomCFRDecompiler.java"
    click FernFlower "https://github.com/fabricmc/fabric-loom/blob/dev/1.9/src/decompilers/fernflower/net/fabricmc/loom/decompilers/fernflower/FabricFernFlowerDecompiler.java"
    click VineFlower "https://github.com/fabricmc/fabric-loom/blob/dev/1.9/src/decompilers/vineflower/net/fabricmc/loom/decompilers/vineflower/VineflowerDecompiler.java"
    click MappingSystem "https://github.com/fabricmc/fabric-loom/tree/dev/1.9/src/main/java/net/fabricmc/loom/configuration/providers/mappings"
    click MojangMap "https://github.com/fabricmc/fabric-loom/blob/dev/1.9/src/main/java/net/fabricmc/loom/configuration/providers/mappings/mojmap/MojangMappingLayer.java"
    click ParchmentMap "https://github.com/fabricmc/fabric-loom/blob/dev/1.9/src/main/java/net/fabricmc/loom/configuration/providers/mappings/parchment/ParchmentMappingLayer.java"
    click IntermediaryMap "https://github.com/fabricmc/fabric-loom/blob/dev/1.9/src/main/java/net/fabricmc/loom/configuration/providers/mappings/intermediary/IntermediaryMappingLayer.java"
    click MCProvider "https://github.com/fabricmc/fabric-loom/blob/dev/1.9/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftProvider.java"
    click LibMgmt "https://github.com/fabricmc/fabric-loom/tree/dev/1.9/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/library"
    click JarSplit "https://github.com/fabricmc/fabric-loom/blob/dev/1.9/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftJarSplitter.java"
    click JarMerge "https://github.com/fabricmc/fabric-loom/blob/dev/1.9/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftJarMerger.java"
    click RunConfigs "https://github.com/fabricmc/fabric-loom/blob/dev/1.9/src/main/java/net/fabricmc/loom/configuration/ide/RunConfig.java"
    click IdeaConfig "https://github.com/fabricmc/fabric-loom/blob/dev/1.9/src/main/java/net/fabricmc/loom/configuration/ide/idea/IdeaConfiguration.java"
    click IDESupport "https://github.com/fabricmc/fabric-loom/tree/dev/1.9/src/main/java/net/fabricmc/loom/configuration/ide"
```
