{
    "sourceFile": "Documentation/02_Developer_Guide/03_Key_Components.md",
    "activeCommit": 0,
    "commits": [
        {
            "activePatchIndex": 1,
            "patches": [
                {
                    "date": 1745494444361,
                    "content": "Index: \n===================================================================\n--- \n+++ \n"
                },
                {
                    "date": 1745934401039,
                    "content": "Index: \n===================================================================\n--- \n+++ \n@@ -64,5 +64,7 @@\n *   Validating the filename format of detected ZIPs to extract the intended preset name.\r\n *   Triggering the main asset processing logic (`main.run_processing`) for valid new ZIP files.\r\n *   Managing the movement of processed source ZIP files to 'processed' or 'error' directories.\r\n \r\n-These key components work together to provide the tool's functionality, separating concerns and utilizing concurrency for performance and responsiveness.\n\\ No newline at end of file\n+These key components work together to provide the tool's functionality, separating concerns and utilizing concurrency for performance and responsiveness.\r\n+\r\n+**Note on Data Passing:** As mentioned in the Architecture documentation, major changes to the data passing mechanisms between the GUI, Main (CLI orchestration), and `AssetProcessor` modules are currently being planned. The descriptions of module interactions and data flow within this document reflect the current state and will require review and updates once the plan for these changes is finalized.\n\\ No newline at end of file\n"
                }
            ],
            "date": 1745494444361,
            "name": "Commit-0",
            "content": "# Developer Guide: Key Components\r\n\r\nThis document describes the major classes and modules that form the core of the Asset Processor Tool.\r\n\r\n## `AssetProcessor` (`asset_processor.py`)\r\n\r\nThe `AssetProcessor` class is the central engine of the tool. It is responsible for processing a *single* input asset (either a ZIP archive or a folder) through the entire pipeline. Its key responsibilities include:\r\n\r\n*   Setting up and cleaning up a temporary workspace for processing.\r\n*   Extracting or copying input files to the workspace.\r\n*   Inventorying and classifying files based on configured rules (maps, models, extra, ignored, unrecognised).\r\n*   Determining asset metadata such as name, category, and archetype.\r\n*   Processing texture maps (resizing, format/bit depth conversion, handling Gloss->Roughness inversion, calculating statistics).\r\n*   Merging channels from different maps according to merge rules.\r\n*   Generating the `metadata.json` file containing details about the processed asset.\r\n*   Organizing the final output files into the structured library directory.\r\n*   Providing methods (`get_detailed_file_predictions`) used by the GUI for previewing file classification.\r\n\r\n## `Configuration` (`configuration.py`)\r\n\r\nThe `Configuration` class manages the tool's settings. It is responsible for:\r\n\r\n*   Loading the core default settings defined in `config.py`.\r\n*   Loading the supplier-specific rules from a selected preset JSON file (`Presets/*.json`).\r\n*   Merging the core settings and preset rules into a single, unified configuration object.\r\n*   Validating the loaded configuration to ensure required settings are present.\r\n*   Pre-compiling regular expression patterns defined in the preset for efficient file classification by the `AssetProcessor`.\r\n\r\nAn instance of the `Configuration` class is typically created once per asset processing task (within a worker process) to ensure isolated and correct settings for each asset.\r\n\r\n## `MainWindow` (`gui/main_window.py`)\r\n\r\nThe `MainWindow` class is the main application window for the Graphical User Interface (GUI). It handles the overall UI layout and user interaction:\r\n\r\n*   Sets up the main window structure, including panels for the preset editor and processing controls.\r\n*   Manages the layout of UI elements like the drag-and-drop area, preview table, buttons, and status bar.\r\n*   Connects user actions (button clicks, drag/drop events) to corresponding handler methods (slots).\r\n*   Interacts with background processing and prediction handlers (`ProcessingHandler`, `PredictionHandler`) via Qt signals and slots to update the UI safely from background threads.\r\n*   Manages the GUI-specific logging handler (`QtLogHandler`) to display logs in the UI console.\r\n\r\n## `ProcessingHandler` (`gui/processing_handler.py`)\r\n\r\nThe `ProcessingHandler` class is designed to run in a separate `QThread` within the GUI. Its purpose is to manage the execution of the main asset processing pipeline and optional Blender scripts in the background, preventing the GUI from freezing. It:\r\n\r\n*   Manages a `concurrent.futures.ProcessPoolExecutor` to run individual asset processing tasks (`AssetProcessor.process()`) in separate worker processes.\r\n*   Submits processing tasks to the pool and monitors their completion.\r\n*   Communicates progress, status updates, and results back to the `MainWindow` using Qt signals.\r\n*   Handles the execution of Blender scripts via subprocess calls after asset processing is complete.\r\n*   Provides logic for cancelling ongoing processing tasks (though cancellation of already running worker processes is not immediate).\r\n\r\n## `PredictionHandler` (`gui/prediction_handler.py`)\r\n\r\nThe `PredictionHandler` class also runs in a separate `QThread` in the GUI. It is responsible for generating file classification previews in the background without blocking the UI. It:\r\n\r\n*   Calls methods on the `AssetProcessor` (specifically `get_detailed_file_predictions`) to analyze input files and predict their classification and output names based on the selected processing preset.\r\n*   Uses a `ThreadPoolExecutor` for potentially concurrent prediction tasks.\r\n*   Sends the prediction results back to the `MainWindow` via Qt signals to update the preview table.\r\n\r\n## `ZipHandler` (`monitor.py`)\r\n\r\nThe `ZipHandler` is a custom event handler used by the `monitor.py` script, built upon the `watchdog` library. It is responsible for:\r\n\r\n*   Detecting file system events, specifically the creation of new `.zip` files, in the monitored input directory.\r\n*   Validating the filename format of detected ZIPs to extract the intended preset name.\r\n*   Triggering the main asset processing logic (`main.run_processing`) for valid new ZIP files.\r\n*   Managing the movement of processed source ZIP files to 'processed' or 'error' directories.\r\n\r\nThese key components work together to provide the tool's functionality, separating concerns and utilizing concurrency for performance and responsiveness."
        }
    ]
}