# jamf/certificatesdk architecture

> Architecture diagram of the GitHub repository jamf/certificatesdk, 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/certificatesdk
- Repository: https://github.com/jamf/certificatesdk

## Overview

##### Main Components
- CertificateSDK XCFramework: Represented as an external library/framework that encapsulates all certificate request logic. Indicate that it supports various architectures (ios-arm64, simulator versions, xros-arm64, etc.).
- Sample Application Modules: There are two main client apps:
- Certificate SDK Sample iOS: Contains view controllers (e.g., ActionLogViewController, SetupTestViewController), storyboard files, and app delegate logic.
- Certificate SDK Sample visionOS: A SwiftUI-based app with components like ContentView, RequestTypeView, and dedicated entry points.
- Shared Module (Certificate SDK Sample Shared): Contains common code for handling certificate requests (CertificateRequestManager), keychain operations (KeychainHandler), configuration (CertRequestConfiguration.swift), and local notifications.

##### Additional External Elements
- Jamf Pro Server (External Dependency): Show how the configuration is used to communicate with the Jamf Pro server to obtain the certificate using the keys defined in the managed app configuration.

##### Relationships and Interactions
- Both client apps (iOS and visionOS) leverage the shared module to access common certificate management features.
- The shared module, particularly the CertificateRequestManager, interacts directly with the CertificateSDK (external framework) to initiate certificate requests.
- The CertificateSDK, in turn, encapsulates the lower-level API calls and encryption, interfacing with the external Jamf Pro server over the network.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project clearly separates presentation (iOS and visionOS apps), business logic (shared module), and the certificate functionality encapsulated in the CertificateSDK XCFramework.
- Modularity: The use of Swift Package Manager for installing the SDK and the shared structure allow the certificate request functionality to be reused across different platforms.
- Platform-Specific Adaptations: While the business logic is shared, the UI and interaction components are tailored to each platform.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Components - iOS App
    subgraph "Certificate SDK Sample iOS App"
        direction TB
        A["ActionLogViewController.swift"]:::ui
        B["SetupTestViewController.swift"]:::ui
        C["AppDelegate.swift"]:::ui
        D["Base.lproj Storyboards"]:::ui
    end

    %% UI Components - visionOS App
    subgraph "Certificate SDK Sample visionOS App"
        direction TB
        V1["CertificateSDKSampleVisionOSApp.swift"]:::ui
        V2["ContentView.swift"]:::ui
        V3["RequestTypeView.swift"]:::ui
        V4["Assets"]:::ui
    end

    %% Shared Business Logic Module
    subgraph "Certificate SDK Sample Shared Module"
        direction TB
        S1["CertificateRequestManager.swift"]:::shared
        S2["KeychainHandler.swift"]:::shared
        S3["CertRequestConfiguration.swift"]:::shared
        S4["LocalNotificationService.swift"]:::shared
    end

    %% External Framework and Service
    X["CertificateSDK XCFramework"]:::external
    E["Jamf Pro Server"]:::external

    %% Connections between components
    C -->|"calls"| S1
    V1 -->|"calls"| S1
    S1 -->|"invokes"| X
    X -->|"communicatesTo"| E

    %% Click Events using component mapping paths
    click X "https://github.com/jamf/certificatesdk/blob/main/CertificateSDK.xcframework"
    click C "https://github.com/jamf/certificatesdk/tree/main/Certificate SDK Sample iOS"
    click V1 "https://github.com/jamf/certificatesdk/tree/main/Certificate SDK Sample visionOS"
    click S1 "https://github.com/jamf/certificatesdk/tree/main/Certificate SDK Sample Shared"

    %% Styles for color coding
    classDef ui fill:#FFD700,stroke:#B8860B,stroke-width:2px;
    classDef shared fill:#87CEFA,stroke:#4682B4,stroke-width:2px;
    classDef external fill:#90EE90,stroke:#32CD32,stroke-width:2px;
```
