# micke-k/intunemanagement architecture

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

- Interactive diagram: https://gitdiagram.com/micke-k/intunemanagement
- Repository: https://github.com/micke-k/intunemanagement

## Overview

##### Project type and purpose
- This is a Windows desktop application built in PowerShell with a WPF front-end.
- Purpose: Provide a UI (and optional CLI/silent mode) to manage Microsoft Intune and Azure objects via MSAL-authenticated calls to Microsoft Graph and Azure Management APIs. Features include Export/Import of JSON objects, Compare, Bulk Copy, Documentation, ADMX import, etc.

##### Top-level components
a. UI Layer (WPF)
- XAML Views: located under `/Xaml` and `/Themes`
- Code-behind entry script: `Start-IntuneManagement.ps1` (and CMD wrappers)
b. Core Framework Modules
- `Core.psm1`: UI management, settings, logging support
- `CloudAPIPowerShellManagement.psm1`: foundational abstractions for Graph/Azure calls, token cache helpers (`CS/TokenCacheHelperEx.cs`, `HttpFactoryWithProxy.cs`)
c. Extension Modules (features plug-ins)
- Modules under `/Extensions` (e.g., `Compare.psm1`, `Import.psm1`, `MSGraph.psm1`, `IntuneTools.psm1`, …)
d. Authentication library
- MSAL DLL: `Microsoft.Identity.Client.dll` (packaged copy + optional Az/MSAL.PS fallback)
e. Services Layer
- Authentication Service (wraps MSAL)
- Graph API Service (calls Microsoft Graph REST endpoints)
- Azure Management API Service (undocumented endpoints)
f. Data & Configuration
- File-system: exported JSON object folders, ADMX/ADML files, bulk-job JSON settings
- Registry or JSON settings file `%LOCALAPPDATA%\CloudAPIPowerShellManagement\Settings.json`
- Application logs (CMTrace format)
g. External endpoints
- Azure AD (token issuance)
- Microsoft Graph API (beta endpoints)
- Azure Management API

##### Relationships and data flows
- UI Layer → Core Framework: calls cmdlets/functions for generic UI, settings, logging
- Core Framework → Extension Modules: dispatch user actions (Export, Import, Compare, etc.)
- Extension Modules → Services Layer:
- Auth Service retrieves token via MSAL
- Graph Service / AzureMgmt Service issues REST calls
- Services Layer ↔ External Endpoints over HTTPS
- Extension Modules → File System: read/write JSON export files, read ADMX/ADML, read/write settings JSON, registry I/O
- CLI Entrypoint (`Start-*.ps1` with –Silent) → Core/Extensions (headless execution)

##### Architectural patterns & design principles
- Modular plug-in architecture: core modules + multiple independent extension modules
- MVVM‐inspired separation: XAML views separated from PS “view models” (cmdlet logic)
- Layered design: UI → Orchestration (Core) → Feature Modules → Services → External APIs
- Configurable Data Store: registry vs. JSON file for settings, file-system for exported data
- Optional Headless mode: pipeline friendly

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "UI Layer"
        XAML["XAML Views"]:::ui
        Themes["Themes"]:::ui
        StartPS["Start-IntuneManagement.ps1"]:::ui
        subgraph "CMD Wrappers"
            CMD1["Start.cmd"]:::ui
            CMD2["Start-WithApp.cmd"]:::ui
            CMD3["Start-WithConsole.cmd"]:::ui
            CMD4["Start-WithJson.cmd"]:::ui
        end
    end

    subgraph "Core Framework"
        PSD1["CloudAPIPowerShellManagement.psd1"]:::core
        PSM1["CloudAPIPowerShellManagement.psm1"]:::core
        CORE["Core.psm1"]:::core
    end

    subgraph "Extension Modules"
        Compare["Compare.psm1"]:::extension
        Copy["Copy.psm1"]:::extension
        IntuneApp["IntuneAppManagement.psm1"]:::extension
        IntuneAssign["IntuneAssignments.psm1"]:::extension
        IntuneFilter["IntuneFilterUsage.psm1"]:::extension
        IntuneTools["IntuneTools.psm1"]:::extension
        DocGen["Documentation.psm1"]:::extension
        DocCust["DocumentationCustom.psm1"]:::extension
        DocHTML["DocumentationHTML.psm1"]:::extension
        DocMD["DocumentationMD.psm1"]:::extension
        DocWord["DocumentationWord.psm1"]:::extension
    end

    subgraph "Services Layer"
        Auth["MSALAuthentication.psm1"]:::service
        TokenCache["TokenCacheHelperEx.cs"]:::service
        HTTPFactory["HttpFactoryWithProxy.cs"]:::service
        GraphSvc["MSGraph.psm1"]:::service
        AzureMgmt["EndpointManager.psm1"]:::service
        AzureInfo["EndpointManagerInfo.psm1"]:::service
    end

    subgraph "Data & Configuration"
        JSONObj["JSON Object Definitions"]:::datastore
        LocStrings["Localization Strings"]:::datastore
        AppCats["AppTypes & Categories"]:::datastore
        ADMX["ADMX Guidance"]:::datastore
        Settings["Settings.json"]:::datastore
        Logs["Application Logs"]:::datastore
    end

    subgraph "External Systems"
        AzureAD["Azure AD"]:::external
        MSGraphAPI["Microsoft Graph API"]:::external
        AzureMgmtAPI["Azure Management API"]:::external
    end

    %% Relationships
    StartPS -->|dispatch| CORE
    CMD1 -->|dispatch| CORE
    CMD2 -->|dispatch| CORE
    CMD3 -->|dispatch| CORE
    CMD4 -->|dispatch| CORE
    CORE -->|invoke| Compare
    CORE -->|invoke| Copy
    CORE -->|invoke| IntuneApp
    CORE -->|invoke| IntuneAssign
    CORE -->|invoke| IntuneFilter
    CORE -->|invoke| IntuneTools
    CORE -->|invoke| DocGen
    CORE -->|invoke| DocCust
    CORE -->|invoke| DocHTML
    CORE -->|invoke| DocMD
    CORE -->|invoke| DocWord

    Compare -->|auth| Auth
    Copy -->|auth| Auth
    IntuneApp -->|auth| Auth
    IntuneAssign -->|auth| Auth
    IntuneFilter -->|auth| Auth
    IntuneTools -->|auth| Auth
    DocGen -->|auth| Auth
    DocCust -->|auth| Auth
    DocHTML -->|auth| Auth
    DocMD -->|auth| Auth
    DocWord -->|auth| Auth

    Auth -->|token cache| TokenCache
    Auth -->|uses HTTP| HTTPFactory
    Compare -->|call API| GraphSvc
    Copy -->|call API| GraphSvc
    IntuneApp -->|call API| GraphSvc
    IntuneAssign -->|call API| GraphSvc
    IntuneFilter -->|call API| GraphSvc
    IntuneTools -->|call API| GraphSvc

    Compare -->|call API| AzureMgmt
    Copy -->|call API| AzureMgmt
    IntuneApp -->|call API| AzureMgmt
    IntuneAssign -->|call API| AzureMgmt
    IntuneFilter -->|call API| AzureInfo
    IntuneTools -->|call API| AzureInfo

    Auth -->|OAuth2| AzureAD
    GraphSvc -->|REST over HTTPS| MSGraphAPI
    AzureMgmt -->|REST over HTTPS| AzureMgmtAPI
    AzureInfo -->|REST over HTTPS| AzureMgmtAPI

    Compare -.->|read/write JSON| JSONObj
    Copy -.->|read/write JSON| JSONObj
    IntuneApp -.->|read/write JSON| JSONObj
    IntuneAssign -.->|read/write JSON| JSONObj
    IntuneFilter -.->|read/write JSON| JSONObj
    IntuneTools -.->|read/write JSON| JSONObj
    DocGen -.->|read docs| LocStrings
    DocCust -.->|read docs| LocStrings
    DocHTML -.->|read docs| LocStrings
    DocMD -.->|read docs| LocStrings
    DocWord -.->|read docs| LocStrings

    Compare -.->|settings| Settings
    Copy -.->|settings| Settings

    Compare -.->|logs| Logs
    Copy -.->|logs| Logs

    %% Click events
    click XAML "https://github.com/micke-k/intunemanagement/tree/master/Xaml/"
    click Themes "https://github.com/micke-k/intunemanagement/tree/master/Themes/"
    click StartPS "https://github.com/micke-k/intunemanagement/blob/master/Start-IntuneManagement.ps1"
    click CMD1 "https://github.com/micke-k/intunemanagement/blob/master/Start.cmd"
    click CMD2 "https://github.com/micke-k/intunemanagement/blob/master/Start-WithApp.cmd"
    click CMD3 "https://github.com/micke-k/intunemanagement/blob/master/Start-WithConsole.cmd"
    click CMD4 "https://github.com/micke-k/intunemanagement/blob/master/Start-WithJson.cmd"
    click PSD1 "https://github.com/micke-k/intunemanagement/blob/master/CloudAPIPowerShellManagement.psd1"
    click PSM1 "https://github.com/micke-k/intunemanagement/blob/master/CloudAPIPowerShellManagement.psm1"
    click CORE "https://github.com/micke-k/intunemanagement/blob/master/Core.psm1"
    click Auth "https://github.com/micke-k/intunemanagement/blob/master/Extensions/MSALAuthentication.psm1"
    click TokenCache "https://github.com/micke-k/intunemanagement/blob/master/CS/TokenCacheHelperEx.cs"
    click HTTPFactory "https://github.com/micke-k/intunemanagement/blob/master/CS/HttpFactoryWithProxy.cs"
    click GraphSvc "https://github.com/micke-k/intunemanagement/blob/master/Extensions/MSGraph.psm1"
    click AzureMgmt "https://github.com/micke-k/intunemanagement/blob/master/Extensions/EndpointManager.psm1"
    click AzureInfo "https://github.com/micke-k/intunemanagement/blob/master/Extensions/EndpointManagerInfo.psm1"
    click Compare "https://github.com/micke-k/intunemanagement/blob/master/Extensions/Compare.psm1"
    click Copy "https://github.com/micke-k/intunemanagement/blob/master/Extensions/Copy.psm1"
    click IntuneApp "https://github.com/micke-k/intunemanagement/blob/master/Extensions/IntuneAppManagement.psm1"
    click IntuneAssign "https://github.com/micke-k/intunemanagement/blob/master/Extensions/IntuneAssignments.psm1"
    click IntuneFilter "https://github.com/micke-k/intunemanagement/blob/master/Extensions/IntuneFilterUsage.psm1"
    click IntuneTools "https://github.com/micke-k/intunemanagement/blob/master/Extensions/IntuneTools.psm1"
    click DocGen "https://github.com/micke-k/intunemanagement/blob/master/Extensions/Documentation.psm1"
    click DocCust "https://github.com/micke-k/intunemanagement/blob/master/Extensions/DocumentationCustom.psm1"
    click DocHTML "https://github.com/micke-k/intunemanagement/blob/master/Extensions/DocumentationHTML.psm1"
    click DocMD "https://github.com/micke-k/intunemanagement/blob/master/Extensions/DocumentationMD.psm1"
    click DocWord "https://github.com/micke-k/intunemanagement/blob/master/Extensions/DocumentationWord.psm1"
    click JSONObj "https://github.com/micke-k/intunemanagement/tree/master/Documentation/ObjectInfo/"
    click LocStrings "https://github.com/micke-k/intunemanagement/blob/master/Documentation/Strings-*.json"
    click AppCats "https://github.com/micke-k/intunemanagement/blob/master/Documentation/AppTypes.json"
    click ADMX "https://github.com/micke-k/intunemanagement/blob/master/ADMXImport.md"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#1f78b4,color:#000;
    classDef core fill:#d4f1f9,stroke:#17a2b8,color:#000;
    classDef extension fill:#d4edda,stroke:#28a745,color:#000;
    classDef service fill:#fff3cd,stroke:#ffc107,color:#000;
    classDef external fill:#ffe5b4,stroke:#fd7e14,color:#000;
    classDef datastore fill:#f0f0f0,stroke:#6c757d,color:#000;
```
