# micromdm/nanomdm architecture

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

- Interactive diagram: https://gitdiagram.com/micromdm/nanomdm
- Repository: https://github.com/micromdm/nanomdm
- Video tour (about a minute): https://gitdiagram.com/micromdm/nanomdm/video

## Overview

NanoMDM is a composable Apple MDM server: devices send check-ins and command results over HTTP; handlers adapt those requests to services, which process enrollment state and commands through storage. API clients can queue commands and pushes, while APNs delivery, webhooks, certificate authorization, declarative-management hooks, and migration are additional product capabilities. The README documents the handler/service/storage layers; excerpts show core service and push behavior. Some wiring and subsystem details are unsampled, so unsupported call relationships are omitted.

Main entry points: [`service/nanomdm/service.go`](https://github.com/micromdm/nanomdm/blob/main/service/nanomdm/service.go) (Core MDM service), [`http/mdm/mdm_cert.go`](https://github.com/micromdm/nanomdm/blob/main/http/mdm/mdm_cert.go) (MDM HTTP handlers), [`http/api/api.go`](https://github.com/micromdm/nanomdm/blob/main/http/api/api.go) (API handlers), [`storage/allmulti/allmulti.go`](https://github.com/micromdm/nanomdm/blob/main/storage/allmulti/allmulti.go) (Multi-store dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingress["HTTP ingress"]
  node_mdm_http["MDM HTTP handlers<br/>[mdm_cert.go]"]
  node_api_http["API handlers<br/>[api.go]"]
end

subgraph group_services["MDM services"]
  node_mdm_protocol["MDM protocol<br/>[checkin.go]"]
  node_core_service["Core MDM service<br/>[service.go]"]
  node_cert_auth["Certificate authorization<br/>[service.go]"]
  node_multi_service["Multi-command targeting<br/>[multi.go]"]
  node_dm_hook["Declarative management hook<br/>[dmhook.go]"]
end

subgraph group_state["Persistence"]
  node_storage_contracts["Storage interfaces<br/>[storage.go]"]
  node_storage_dispatch["Multi-store dispatch<br/>[allmulti.go]"]
  node_kv_storage[("KV storage<br/>[mdm.go]")]
  node_sql_storage[("SQL storage<br/>[mysql.go]")]
  node_file_storage[("File storage<br/>[file.go]")]
end

subgraph group_integrations["External integrations"]
  node_webhook["Webhook events<br/>[service.go]"]
  node_push_service["Push delivery service<br/>[service.go]"]
  node_push_provider["APNs provider<br/>[provider.go]"]
end

subgraph group_runtime["Server runtime"]
  node_server["NanoMDM server<br/>[main.go]"]
  node_migration["Migration client<br/>[main.go]"]
end

node_devices(("Apple devices"))
node_api_clients(("API clients"))
node_apns{{"Apple APNs"}}
node_webhook_target{{"Webhook target"}}

node_devices -->|"send check-ins"| node_mdm_http
node_mdm_http -->|"adapts requests"| node_core_service
node_mdm_http -->|"handles messages"| node_mdm_protocol
node_api_clients -->|"submit API requests"| node_api_http
node_api_http -->|"queues commands"| node_core_service
node_api_http -->|"requests pushes"| node_push_service
node_core_service -->|"dispatches state operations"| node_storage_contracts
node_core_service -.->|"uses authorization wrapper"| node_cert_auth
node_core_service -->|"delegates DM"| node_dm_hook
node_core_service -.->|"dispatches events"| node_webhook
node_mdm_http -.->|"sends event requests"| node_webhook
node_webhook -->|"posts events"| node_webhook_target
node_core_service -.->|"supports targeting"| node_multi_service
node_storage_contracts -->|"implemented by"| node_storage_dispatch
node_storage_dispatch -->|"dispatches storage calls"| node_kv_storage
node_storage_dispatch -.->|"dispatches storage calls"| node_sql_storage
node_storage_dispatch -.->|"dispatches storage calls"| node_file_storage
node_push_service -->|"retrieves push data"| node_storage_contracts
node_push_service -->|"sends notifications"| node_push_provider
node_push_provider -->|"delivers pushes"| node_apns
node_server -->|"configures handlers"| node_mdm_http
node_server -->|"configures handlers"| node_api_http
node_server -->|"configures service"| node_core_service
node_migration -->|"retrieves check-ins"| node_storage_contracts
node_migration -->|"sends migration requests"| node_api_http

click node_server "https://github.com/micromdm/nanomdm/blob/main/cmd/nanomdm/main.go"
click node_mdm_http "https://github.com/micromdm/nanomdm/blob/main/http/mdm/mdm_cert.go"
click node_api_http "https://github.com/micromdm/nanomdm/blob/main/http/api/api.go"
click node_mdm_protocol "https://github.com/micromdm/nanomdm/blob/main/mdm/checkin.go"
click node_core_service "https://github.com/micromdm/nanomdm/blob/main/service/nanomdm/service.go"
click node_cert_auth "https://github.com/micromdm/nanomdm/blob/main/service/certauth/service.go"
click node_multi_service "https://github.com/micromdm/nanomdm/blob/main/service/multi/multi.go"
click node_dm_hook "https://github.com/micromdm/nanomdm/blob/main/service/dmhook/dmhook.go"
click node_webhook "https://github.com/micromdm/nanomdm/blob/main/service/webhook/service.go"
click node_migration "https://github.com/micromdm/nanomdm/blob/main/cmd/nano2nano/main.go"
click node_push_service "https://github.com/micromdm/nanomdm/blob/main/push/service/service.go"
click node_push_provider "https://github.com/micromdm/nanomdm/blob/main/push/nanopush/provider.go"
click node_storage_contracts "https://github.com/micromdm/nanomdm/blob/main/storage/storage.go"
click node_storage_dispatch "https://github.com/micromdm/nanomdm/blob/main/storage/allmulti/allmulti.go"
click node_kv_storage "https://github.com/micromdm/nanomdm/blob/main/storage/kv/mdm.go"
click node_sql_storage "https://github.com/micromdm/nanomdm/blob/main/storage/mysql/mysql.go"
click node_file_storage "https://github.com/micromdm/nanomdm/blob/main/storage/file/file.go"

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_mdm_http,node_api_http,node_api_clients toneBlue
class node_mdm_protocol,node_core_service,node_cert_auth,node_multi_service,node_dm_hook toneAmber
class node_storage_contracts,node_storage_dispatch,node_kv_storage,node_sql_storage,node_file_storage,node_webhook_target toneMint
class node_webhook,node_push_service,node_push_provider toneRose
class node_server,node_migration,node_devices,node_apns toneIndigo
```

## Components

### HTTP ingress

- [MDM HTTP handlers](https://github.com/micromdm/nanomdm/blob/main/http/mdm/mdm_cert.go): `http/mdm/mdm_cert.go`
- [API handlers](https://github.com/micromdm/nanomdm/blob/main/http/api/api.go): `http/api/api.go`

### MDM services

- [MDM protocol](https://github.com/micromdm/nanomdm/blob/main/mdm/checkin.go): `mdm/checkin.go`
- [Core MDM service](https://github.com/micromdm/nanomdm/blob/main/service/nanomdm/service.go): `service/nanomdm/service.go`
- [Certificate authorization](https://github.com/micromdm/nanomdm/blob/main/service/certauth/service.go): `service/certauth/service.go`
- [Multi-command targeting](https://github.com/micromdm/nanomdm/blob/main/service/multi/multi.go): `service/multi/multi.go`
- [Declarative management hook](https://github.com/micromdm/nanomdm/blob/main/service/dmhook/dmhook.go): `service/dmhook/dmhook.go`

### Persistence

- [Storage interfaces](https://github.com/micromdm/nanomdm/blob/main/storage/storage.go): `storage/storage.go`
- [Multi-store dispatch](https://github.com/micromdm/nanomdm/blob/main/storage/allmulti/allmulti.go): `storage/allmulti/allmulti.go`
- [KV storage](https://github.com/micromdm/nanomdm/blob/main/storage/kv/mdm.go): `storage/kv/mdm.go`
- [SQL storage](https://github.com/micromdm/nanomdm/blob/main/storage/mysql/mysql.go): `storage/mysql/mysql.go`
- [File storage](https://github.com/micromdm/nanomdm/blob/main/storage/file/file.go): `storage/file/file.go`

### External integrations

- [Webhook events](https://github.com/micromdm/nanomdm/blob/main/service/webhook/service.go): `service/webhook/service.go`
- [Push delivery service](https://github.com/micromdm/nanomdm/blob/main/push/service/service.go): `push/service/service.go`
- [APNs provider](https://github.com/micromdm/nanomdm/blob/main/push/nanopush/provider.go): `push/nanopush/provider.go`

### Server runtime

- [NanoMDM server](https://github.com/micromdm/nanomdm/blob/main/cmd/nanomdm/main.go): `cmd/nanomdm/main.go`
- [Migration client](https://github.com/micromdm/nanomdm/blob/main/cmd/nano2nano/main.go): `cmd/nano2nano/main.go`

### Other components

- **Apple devices**
- **API clients**
- **Apple APNs**
- **Webhook target**

## Connections

- Apple devices → MDM HTTP handlers: send check-ins
- MDM HTTP handlers → Core MDM service: adapts requests
- MDM HTTP handlers → MDM protocol: handles messages (evidence: `http/mdm/mdm_cert.go`)
- API clients → API handlers: submit API requests
- API handlers → Core MDM service: queues commands (evidence: `http/api/api.go`)
- API handlers → Push delivery service: requests pushes (evidence: `http/api/api.go`)
- Core MDM service → Storage interfaces: dispatches state operations (evidence: `service/nanomdm/service.go`)
- Core MDM service → Certificate authorization: uses authorization wrapper
- Core MDM service → Declarative management hook: delegates DM (evidence: `service/nanomdm/service.go`)
- Core MDM service → Webhook events: dispatches events (evidence: `service/webhook/service.go`)
- MDM HTTP handlers → Webhook events: sends event requests
- Webhook events → Webhook target: posts events (evidence: `service/webhook/service.go`)
- Core MDM service → Multi-command targeting: supports targeting
- Storage interfaces → Multi-store dispatch: implemented by (evidence: `storage/allmulti/allmulti.go`)
- Multi-store dispatch → KV storage: dispatches storage calls (evidence: `storage/allmulti/allmulti.go`)
- Multi-store dispatch → SQL storage: dispatches storage calls
- Multi-store dispatch → File storage: dispatches storage calls
- Push delivery service → Storage interfaces: retrieves push data (evidence: `push/service/service.go`)
- Push delivery service → APNs provider: sends notifications (evidence: `push/service/service.go`)
- APNs provider → Apple APNs: delivers pushes (evidence: `push/nanopush/provider.go`)
- NanoMDM server → MDM HTTP handlers: configures handlers (evidence: `cmd/nanomdm/main.go`)
- NanoMDM server → API handlers: configures handlers (evidence: `cmd/nanomdm/main.go`)
- NanoMDM server → Core MDM service: configures service (evidence: `cmd/nanomdm/main.go`)
- Migration client → Storage interfaces: retrieves check-ins (evidence: `cmd/nano2nano/main.go`)
- Migration client → API handlers: sends migration requests
