# myz21/mdm architecture

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

- Interactive diagram: https://gitdiagram.com/myz21/mdm
- Repository: https://github.com/myz21/mdm

## Overview

1. This is a single Spring Boot backend service for Apple MDM and agent management, organized as a modular monolith rather than separate deployable services. The application entry point is `AppleMdmApplication`, with most behavior split into package-level subsystems under `controllers`, `services`, `repositories`, and `models`.

2. The primary request entrypoints are REST controllers in `controllers/`. They cover major product areas: enrollment, device management, app/catalog management, ABM/DEP/VPP integration, remote control sessions, reports, system settings, and agent operations. These controllers are thin API adapters that delegate into service-layer workflows.

3. The service layer is where most business logic lives. It is further divided into domain-oriented packages such as `services/enrollment`, `services/agent`, `services/apple`, `services/app`, `services/device`, `services/report`, `services/screenshare`, `services/terminal`, and `services/vnc`. This split indicates the application handles both device lifecycle management and live session orchestration, not just CRUD APIs.

4. Persistence is handled through JPA repositories in `repositories/`, backed by a relational database. The data model is rich and Apple-MDM-specific: devices, identities, commands, enrollment history/status, app groups, enterprise apps, telemetry, presence, locations, policies, system settings, and audit logs. Flyway migrations in `src/main/resources/db/migration` define schema evolution, including later additions for command reporting, bulk commands, optimistic locking, and agent auth history.

5. The domain model is explicitly separated into persistent entities under `domains/` and API DTOs under `models/api/`. There are also specialized model packages for Apple certificates/protocols, profile payloads, and session state. This separation matters for architecture diagrams because external request/response shapes are not the same as database entities.

6. Device and agent management is a major subsystem. `services/agent` and related controllers support agent authentication, command dispatch, telemetry ingestion, location tracking, presence tracking, activity logging, push notifications, and geofence-related behavior. There is a time-based command timeout scheduler, suggesting asynchronous lifecycle handling around command delivery and completion.

7. Enrollment is another core subsystem and has several paths: standard enrollment, account-driven enrollment, web authentication enrollment, check-in, profile generation, disenrollment, and enrollment auditing. Enrollment also depends on identity and OAuth2/account resolution logic, which is reflected in resolver/strategy classes and `EnrollmentAuditService` / `EnrollmentStatusService`.

8. Apple ecosystem integrations are isolated in `services/apple` and related config classes. The codebase includes services for ABM/DEP, VPP, APNs push, certificates, SCEP, and command building/sending. Supporting model packages under `models/cert` and `models/profile` suggest the service generates Apple configuration profiles and certificate-backed payloads for managed devices.

9. Commands and policy application appear to be a central orchestration path. Policy changes trigger listeners in `event/listener`, which then drive command creation, queueing, sending, and compliance tracking. There are strategy classes for platform-specific payload generation across iOS, macOS, tvOS, visionOS, and watchOS, indicating policy generation is platform-aware.

10. The application also includes real-time collaboration and remote management subsystems. WebSocket configuration, Redis relay, and session models support screen sharing, remote terminal, and VNC-style connectivity. These live-session features are separated into dedicated services and handlers rather than being mixed into device CRUD logic.

11. Messaging and integration infrastructure is present beyond HTTP. RabbitMQ configuration, MQTT message routing, and Redis-backed command queueing indicate the system relies on async/event-driven flows for notifications, command delivery, and cross-node coordination. Redis is especially important for command queues and websocket/session relay behavior.

12. Reporting and analytics are treated as a separate read-optimized area. `services/report` and `controllers/ReportController` expose fleet health, compliance, enrollment trends, command trends, and security/device reports. The existence of custom repository implementations and query indexes in migrations suggests these are database-heavy aggregation queries rather than simple entity fetches.

13. Security is layered into the web boundary with custom filters and JWT handling. The repo includes agent-token authentication, platform permission checks, custom JWT conversion, and security context configuration. This implies distinct trust models for human/admin API calls versus device/agent calls.

14. Supporting concerns are handled through configuration modules: async execution, audit metadata, HTTP client beans, OpenAPI/Swagger docs, web configuration, Redis, MQTT, websocket, and enrollment-related properties. There is also a simple Thymeleaf template for `enrollment-login.html`, so the backend serves at least one server-rendered enrollment page in addition to JSON APIs.

15. Operationally, the project is built with Maven, packaged in Docker, and deployed via GitHub Actions. `application.yaml`, `config/license.dat`, and the deployment workflow indicate a conventional containerized Spring Boot service with externalized configuration and licensing.

Main entry points: [`src/main/java/com/arcyintel/arcops/apple_mdm/AppleMdmApplication.java`](https://github.com/myz21/mdm/blob/master/src/main/java/com/arcyintel/arcops/apple_mdm/AppleMdmApplication.java) (Apple MDM), [`src/main/java/com/arcyintel/arcops/apple_mdm/repositories`](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/repositories) (JPA Repos), [`src/main/java/com/arcyintel/arcops/apple_mdm/services/apple/command`](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/services/apple/command) (Command/Policy Engine), [`src/main/java/com/arcyintel/arcops/apple_mdm/controllers`](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/controllers) (Device/Agent API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["API Layer"]
  node_enrollment_api["Enrollment API<br/>REST controllers"]
  node_device_api["Device/Agent API<br/>REST controllers"]
  node_app_api["App/Account API<br/>REST controllers"]
  node_remote_api["Remote Ops API<br/>REST controllers"]
  node_report_api["Report/System API<br/>REST controllers"]
  node_api_models["API Models<br/>DTOs"]
end

subgraph group_domain["Service Layer"]
  node_app(("Apple MDM<br/>Spring Boot app"))
  node_enrollment_svc["Enrollment Orchestrator<br/>service workflows"]
  node_device_agent_svc["Device/Agent Ops<br/>service workflows"]
  node_apple_svc["Apple Integrations<br/>integration services"]
  node_command_policy_svc["Command/Policy Engine<br/>orchestration services"]
  node_app_svc["App Management<br/>service workflows"]
  node_session_svc["Remote Sessions<br/>session services"]
  node_report_svc["Report Analytics<br/>query services"]
  node_settings_svc["Settings<br/>config service"]
end

subgraph group_data["Persistence"]
  node_repos[("JPA Repos<br/>data access")]
  node_entities[("Domain Entities<br/>persistent model")]
  node_migrations["Flyway Migrations<br/>schema evolution"]
end

subgraph group_infra["Infrastructure"]
  node_security{{"Security"}}
  node_messaging{{"Messaging/Relay<br/>async infra"}}
  node_web_config{{"Web Config<br/>configuration"}}
end

node_app -->|"boots with"| node_security
node_app -->|"boots with"| node_web_config
node_app -->|"exposes"| node_enrollment_api
node_app -->|"exposes"| node_device_api
node_app -->|"exposes"| node_app_api
node_app -->|"exposes"| node_remote_api
node_app -->|"exposes"| node_report_api
node_enrollment_api -->|"delegates to"| node_enrollment_svc
node_device_api -->|"delegates to"| node_device_agent_svc
node_device_api -->|"delegates to"| node_command_policy_svc
node_app_api -->|"delegates to"| node_app_svc
node_app_api -->|"delegates to"| node_apple_svc
node_remote_api -->|"delegates to"| node_session_svc
node_report_api -->|"delegates to"| node_report_svc
node_report_api -->|"delegates to"| node_settings_svc
node_enrollment_svc -->|"reads/writes"| node_repos
node_device_agent_svc -->|"reads/writes"| node_repos
node_app_svc -->|"reads/writes"| node_repos
node_command_policy_svc -->|"reads/writes"| node_repos
node_report_svc -->|"queries"| node_repos
node_repos -->|"maps"| node_entities
node_migrations -->|"evolves"| node_entities
node_security -.->|"guards"| node_enrollment_api
node_security -.->|"guards"| node_device_api
node_messaging -.->|"supports"| node_device_agent_svc
node_messaging -.->|"supports"| node_command_policy_svc
node_messaging -.->|"supports"| node_session_svc
node_apple_svc -->|"provides"| node_command_policy_svc
node_command_policy_svc -->|"uses"| node_api_models
node_enrollment_svc -->|"uses"| node_api_models
node_app_svc -->|"uses"| node_api_models

click node_app "https://github.com/myz21/mdm/blob/master/src/main/java/com/arcyintel/arcops/apple_mdm/AppleMdmApplication.java"
click node_enrollment_api "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/controllers"
click node_device_api "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/controllers"
click node_app_api "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/controllers"
click node_remote_api "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/controllers"
click node_report_api "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/controllers"
click node_enrollment_svc "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/services/enrollment"
click node_device_agent_svc "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/services/agent"
click node_apple_svc "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/services/apple"
click node_command_policy_svc "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/services/apple/command"
click node_app_svc "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/services/app"
click node_session_svc "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/services/screenshare"
click node_report_svc "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/services/report"
click node_settings_svc "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/services/settings"
click node_repos "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/repositories"
click node_entities "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/domains"
click node_migrations "https://github.com/myz21/mdm/tree/master/src/main/resources/db/migration"
click node_security "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/configs/security"
click node_messaging "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/configs"
click node_web_config "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/configs"
click node_api_models "https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/models"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_enrollment_api,node_device_api,node_app_api,node_remote_api,node_report_api,node_api_models toneBlue
class node_app,node_enrollment_svc,node_device_agent_svc,node_apple_svc,node_command_policy_svc,node_app_svc,node_session_svc,node_report_svc,node_settings_svc toneAmber
class node_repos,node_entities,node_migrations toneMint
class node_security,node_messaging,node_web_config toneRose
```

## Components

### API Layer

REST controllers and request/response boundaries

- [Enrollment API](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/controllers): REST controllers · Enrollment, check-in, web auth, and profile endpoints · `src/main/java/com/arcyintel/arcops/apple_mdm/controllers`
- [Device/Agent API](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/controllers): REST controllers · Device, agent auth, command, notification, and MDM control endpoints · `src/main/java/com/arcyintel/arcops/apple_mdm/controllers`
- [App/Account API](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/controllers): REST controllers · App catalog, app groups, accounts, ABM, and enterprise app endpoints · `src/main/java/com/arcyintel/arcops/apple_mdm/controllers`
- [Remote Ops API](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/controllers): REST controllers · Screen share, terminal, VNC, and remote control endpoints · `src/main/java/com/arcyintel/arcops/apple_mdm/controllers`
- [Report/System API](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/controllers): REST controllers · Reporting, dashboard, settings, discovery, and certificate endpoints · `src/main/java/com/arcyintel/arcops/apple_mdm/controllers`
- [API Models](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/models): DTOs · Request/response models, cert payloads, profile payloads, and session state · `src/main/java/com/arcyintel/arcops/apple_mdm/models`

### Service Layer

Business workflows and orchestrators

- [Apple MDM](https://github.com/myz21/mdm/blob/master/src/main/java/com/arcyintel/arcops/apple_mdm/AppleMdmApplication.java): Spring Boot app · Application entry point and composition root · `src/main/java/com/arcyintel/arcops/apple_mdm/AppleMdmApplication.java`
- [Enrollment Orchestrator](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/services/enrollment): service workflows · Enrollment, status, audit, profile generation, auth strategy, and disenrollment flows · `src/main/java/com/arcyintel/arcops/apple_mdm/services/enrollment`
- [Device/Agent Ops](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/services/agent): service workflows · Agent auth, telemetry, location, presence, push, retention, and device lookup · `src/main/java/com/arcyintel/arcops/apple_mdm/services/agent`
- [Apple Integrations](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/services/apple): integration services · ABM/DEP/VPP, APNs, certificates, SCEP, and Apple-specific platform services · `src/main/java/com/arcyintel/arcops/apple_mdm/services/apple`
- [Command/Policy Engine](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/services/apple/command): orchestration services · Command build/send/queue, policy application, compliance tracking, and platform payload strategies · `src/main/java/com/arcyintel/arcops/apple_mdm/services/apple/command`
- [App Management](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/services/app): service workflows · App catalog, app groups, enterprise apps, iTunes app resolution, and temp storage · `src/main/java/com/arcyintel/arcops/apple_mdm/services/app`
- [Remote Sessions](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/services/screenshare): session services · Screen share, remote terminal, VNC, signaling, and relay handling · `src/main/java/com/arcyintel/arcops/apple_mdm/services/screenshare`
- [Report Analytics](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/services/report): query services · Fleet health, compliance, enrollment, command, and security reporting · `src/main/java/com/arcyintel/arcops/apple_mdm/services/report`
- [Settings](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/services/settings): config service · System setting read/write workflows · `src/main/java/com/arcyintel/arcops/apple_mdm/services/settings`

### Persistence

Entities, repositories, and schema evolution

- [JPA Repos](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/repositories): data access · Repository layer for devices, enrollment, apps, commands, settings, and logs · `src/main/java/com/arcyintel/arcops/apple_mdm/repositories`
- [Domain Entities](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/domains): persistent model · Relational entities for devices, identities, commands, enrollment, apps, policies, and telemetry · `src/main/java/com/arcyintel/arcops/apple_mdm/domains`
- [Flyway Migrations](https://github.com/myz21/mdm/tree/master/src/main/resources/db/migration): schema evolution · Versioned database changes for the MDM schema and reporting indexes · `src/main/resources/db/migration`

### Infrastructure

Security, messaging, realtime, and configuration

- [Security](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/configs/security): web security · JWT, agent token, platform permission, and security context filters · `src/main/java/com/arcyintel/arcops/apple_mdm/configs/security`
- [Messaging/Relay](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/configs): async infra · RabbitMQ, MQTT, Redis queueing, and websocket relay infrastructure · `src/main/java/com/arcyintel/arcops/apple_mdm/configs`
- [Web Config](https://github.com/myz21/mdm/tree/master/src/main/java/com/arcyintel/arcops/apple_mdm/configs): configuration · Async, HTTP, OpenAPI, Redis, websocket, and MVC configuration · `src/main/java/com/arcyintel/arcops/apple_mdm/configs`

## Connections

- Apple MDM → Security: boots with · Security is part of application composition
- Apple MDM → Web Config: boots with · Web and infra configuration are loaded at startup
- Apple MDM → Enrollment API: exposes · Public enrollment endpoints
- Apple MDM → Device/Agent API: exposes · Device and agent endpoints
- Apple MDM → App/Account API: exposes · App, account, and ABM endpoints
- Apple MDM → Remote Ops API: exposes · Remote session endpoints
- Apple MDM → Report/System API: exposes · Reporting and system endpoints
- Enrollment API → Enrollment Orchestrator: delegates to · REST layer forwards enrollment workflows
- Device/Agent API → Device/Agent Ops: delegates to · REST layer forwards agent/device workflows
- Device/Agent API → Command/Policy Engine: delegates to · Command endpoints orchestrate policy and command flow
- App/Account API → App Management: delegates to · App and account operations use app services
- App/Account API → Apple Integrations: delegates to · ABM/DEP/VPP and certificate operations use Apple integrations
- Remote Ops API → Remote Sessions: delegates to · Remote control APIs manage live sessions
- Report/System API → Report Analytics: delegates to · Reporting endpoints use aggregation services
- Report/System API → Settings: delegates to · Settings endpoints use settings service
- Enrollment Orchestrator → JPA Repos: reads/writes · Enrollment workflows persist status and audit data
- Device/Agent Ops → JPA Repos: reads/writes · Agent workflows persist telemetry, presence, and history
- App Management → JPA Repos: reads/writes · App and account workflows persist catalog and account data
- Command/Policy Engine → JPA Repos: reads/writes · Command orchestration persists commands and compliance state
- Report Analytics → JPA Repos: queries · Reports use repository-backed aggregation queries
- JPA Repos → Domain Entities: maps · Repositories operate on JPA entities
- Flyway Migrations → Domain Entities: evolves · Schema changes track entity and reporting evolution
- Security → Enrollment API: guards · Authentication and authorization at the web boundary
- Security → Device/Agent API: guards · Agent token and platform permission checks
- Messaging/Relay → Device/Agent Ops: supports · Async notifications, relay, and command delivery
- Messaging/Relay → Command/Policy Engine: supports · Queueing and event-driven command orchestration
- Messaging/Relay → Remote Sessions: supports · Websocket relay and session coordination
- Apple Integrations → Command/Policy Engine: provides · Apple command send/build primitives support policy execution
- Command/Policy Engine → API Models: uses · Command and policy flows consume DTOs and payload models
- Enrollment Orchestrator → API Models: uses · Enrollment APIs exchange DTOs and session/auth models
- App Management → API Models: uses · App and account endpoints use request/response models
