# 777chara777/moddecoder architecture

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

- Interactive diagram: https://gitdiagram.com/777chara777/moddecoder
- Repository: https://github.com/777chara777/moddecoder

## Overview

##### And Label Main Components
- UI/Presentation Layer:
- Component: GUI Module
- File: gui/gui.py
- Role: Provides the user interface which lets the user select a .jar mod file, choose an output directory, and initiate the decode process.
- Application Entry Point & Orchestration:
- Component: Main Application
- File: app.py
- Role: Acts as the central orchestrator, tying together the GUI, decoding/extraction, and analysis modules.
- Decoding and Extraction:
- Component: Jar Extraction Module
- File: decodejar/decodejar.py
- Role: Manages extraction of .jar files and acts as a precursor to further analysis.
- Mod Structure Analysis:
- Component: Fabric Mod Analysis
- File: FabricStructur/FabricStructur.py
- Role: Analyzes the structure specific to Fabric mods.
- Parsing & Remapping:
- Component: Parser Module
- Files:
- parser/parser/parser_mapper.py and parser/parser/log_mapper.py – to map and interpret mod file structures or logs.
- parser/remapper/download_mapper.py – likely handling remapping (perhaps adjusting names or metadata).
- Role: Processes, maps, and converts data for further analysis.
- Utility & Supporting Libraries:
- Component: Logging and Configuration
- Files: libs/Logger (with its submodules) and libs/Config/__init__.py
- Role: Centralized logging and configuration management across the application.
- Component: Thread Management
- File: libs/StoppableThread.py
- Role: Provides mechanisms for safe threading in long-running tasks.
- Component: Decompilation Utility
- File: libs/fernflower.jar
- Role: External tool integrated to decompile Java code extracted from mod files.

##### Relationships & Data Flow
- App.py then delegates tasks to:
- The jar extraction module (decodejar/decodejar.py) for extracting the contents.
- The decompilation process via the external FernFlower jar.
- The Fabric mod analysis module (FabricStructur/FabricStructur.py) to examine mod structure.
- For complex operations that require parallelism (for instance, concurrent extraction or analysis), the StoppableThread utility is used. This should be noted as an underlying service supporting the key modules.

##### Architectural Patterns & Design Principles
- Modularity: Each major function (UI, extraction, analysis, parsing, logging) is encapsulated in its own module/folder.
- Layered Architecture: Separate the presentation (GUI) from the business logic (app.py, extraction/analysis routines) and support modules (parsing, logging, threading).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interface"
        GUI["GUI Module"]
    end

    subgraph "Core Orchestration"
        App["Main Application (app.py)"]
    end

    subgraph "Mod Decoding Suite"
        Extraction["Jar Extraction Module"]
        Fern["FernFlower (External Decompiler)"]
        Analysis["Fabric Mod Analysis"]
    end

    subgraph "Parser Modules"
        ParserMapper["Parser Mapper"]
        LogMapper["Log Mapper"]
        Remapping["Remapping Module"]
    end

    subgraph "Supporting Utilities"
        Logger["Logger"]
        Config["Config"]
        Thread["Thread Management"]
    end

    %% Primary Flow
    GUI -->|"User_Actions"| App
    App -->|"Extract_Mod"| Extraction
    App -->|"Decompile"| Fern
    App -->|"Analyze_Mod"| Analysis

    %% Extraction & Analysis flow into Parser Modules
    Extraction -->|"Extraction_Output"| ParserMapper
    Extraction -->|"Extraction_Output"| LogMapper
    Analysis -->|"Analysis_Output"| ParserMapper
    Analysis -->|"Analysis_Output"| LogMapper

    ParserMapper -->|"Remap_Data"| Remapping
    LogMapper -->|"Remap_Data"| Remapping

    %% Shared Utility Dependencies (bidirectional)
    App <==>|"Uses"| Logger
    App <==>|"Uses"| Config

    Extraction <==>|"Uses"| Logger
    Extraction <==>|"Uses"| Config

    Analysis <==>|"Uses"| Logger
    Analysis <==>|"Uses"| Config

    ParserMapper <==>|"Uses"| Logger
    ParserMapper <==>|"Uses"| Config

    LogMapper <==>|"Uses"| Logger
    LogMapper <==>|"Uses"| Config

    Remapping <==>|"Uses"| Logger
    Remapping <==>|"Uses"| Config

    GUI <==>|"Uses"| Logger
    GUI <==>|"Uses"| Config

    %% Thread Management supports parallel tasks
    Extraction -->|"Parallel_Task_Support"| Thread
    Analysis -->|"Parallel_Task_Support"| Thread
    Remapping -->|"Parallel_Task_Support"| Thread

    %% Click Events for Component Mappings
    click GUI "https://github.com/777chara777/moddecoder/blob/main/gui/gui.py"
    click App "https://github.com/777chara777/moddecoder/blob/main/app.py"
    click Extraction "https://github.com/777chara777/moddecoder/blob/main/decodejar/decodejar.py"
    click Analysis "https://github.com/777chara777/moddecoder/blob/main/FabricStructur/FabricStructur.py"
    click ParserMapper "https://github.com/777chara777/moddecoder/blob/main/parser/parser/parser_mapper.py"
    click LogMapper "https://github.com/777chara777/moddecoder/blob/main/parser/parser/log_mapper.py"
    click Remapping "https://github.com/777chara777/moddecoder/blob/main/parser/remapper/download_mapper.py"
    click Logger "https://github.com/777chara777/moddecoder/blob/main/libs/Logger/logger.py"
    click Config "https://github.com/777chara777/moddecoder/blob/main/libs/Config/__init__.py"
    click Thread "https://github.com/777chara777/moddecoder/blob/main/libs/StoppableThread.py"
    click Fern "https://github.com/777chara777/moddecoder/blob/main/libs/fernflower.jar"

    %% Styles
    classDef gui fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef main fill:#9cf,stroke:#333,stroke-width:2px;
    classDef extraction fill:#9f9,stroke:#333,stroke-width:2px;
    classDef analysis fill:#fc9,stroke:#333,stroke-width:2px;
    classDef parser fill:#ccf,stroke:#333,stroke-width:2px;
    classDef utility fill:#ddd,stroke:#333,stroke-width:2px;
    classDef external fill:#ffe,stroke:#333,stroke-width:2px;

    class GUI gui;
    class App main;
    class Extraction extraction;
    class Analysis analysis;
    class ParserMapper parser;
    class LogMapper parser;
    class Remapping parser;
    class Logger utility;
    class Config utility;
    class Thread utility;
    class Fern external;
```
