# jamf/reenroller architecture

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

- Interactive diagram: https://gitdiagram.com/jamf/reenroller
- Repository: https://github.com/jamf/reenroller

## Overview

- User Interface (UI) Layer – Represented by files such as Main.storyboard (in Base.lproj) and view controllers (e.g., HelpViewController.swift, SourceMdmViewController.swift, ViewController.swift). This layer handles user interactions like entering configuration details and displaying help information.
- Business Logic/Controller Layer – Include files like Command.swift, Globals.swift, and Alert.swift. These manage core logic, decision-making, and global parameters for the enrollment process.
- Networking/API Layer – Highlight components dealing with remote communications with Jamf Pro servers. Files such as ApiCall.swift and JamfPro.swift handle API requests, authentication (including bearer token support), and error handling.
- Installation and Scripting Artifacts – The preinstall and postinstall directories (ReEnroller/1 and ReEnroller/2) contain scripts executed during the enrollment package installation. Also note the presence of helper scripts like apiMDM_removal and the mobileconfig file (ReEnrollerNotification.mobileconfig) required for newer macOS versions.
- Configuration and Assets – This includes property list files (Info.plist, settings.plist, and ReEnroller-component.plist), entitlements (ReEnroller.entitlements), and asset catalogs (Assets.xcassets). These files describe the app’s resources, settings, and permissions.

##### Architectural Patterns and Technologies
- API Integration – Clearly indicate that the application communicates with external Jamf Pro servers using defined API calls. Label these components with authentication techniques (including the use of bearer tokens as mentioned in the README).
- Package and Deployment – Make a note that the application can build deployment packages containing preinstall and postinstall scripts, along with configuration profiles (mobileconfig) to manage enrollment on modern macOS versions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer (Storyboards & View Controllers)"
        UI1["Main.storyboard"]:::ui
        UI2["HelpViewController.swift"]:::ui
        UI3["SourceMdmViewController.swift"]:::ui
        UI4["ViewController.swift"]:::ui
    end

    %% Business Logic / Controller Layer
    subgraph "Business Logic"
        BL1["Command.swift"]:::business
        BL2["Globals.swift"]:::business
        BL3["Alert.swift"]:::business
    end

    %% Networking/API Layer
    subgraph "Networking/API Module"
        NW1["ApiCall.swift"]:::networking
        NW2["JamfPro.swift"]:::networking
        ES1["Source Jamf Pro Server"]:::networking
        ES2["Destination Jamf Pro Server"]:::networking
    end

    %% Installation and Scripting Artifacts
    subgraph "Deployment Scripts"
        D1["1/preinstall"]:::deployment
        D2["1/postinstall"]:::deployment
        D3["2/preinstall"]:::deployment
        D4["2/postinstall"]:::deployment
        D5["ade.sh"]:::deployment
        D6["ReEnrollerNotification.mobileconfig"]:::deployment
    end

    %% Configuration and Assets
    subgraph "Configuration & Assets"
        CFG1["Info.plist"]:::config
        CFG2["settings.plist"]:::config
        CFG3["ReEnroller-component.plist"]:::config
        CFG4["ReEnroller.entitlements"]:::config
        CFG5["Assets.xcassets"]:::config
    end

    %% Logging and Diagnostics
    subgraph "Logging & Diagnostics"
        LOG1["WriteToLog.swift"]:::log
        LOG2["Notes.md"]:::log
        LOG3["help/apiMDM_remove.txt"]:::log
    end

    %% Data Flow Connections
    UI1 -->|"user input"| BL1
    UI2 --> BL1
    UI3 --> BL1
    UI4 --> BL1

    BL1 -->|"initiate enrollment"| NW1
    BL1 -->|"initiate enrollment"| NW2
    NW1 -->|"API Request"| ES1
    NW1 -->|"API Request"| ES2
    NW2 -->|"API Request"| ES1
    NW2 -->|"API Request"| ES2

    NW1 -->|"response"| BL1
    NW2 -->|"response"| BL1

    %% Conditional flow for error handling and fallback
    BL1 -- "Success" --> NW1
    NW1 -- "Failback" --> BL1

    %% Deployment Trigger after business logic decisions
    BL1 -->|"trigger scripts"| D1
    BL1 --> D2
    BL1 --> D3
    BL1 --> D4
    BL1 --> D5
    BL1 --> D6

    %% Configuration Lookup
    BL1 -->|"load config"| CFG1
    BL1 --> CFG2
    BL1 --> CFG3
    BL1 --> CFG4
    BL1 --> CFG5

    %% Logging occurs at critical steps (using dashed lines)
    UI1 --- LOG1
    BL1 --- LOG1
    NW1 --- LOG1
    D1 --- LOG1
    CFG1 --- LOG1

    %% Additional logging links
    UI2 --- LOG2
    BL2 --- LOG2
    NW2 --- LOG3

    %% Click Events for UI Layer
    click UI1 "https://github.com/jamf/reenroller/blob/master/ReEnroller/Base.lproj/Main.storyboard"
    click UI2 "https://github.com/jamf/reenroller/blob/master/ReEnroller/HelpViewController.swift"
    click UI3 "https://github.com/jamf/reenroller/blob/master/ReEnroller/SourceMdmViewController.swift"
    click UI4 "https://github.com/jamf/reenroller/blob/master/ReEnroller/ViewController.swift"

    %% Click Events for Business Logic
    click BL1 "https://github.com/jamf/reenroller/blob/master/ReEnroller/Command.swift"
    click BL2 "https://github.com/jamf/reenroller/blob/master/ReEnroller/Globals.swift"
    click BL3 "https://github.com/jamf/reenroller/blob/master/ReEnroller/Alert.swift"

    %% Click Events for Networking/API Layer
    click NW1 "https://github.com/jamf/reenroller/blob/master/ReEnroller/ApiCall.swift"
    click NW2 "https://github.com/jamf/reenroller/blob/master/ReEnroller/JamfPro.swift"

    %% Click Events for Deployment Scripts
    click D1 "https://github.com/jamf/reenroller/tree/master/ReEnroller/1/preinstall"
    click D2 "https://github.com/jamf/reenroller/tree/master/ReEnroller/1/postinstall"
    click D3 "https://github.com/jamf/reenroller/tree/master/ReEnroller/2/preinstall"
    click D4 "https://github.com/jamf/reenroller/tree/master/ReEnroller/2/postinstall"
    click D5 "https://github.com/jamf/reenroller/blob/master/ReEnroller/ade.sh"
    click D6 "https://github.com/jamf/reenroller/blob/master/ReEnrollerNotification.mobileconfig"

    %% Click Events for Configuration and Assets
    click CFG1 "https://github.com/jamf/reenroller/blob/master/ReEnroller/Info.plist"
    click CFG2 "https://github.com/jamf/reenroller/blob/master/ReEnroller/settings.plist"
    click CFG3 "https://github.com/jamf/reenroller/blob/master/ReEnroller/ReEnroller-component.plist"
    click CFG4 "https://github.com/jamf/reenroller/blob/master/ReEnroller/ReEnroller.entitlements"
    click CFG5 "https://github.com/jamf/reenroller/blob/master/ReEnroller/Assets.xcassets"

    %% Click Events for Logging and Diagnostics
    click LOG1 "https://github.com/jamf/reenroller/blob/master/ReEnroller/WriteToLog.swift"
    click LOG2 "https://github.com/jamf/reenroller/blob/master/Notes.md"
    click LOG3 "https://github.com/jamf/reenroller/blob/master/ReEnroller/help/apiMDM_remove.txt"

    %% Styles
    classDef ui fill:#D6E9F8,stroke:#1F78C1,stroke-width:2px;
    classDef business fill:#FCF6BD,stroke:#D4AC0D,stroke-width:2px;
    classDef networking fill:#D5F5E3,stroke:#28B463,stroke-width:2px;
    classDef deployment fill:#FADBD8,stroke:#E74C3C,stroke-width:2px;
    classDef config fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
    classDef log fill:#F0F3F4,stroke:#BDC3C7,stroke-width:2px;
```
