# leminlimez/nugget architecture

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

- Interactive diagram: https://gitdiagram.com/leminlimez/nugget
- Repository: https://github.com/leminlimez/nugget

## Overview

##### Project Type and Purpose
- This is a Python-based tool designed to leverage the sparserestore exploit to unlock additional functionalities on iOS devices. It targets functionalities like enabling Dynamic Island, iPhone X gestures, various device tweaks, and more.
- The README indicates a dual nature: a GUI-driven application (using PySide6) for interactive use and a CLI option (via cli_app.py) for command-line access. It also integrates device management and exploit modules for low-level file operations.

##### Analyzing the File Structure
- Core Modules:
- Sparserestore directory includes backup.py, mbdb.py, and restore.py. This represents the heart of the exploit operations.
- devicemanagement contains critical classes that handle device state, constants, and device-specific operations.
- tweaks holds the logic for applying specific device tweaks (like eligibility, daemons, custom settings).
- Controller Layer:
- The controllers directory contains handlers for paths, plist files, and web requests. These modules abstract the data processing and system interfacing required by the exploit.
- User Interface:
- The gui directory and qt folder (which contains .ui files and resource files) denote the front-end components built on the PySide6 framework.
- main_app.py appears to be the entry point for the GUI application.
- Additional Support:
- Files under "files/eligibility" provide essential configuration/plist data.
- compile.py, mainwindow_ui.py, and resources_rc.py indicate additional build and compilation tooling for UI resources.
- The project also includes common configuration files (requirements.txt, .gitignore, etc.) and administrative documentation (documentation.md, credits, README).

a. Main Components to Represent:
- Graphical User Interface: Two parts here—a “GUI Layer” (from the gui folder) and “Qt UI Components” (from the qt folder and associated compiled UI files)

b. Relationships/Interactions:
- That some modules might share data through configuration files (as seen in the “files” directory) or via constants defined in the modules.

##### Architectural Patterns & Design Principles
- The project adopts a loosely layered architecture:
- A front-end layer (GUI/CLI) that communicates with a middle “Controller” layer.
- A back-end core comprised of low-level exploit functions (Sparserestore), device management, and tweaking logic.
- This separation (similar to an MVC or layered pattern) ensures that the UI logic is isolated from the core functionality.
- That file processing (plist handling, eligibility data) is a critical component. Include a note on how configuration files drive some decisions made in the device management and tweaks modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        GUI_Layer["GUI Layer (gui/)"]:::ui
        MainApp["Main UI Application (main_app.py)"]:::ui
        CLI["CLI Application (cli_app.py)"]:::ui
        Qt["Qt UI Components (qt/)"]:::ui
    end

    %% Controller Layer
    subgraph "Controller Layer"
        Controllers["Controllers (controllers/)"]:::controller
    end

    %% Core Exploit Modules
    subgraph "Core Exploit Modules"
        Sparserestore["Sparserestore Module (Sparserestore/)"]:::backend
        DevMgmt["Device Management Module (devicemanagement/)"]:::backend
        Tweaks["Tweaks Module (tweaks/)"]:::backend
    end

    %% Support and External Services
    subgraph "Support & External"
        Config["Configuration/Eligibility Files (files/eligibility/)"]:::config
        External["External Services/Dependencies"]:::external
    end

    %% Connections from UI to Controllers
    GUI_Layer -->|"UI_command"| Controllers
    MainApp -->|"UI_command"| Controllers
    CLI -->|"CLI_command"| Controllers
    Qt -->|"UI_event"| Controllers

    %% Connections from Controllers to Core Modules
    Controllers -->|"execute_exploit"| Sparserestore
    Controllers -->|"manage_device"| DevMgmt
    Controllers -->|"apply_tweaks"| Tweaks

    %% Interactions among Core Modules
    DevMgmt <-->|"data_sync"| Tweaks

    %% Connections from Core Modules to External Dependencies
    Sparserestore -->|"device_ops"| External
    DevMgmt -->|"uses_services"| External
    Tweaks -->|"uses_services"| External

    %% Configuration influence
    Config -->|"provides_config"| DevMgmt
    Config -->|"provides_config"| Tweaks

    %% Click Events
    click Sparserestore "https://github.com/leminlimez/nugget/tree/main/Sparserestore/"
    click DevMgmt "https://github.com/leminlimez/nugget/tree/main/devicemanagement/"
    click Tweaks "https://github.com/leminlimez/nugget/tree/main/tweaks/"
    click Controllers "https://github.com/leminlimez/nugget/tree/main/controllers/"
    click GUI_Layer "https://github.com/leminlimez/nugget/tree/main/gui/"
    click MainApp "https://github.com/leminlimez/nugget/blob/main/main_app.py"
    click Qt "https://github.com/leminlimez/nugget/tree/main/qt/"
    click Config "https://github.com/leminlimez/nugget/tree/main/files/eligibility/"

    %% Styling Classes
    classDef ui fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef controller fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef backend fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px,stroke-dasharray: 5,5;
    classDef config fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
```
