# johandegraeve/xdripswift architecture

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

- Interactive diagram: https://gitdiagram.com/johandegraeve/xdripswift
- Repository: https://github.com/johandegraeve/xdripswift

## Overview

xDrip4iOS is an iOS CGM monitoring app with Master mode for direct sensor connections and Follower mode for remote glucose services. The principal workflow acquires or downloads readings, stores them locally, then presents them in the app and system surfaces; processing, alerts, analytics, and sharing extend that workflow. The README documents the supported sources and product capabilities; sampled excerpts provide implementation detail for only some managers, so uncertain internal wiring is omitted. Optional destinations are shown separately from the main reading path.

Main entry points: [`xDrip/Managers/CoreData/CoreDataManager.swift`](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/CoreData/CoreDataManager.swift) (Core Data), [`xDrip/Application Delegate/XdripApp.swift`](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Application%20Delegate/XdripApp.swift) (iOS app), [`xDrip/Managers/BluetoothPeripheral/BluetoothPeripheralManager.swift`](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/BluetoothPeripheral/BluetoothPeripheralManager.swift) (Peripheral manager), [`xDrip/Managers/Nightscout/NightscoutFollowManager.swift`](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/Nightscout/NightscoutFollowManager.swift) (Nightscout follower)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_acquisition["Data acquisition"]
  node_ble["Peripheral manager"]
  node_transmitters["CGM transmitters"]
  node_nightscout_follow["Nightscout follower"]
  node_carelink_follow["CareLink follower"]
  node_libre_follow["LibreLinkUp follower"]
  node_other_followers["Other followers"]
end

subgraph group_core["Reading core"]
  node_store[("Core Data")]
  node_postprocessing["Reading processing"]
  node_noise["Sensor noise"]
end

subgraph group_experience["App experience"]
  node_app["iOS app<br/>[XdripApp.swift]"]
  node_chart["Glucose chart"]
  node_alerts["Alerts<br/>[AlertManager.swift]"]
  node_statistics["Statistics"]
  node_therapy["Therapy metrics"]
end

subgraph group_sharing["Sharing and health"]
  node_nightscout_sync["Nightscout sync"]
  node_share_upload["Dexcom Share upload"]
  node_healthkit["Apple Health"]
  node_loop["Loop sharing<br/>[LoopManager.swift]"]
end

subgraph group_surfaces["System surfaces"]
  node_watch["Watch app<br/>[MainView.swift]"]
  node_complication["Watch complications"]
  node_widget["Widgets and Live Activities<br/>[XDripWidget.swift]"]
  node_shortcuts["Siri and Shortcuts<br/>[AppShortcuts.swift]"]
  node_m5["M5 companion displays"]
end

node_user(("User"))
node_cgm(("CGM device"))
node_remote(("Follower services"))

node_user -->|"uses"| node_app
node_cgm -->|"Bluetooth data"| node_ble
node_ble -->|"manages"| node_transmitters
node_transmitters -->|"delegate callbacks"| node_ble
node_ble -->|"persists readings"| node_store
node_remote -->|"provides data"| node_nightscout_follow
node_remote -->|"provides data"| node_carelink_follow
node_remote -->|"provides data"| node_libre_follow
node_remote -->|"provides data"| node_other_followers
node_nightscout_follow -->|"imports readings"| node_store
node_carelink_follow -->|"imports data"| node_store
node_libre_follow -->|"imports readings"| node_store
node_other_followers -->|"imports readings"| node_store
node_app -->|"configures sources"| node_ble
node_app -->|"selects follower"| node_nightscout_follow
node_store -->|"supplies readings"| node_postprocessing
node_postprocessing -->|"updates readings"| node_store
node_store -->|"supplies samples"| node_noise
node_store -->|"loads chart data"| node_chart
node_store -->|"supplies history"| node_statistics
node_store -->|"supplies treatments"| node_therapy
node_store -->|"supplies readings"| node_alerts
node_store -->|"syncs records"| node_nightscout_sync
node_nightscout_sync -.->|"uploads and downloads"| node_remote
node_store -->|"supplies readings"| node_share_upload
node_share_upload -.->|"uploads readings"| node_remote
node_store -->|"shares readings"| node_healthkit
node_store -->|"shares glucose"| node_loop
node_app -->|"shows readings"| node_chart
node_app -->|"manages alerts"| node_alerts
node_store -->|"shares glucose data"| node_watch
node_store -->|"provides complication data"| node_complication
node_store -->|"provides widget data"| node_widget
node_store -->|"provides latest reading"| node_shortcuts
node_store -.->|"supplies display data"| node_m5

click node_ble "https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/BluetoothPeripheral/BluetoothPeripheralManager.swift"
click node_transmitters "https://github.com/johandegraeve/xdripswift/tree/master/xDrip/BluetoothTransmitter/CGM"
click node_nightscout_follow "https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/Nightscout/NightscoutFollowManager.swift"
click node_carelink_follow "https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/CareLink/CareLinkFollowManager.swift"
click node_libre_follow "https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/LibreLinkUp/LibreLinkUpFollowManager.swift"
click node_other_followers "https://github.com/johandegraeve/xdripswift/tree/master/xDrip/Managers/Followers"
click node_store "https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/CoreData/CoreDataManager.swift"
click node_postprocessing "https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/PostProcessing/BgPostProcessingManager.swift"
click node_noise "https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/SensorNoise/SensorNoiseManager.swift"
click node_app "https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Application%20Delegate/XdripApp.swift"
click node_chart "https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/Charts/GlucoseChartStateManager.swift"
click node_alerts "https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/Alerts/AlertManager.swift"
click node_statistics "https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/Statistics/StatisticsManager.swift"
click node_therapy "https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/Therapy/TherapyMetricsManager.swift"
click node_nightscout_sync "https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/Nightscout/NightscoutSyncManager.swift"
click node_share_upload "https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/DexcomShare/DexcomShareUploadManager.swift"
click node_healthkit "https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/HealthKit/HealthKitManager.swift"
click node_loop "https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/Loop/LoopManager.swift"
click node_watch "https://github.com/johandegraeve/xdripswift/blob/master/xDrip%20Watch%20App/Views/MainView/MainView.swift"
click node_complication "https://github.com/johandegraeve/xdripswift/blob/master/xDrip%20Watch%20Complication/XDripWatchComplication.swift"
click node_widget "https://github.com/johandegraeve/xdripswift/blob/master/xDrip%20Widget/XDripWidget.swift"
click node_shortcuts "https://github.com/johandegraeve/xdripswift/blob/master/xDrip/AppShortcuts.swift"
click node_m5 "https://github.com/johandegraeve/xdripswift/blob/master/xDrip/BluetoothTransmitter/M5Stack/M5StackBluetoothTransmitter.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_ble,node_transmitters,node_nightscout_follow,node_carelink_follow,node_libre_follow,node_other_followers,node_user toneBlue
class node_store,node_postprocessing,node_noise toneAmber
class node_app,node_chart,node_alerts,node_statistics,node_therapy toneMint
class node_nightscout_sync,node_share_upload,node_healthkit,node_loop toneRose
class node_watch,node_complication,node_widget,node_shortcuts,node_m5,node_cgm,node_remote toneIndigo
```

## Components

### Data acquisition

- [Peripheral manager](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/BluetoothPeripheral/BluetoothPeripheralManager.swift): `xDrip/Managers/BluetoothPeripheral/BluetoothPeripheralManager.swift`
- [CGM transmitters](https://github.com/johandegraeve/xdripswift/tree/master/xDrip/BluetoothTransmitter/CGM): `xDrip/BluetoothTransmitter/CGM`
- [Nightscout follower](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/Nightscout/NightscoutFollowManager.swift): `xDrip/Managers/Nightscout/NightscoutFollowManager.swift`
- [CareLink follower](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/CareLink/CareLinkFollowManager.swift): `xDrip/Managers/CareLink/CareLinkFollowManager.swift`
- [LibreLinkUp follower](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/LibreLinkUp/LibreLinkUpFollowManager.swift): `xDrip/Managers/LibreLinkUp/LibreLinkUpFollowManager.swift`
- [Other followers](https://github.com/johandegraeve/xdripswift/tree/master/xDrip/Managers/Followers): `xDrip/Managers/Followers`

### Reading core

- [Core Data](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/CoreData/CoreDataManager.swift): `xDrip/Managers/CoreData/CoreDataManager.swift`
- [Reading processing](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/PostProcessing/BgPostProcessingManager.swift): `xDrip/Managers/PostProcessing/BgPostProcessingManager.swift`
- [Sensor noise](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/SensorNoise/SensorNoiseManager.swift): `xDrip/Managers/SensorNoise/SensorNoiseManager.swift`

### App experience

- [iOS app](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Application%20Delegate/XdripApp.swift): `xDrip/Application Delegate/XdripApp.swift`
- [Glucose chart](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/Charts/GlucoseChartStateManager.swift): `xDrip/Managers/Charts/GlucoseChartStateManager.swift`
- [Alerts](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/Alerts/AlertManager.swift): `xDrip/Managers/Alerts/AlertManager.swift`
- [Statistics](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/Statistics/StatisticsManager.swift): `xDrip/Managers/Statistics/StatisticsManager.swift`
- [Therapy metrics](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/Therapy/TherapyMetricsManager.swift): `xDrip/Managers/Therapy/TherapyMetricsManager.swift`

### Sharing and health

- [Nightscout sync](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/Nightscout/NightscoutSyncManager.swift): `xDrip/Managers/Nightscout/NightscoutSyncManager.swift`
- [Dexcom Share upload](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/DexcomShare/DexcomShareUploadManager.swift): `xDrip/Managers/DexcomShare/DexcomShareUploadManager.swift`
- [Apple Health](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/HealthKit/HealthKitManager.swift): `xDrip/Managers/HealthKit/HealthKitManager.swift`
- [Loop sharing](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/Managers/Loop/LoopManager.swift): `xDrip/Managers/Loop/LoopManager.swift`

### System surfaces

- [Watch app](https://github.com/johandegraeve/xdripswift/blob/master/xDrip%20Watch%20App/Views/MainView/MainView.swift): `xDrip Watch App/Views/MainView/MainView.swift`
- [Watch complications](https://github.com/johandegraeve/xdripswift/blob/master/xDrip%20Watch%20Complication/XDripWatchComplication.swift): `xDrip Watch Complication/XDripWatchComplication.swift`
- [Widgets and Live Activities](https://github.com/johandegraeve/xdripswift/blob/master/xDrip%20Widget/XDripWidget.swift): `xDrip Widget/XDripWidget.swift`
- [Siri and Shortcuts](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/AppShortcuts.swift): `xDrip/AppShortcuts.swift`
- [M5 companion displays](https://github.com/johandegraeve/xdripswift/blob/master/xDrip/BluetoothTransmitter/M5Stack/M5StackBluetoothTransmitter.swift): `xDrip/BluetoothTransmitter/M5Stack/M5StackBluetoothTransmitter.swift`

### Other components

- **User**
- **CGM device**
- **Follower services**

## Connections

- User → iOS app: uses
- CGM device → Peripheral manager: Bluetooth data
- Peripheral manager → CGM transmitters: manages
- CGM transmitters → Peripheral manager: delegate callbacks
- Peripheral manager → Core Data: persists readings
- Follower services → Nightscout follower: provides data
- Follower services → CareLink follower: provides data
- Follower services → LibreLinkUp follower: provides data
- Follower services → Other followers: provides data
- Nightscout follower → Core Data: imports readings
- CareLink follower → Core Data: imports data
- LibreLinkUp follower → Core Data: imports readings
- Other followers → Core Data: imports readings
- iOS app → Peripheral manager: configures sources
- iOS app → Nightscout follower: selects follower
- Core Data → Reading processing: supplies readings
- Reading processing → Core Data: updates readings
- Core Data → Sensor noise: supplies samples
- Core Data → Glucose chart: loads chart data
- Core Data → Statistics: supplies history
- Core Data → Therapy metrics: supplies treatments
- Core Data → Alerts: supplies readings
- Core Data → Nightscout sync: syncs records
- Nightscout sync → Follower services: uploads and downloads
- Core Data → Dexcom Share upload: supplies readings
- Dexcom Share upload → Follower services: uploads readings
- Core Data → Apple Health: shares readings
- Core Data → Loop sharing: shares glucose
- iOS app → Glucose chart: shows readings
- iOS app → Alerts: manages alerts
- Core Data → Watch app: shares glucose data
- Core Data → Watch complications: provides complication data
- Core Data → Widgets and Live Activities: provides widget data
- Core Data → Siri and Shortcuts: provides latest reading
- Core Data → M5 companion displays: supplies display data
