# cr-zhichen/djonehubnative architecture

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

- Interactive diagram: https://gitdiagram.com/cr-zhichen/djonehubnative
- Repository: https://github.com/cr-zhichen/djonehubnative

## Overview

DJOneHub is a native macOS manager for DJI’s first-generation 4G module. A user works through SwiftUI screens; app stores make requests over a Unix-domain-socket HTTP API, whose Go backend coordinates module operations and returns status or operation results. The product spans device/network status, SMS, eSIM profiles, calls/audio, and traffic routing, with diagnostics and a CLI as additional access paths. The README documents these capabilities; sampled excerpts support selected routing, eSIM, modem, and CLI details, so uncertain internal wiring is omitted.

Main entry points: [`app/Sources/APIClient.swift`](https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/APIClient.swift) (API client), [`backend/cmd/djonehub-macos/main.go`](https://github.com/cr-zhichen/djonehubnative/blob/main/backend/cmd/djonehub-macos/main.go) (HTTP API), [`app/Sources/Views/CallView.swift`](https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/Views/CallView.swift) (Call screen), [`app/Sources/Views/HomeView.swift`](https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/Views/HomeView.swift) (Home and status)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mac["macOS app"]
  node_home["Home and status<br/>[HomeView.swift]"]
  node_dashboard["Dashboard state"]
  node_smsview["SMS screen<br/>[SMSView.swift]"]
  node_smsstore["SMS state<br/>[SMSStore.swift]"]
  node_esimview["eSIM screen<br/>[ESIMView.swift]"]
  node_esimstore["eSIM state<br/>[ESIMStore.swift]"]
  node_callview["Call screen<br/>[CallView.swift]"]
  node_attention["Incoming call"]
  node_audio["Audio bridge<br/>[AudioBridge.swift]"]
  node_api["API client<br/>[APIClient.swift]"]
  node_backendproc["Backend process"]
  node_routingview["Routing screen"]
  node_routingstore["Routing state<br/>[RoutingStore.swift]"]
  node_diagnostics["Diagnostics screen"]
end

subgraph group_backend["Backend API"]
  node_server["HTTP API<br/>[main.go]"]
  node_smsarchive[("SMS archive<br/>[main.go]")]
end

subgraph group_device["Module operations"]
  node_modem["Modem control<br/>[manager.go]"]
  node_esim["eSIM manager<br/>[manager.go]"]
end

subgraph group_routing["Traffic routing"]
  node_routingmgr["Routing manager<br/>[network_routing.go]"]
  node_routinghelper["Privileged service<br/>[main.go]"]
end

subgraph group_access["Additional access"]
  node_cli["CLI client<br/>[client.go]"]
  node_climanager["CLI access setup"]
end

node_user(("Mac user"))
node_usbmodem{{"DJI 4G module"}}
node_networkcore["Network core"]

node_user -->|"views status"| node_home
node_home -->|"updates state"| node_dashboard
node_dashboard -->|"requests data"| node_api
node_user -->|"manages messages"| node_smsview
node_smsview -->|"updates state"| node_smsstore
node_smsstore -->|"requests SMS"| node_api
node_user -->|"manages profiles"| node_esimview
node_esimview -->|"updates state"| node_esimstore
node_esimstore -->|"requests profiles"| node_api
node_user -->|"controls calls"| node_callview
node_callview -->|"sends call actions"| node_api
node_attention -->|"fetches call state"| node_api
node_callview -->|"bridges voice"| node_audio
node_backendproc -->|"starts process"| node_server
node_api -->|"Unix socket HTTP"| node_server
node_server -->|"controls module"| node_modem
node_server -->|"manages profiles"| node_esim
node_modem -->|"sends modem commands"| node_usbmodem
node_esim -->|"uses card channel"| node_usbmodem
node_server -->|"persists archive"| node_smsarchive
node_user -->|"configures routing"| node_routingview
node_routingview -->|"updates state"| node_routingstore
node_routingstore -->|"reads and configures"| node_api
node_server -->|"dispatches routing"| node_routingmgr
node_routingmgr -.->|"controls privileged core"| node_routinghelper
node_routinghelper -->|"starts core"| node_networkcore
node_user -->|"runs diagnostics"| node_diagnostics
node_diagnostics -->|"requests diagnostics"| node_api
node_user -->|"runs commands"| node_cli
node_cli -->|"Unix socket HTTP"| node_server
node_user -->|"enables CLI access"| node_climanager

click node_home "https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/Views/HomeView.swift"
click node_dashboard "https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/DashboardStore.swift"
click node_smsview "https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/Views/SMSView.swift"
click node_smsstore "https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/SMSStore.swift"
click node_esimview "https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/Views/ESIMView.swift"
click node_esimstore "https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/ESIMStore.swift"
click node_callview "https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/Views/CallView.swift"
click node_attention "https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/AttentionStore.swift"
click node_audio "https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/AudioBridge.swift"
click node_api "https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/APIClient.swift"
click node_backendproc "https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/BackendProcess.swift"
click node_server "https://github.com/cr-zhichen/djonehubnative/blob/main/backend/cmd/djonehub-macos/main.go"
click node_modem "https://github.com/cr-zhichen/djonehubnative/blob/main/backend/internal/modem/manager.go"
click node_esim "https://github.com/cr-zhichen/djonehubnative/blob/main/backend/internal/esim/manager.go"
click node_smsarchive "https://github.com/cr-zhichen/djonehubnative/blob/main/backend/cmd/djonehub-macos/main.go"
click node_routingview "https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/Views/TrafficRoutingView.swift"
click node_routingstore "https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/RoutingStore.swift"
click node_routingmgr "https://github.com/cr-zhichen/djonehubnative/blob/main/backend/cmd/djonehub-macos/network_routing.go"
click node_routinghelper "https://github.com/cr-zhichen/djonehubnative/blob/main/backend/cmd/djonehub-routing-helper/main.go"
click node_diagnostics "https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/Views/DiagnosticsView.swift"
click node_cli "https://github.com/cr-zhichen/djonehubnative/blob/main/backend/cmd/djonehub-cli/client.go"
click node_climanager "https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/CLIIntegrationManager.swift"

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_home,node_dashboard,node_smsview,node_smsstore,node_esimview,node_esimstore,node_callview,node_attention,node_audio,node_api,node_backendproc,node_routingview,node_routingstore,node_diagnostics,node_user toneBlue
class node_server,node_smsarchive toneAmber
class node_modem,node_esim toneMint
class node_routingmgr,node_routinghelper toneRose
class node_cli,node_climanager,node_usbmodem,node_networkcore toneIndigo
```

## Components

### macOS app

- [Home and status](https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/Views/HomeView.swift): `app/Sources/Views/HomeView.swift`
- [Dashboard state](https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/DashboardStore.swift): `app/Sources/DashboardStore.swift`
- [SMS screen](https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/Views/SMSView.swift): `app/Sources/Views/SMSView.swift`
- [SMS state](https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/SMSStore.swift): `app/Sources/SMSStore.swift`
- [eSIM screen](https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/Views/ESIMView.swift): `app/Sources/Views/ESIMView.swift`
- [eSIM state](https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/ESIMStore.swift): `app/Sources/ESIMStore.swift`
- [Call screen](https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/Views/CallView.swift): `app/Sources/Views/CallView.swift`
- [Incoming call](https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/AttentionStore.swift): `app/Sources/AttentionStore.swift`
- [Audio bridge](https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/AudioBridge.swift): `app/Sources/AudioBridge.swift`
- [API client](https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/APIClient.swift): `app/Sources/APIClient.swift`
- [Backend process](https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/BackendProcess.swift): `app/Sources/BackendProcess.swift`
- [Routing screen](https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/Views/TrafficRoutingView.swift): `app/Sources/Views/TrafficRoutingView.swift`
- [Routing state](https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/RoutingStore.swift): `app/Sources/RoutingStore.swift`
- [Diagnostics screen](https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/Views/DiagnosticsView.swift): `app/Sources/Views/DiagnosticsView.swift`

### Backend API

- [HTTP API](https://github.com/cr-zhichen/djonehubnative/blob/main/backend/cmd/djonehub-macos/main.go): `backend/cmd/djonehub-macos/main.go`
- [SMS archive](https://github.com/cr-zhichen/djonehubnative/blob/main/backend/cmd/djonehub-macos/main.go): `backend/cmd/djonehub-macos/main.go`

### Module operations

- [Modem control](https://github.com/cr-zhichen/djonehubnative/blob/main/backend/internal/modem/manager.go): `backend/internal/modem/manager.go`
- [eSIM manager](https://github.com/cr-zhichen/djonehubnative/blob/main/backend/internal/esim/manager.go): `backend/internal/esim/manager.go`

### Traffic routing

- [Routing manager](https://github.com/cr-zhichen/djonehubnative/blob/main/backend/cmd/djonehub-macos/network_routing.go): `backend/cmd/djonehub-macos/network_routing.go`
- [Privileged service](https://github.com/cr-zhichen/djonehubnative/blob/main/backend/cmd/djonehub-routing-helper/main.go): `backend/cmd/djonehub-routing-helper/main.go`

### Additional access

- [CLI client](https://github.com/cr-zhichen/djonehubnative/blob/main/backend/cmd/djonehub-cli/client.go): `backend/cmd/djonehub-cli/client.go`
- [CLI access setup](https://github.com/cr-zhichen/djonehubnative/blob/main/app/Sources/CLIIntegrationManager.swift): `app/Sources/CLIIntegrationManager.swift`

### Other components

- **Mac user**
- **DJI 4G module**
- **Network core**

## Connections

- Mac user → Home and status: views status
- Home and status → Dashboard state: updates state
- Dashboard state → API client: requests data
- Mac user → SMS screen: manages messages
- SMS screen → SMS state: updates state
- SMS state → API client: requests SMS
- Mac user → eSIM screen: manages profiles
- eSIM screen → eSIM state: updates state
- eSIM state → API client: requests profiles
- Mac user → Call screen: controls calls
- Call screen → API client: sends call actions
- Incoming call → API client: fetches call state
- Call screen → Audio bridge: bridges voice
- Backend process → HTTP API: starts process
- API client → HTTP API: Unix socket HTTP
- HTTP API → Modem control: controls module
- HTTP API → eSIM manager: manages profiles
- Modem control → DJI 4G module: sends modem commands
- eSIM manager → DJI 4G module: uses card channel
- HTTP API → SMS archive: persists archive
- Mac user → Routing screen: configures routing
- Routing screen → Routing state: updates state
- Routing state → API client: reads and configures
- HTTP API → Routing manager: dispatches routing
- Routing manager → Privileged service: controls privileged core
- Privileged service → Network core: starts core
- Mac user → Diagnostics screen: runs diagnostics
- Diagnostics screen → API client: requests diagnostics
- Mac user → CLI client: runs commands
- CLI client → HTTP API: Unix socket HTTP
- Mac user → CLI access setup: enables CLI access
