# nightscoutfoundation/xdrip architecture

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

- Interactive diagram: https://gitdiagram.com/nightscoutfoundation/xdrip
- Repository: https://github.com/nightscoutfoundation/xdrip

## Overview

#### Overview

Nightscout xDrip is a multi-module Android data hub and processor for glucose, treatment, insulin, activity, and device data. The README documents support for numerous CGMs, glucose meters, pumps, insulin pens, watches, follower phones, Nightscout, Tidepool, MongoDB, InfluxDB, AndroidAPS, and other companion apps. The repository is primarily an Android phone application with a separate Wear OS application and reusable integration modules.

#### Core components

- **Android application shell and UI — `app/src/main/java/com/eveningoutpost/dexdrip`**

Activities, services, receivers, widgets, preferences, notifications, and web-service endpoints form the main Android entry surface. `app/src/main/AndroidManifest.xml` defines the platform-facing component boundary.

- **Domain models and local persistence — `app/src/main/java/com/eveningoutpost/dexdrip/models`**

Domain records include glucose readings, calibrations, sensors, treatments, insulin, profiles, alerts, and device state. Database-facing tables are organized under `app/src/main/java/com/eveningoutpost/dexdrip/tables`; schema migrations are stored in `app/src/main/assets/migrations`. Preferences and key/value state are separately represented under `app/src/main/java/com/eveningoutpost/dexdrip/store` and `app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels`.

- **Device acquisition and protocol adapters — `app/src/main/java/com/eveningoutpost/dexdrip/services`**

Collection services and protocol packages cover Dexcom/G5/G6/G7, Libre, Medtrum, glucose meters, NFC, USB, and other Bluetooth devices. Supporting wire formats and protocol state are organized in `cgm`, `g5model`, `glucosemeter`, `nfc`, and `importedlibraries`.

- **Processing, calibration, alerts, and therapy logic — `app/src/main/java/com/eveningoutpost/dexdrip/calibrations`**

Calibration implementations, smoothing/filtering, glucose-quality evaluators, predictive behavior, alert polling, insulin curves, and treatment calculations are separated into the calibration, processing, evaluators, alert, and insulin packages.

- **Cloud, follower, upload, and local-network interfaces — `app/src/main/java/com/eveningoutpost/dexdrip/cloud`**

This area contains backup, peer/cloud messaging, and NightLite functionality. Related packages implement CareLink, Nightscout, Dexcom Share, web-follow, deposit, Tidepool, InfluxDB, Nocturne, and local web services. These are alternative external integrations rather than one mandatory backend.

- **Wear companion — `wear/src/main/java/com/eveningoutpost/dexdrip`**

The Wear module provides watch activities, watch faces, alerts, charts, collection services, persistent records, and phone synchronization. It contains overlapping domain and protocol code so supported watches can display or collect data independently where documented.

- **Extension and integration modules — `ipluginda/src/main/java/com/eveningoutpost/dexdrip/plugin`**

Separate modules provide a plugin interface, Locale/Tasker API support, GluPro BLE support, and Keks protocol code. These are optional integration boundaries, distinct from the main application path.

#### Relationships

Android lifecycle components expose the app to users and platform events, while acquisition services and external-follow clients provide incoming device or network data. Models and table/state packages own the durable representation of that data. Processing and calibration packages provide domain transformations used by presentation, alerts, and uploads. Cloud, web, broadcast, Tasker, and plugin packages expose selected data or commands to external actors. The Wear application is a companion consumer/producer connected through the repository’s wear-integration and message areas; exact call order is not established by the tree alone.

#### Public entry points and boundaries

Runtime entry points are Android manifest-declared activities, services, broadcast receivers, content/web-service components, widgets, and Wear components. External actors include CGM meters and pumps, companion apps, watches, Nightscout/Tidepool/cloud servers, and user automation tools. Configuration, credentials, permissions, and device availability are application/deployment inputs; this repository owns the adapters and processing implementations but not those external systems.

Main entry points: [`app/src/main/java/com/eveningoutpost/dexdrip`](https://github.com/nightscoutfoundation/xdrip/tree/master/app/src/main/java/com/eveningoutpost/dexdrip) (Android shell and UI), [`app/src/main/java/com/eveningoutpost/dexdrip/models`](https://github.com/nightscoutfoundation/xdrip/tree/master/app/src/main/java/com/eveningoutpost/dexdrip/models) (Domain models), [`app/src/main/java/com/eveningoutpost/dexdrip/calibrations`](https://github.com/nightscoutfoundation/xdrip/tree/master/app/src/main/java/com/eveningoutpost/dexdrip/calibrations) (Processing and therapy logic), [`app/src/main/java/com/eveningoutpost/dexdrip/cloud`](https://github.com/nightscoutfoundation/xdrip/tree/master/app/src/main/java/com/eveningoutpost/dexdrip/cloud) (Cloud and network interfaces)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_main["Android app"]
  node_shell["Android shell and UI<br/>Android application boundary"]
  node_models["Domain models<br/>domain model layer"]
  node_persistence[("Tables and local persistence<br/>persistence layer")]
  node_state[("Preferences and state<br/>state store")]
  node_acquisition["Device acquisition<br/>protocol adapter layer"]
  node_processing["Processing and therapy logic<br/>calibration and processing layer"]
  node_cloud["Cloud and network interfaces<br/>external integration layer"]
end

subgraph group_wear["Wear companion"]
  node_wearapp["Wear application<br/>Wear OS companion"]
end

subgraph group_extensions["Extensions"]
  node_plugins{{"Plugin integrations<br/>optional extension modules"}}
end

subgraph group_external["External actors"]
  node_devices(("Devices and pumps<br/>external device systems"))
  node_servers(("Cloud and companion services<br/>external systems"))
  node_automation(("Users and automation tools<br/>external actors"))
end

node_devices -->|"sends data"| node_acquisition
node_servers -->|"exchanges data"| node_cloud
node_acquisition -->|"produces records"| node_models
node_models -->|"persists as"| node_persistence
node_shell -->|"reads and writes"| node_state
node_models -->|"feeds"| node_processing
node_processing -->|"supports presentation"| node_shell
node_processing -->|"supports uploads"| node_cloud
node_shell -->|"exposes interfaces"| node_automation
node_cloud -->|"uploads and follows"| node_servers
node_wearapp -->|"synchronizes with"| node_shell
node_plugins -.->|"extends"| node_shell
node_plugins -->|"integrates with"| node_automation

click node_shell "https://github.com/nightscoutfoundation/xdrip/tree/master/app/src/main/java/com/eveningoutpost/dexdrip"
click node_models "https://github.com/nightscoutfoundation/xdrip/tree/master/app/src/main/java/com/eveningoutpost/dexdrip/models"
click node_persistence "https://github.com/nightscoutfoundation/xdrip/tree/master/app/src/main/java/com/eveningoutpost/dexdrip/tables"
click node_state "https://github.com/nightscoutfoundation/xdrip/tree/master/app/src/main/java/com/eveningoutpost/dexdrip/store"
click node_acquisition "https://github.com/nightscoutfoundation/xdrip/tree/master/app/src/main/java/com/eveningoutpost/dexdrip/services"
click node_processing "https://github.com/nightscoutfoundation/xdrip/tree/master/app/src/main/java/com/eveningoutpost/dexdrip/calibrations"
click node_cloud "https://github.com/nightscoutfoundation/xdrip/tree/master/app/src/main/java/com/eveningoutpost/dexdrip/cloud"
click node_wearapp "https://github.com/nightscoutfoundation/xdrip/tree/master/wear/src/main/java/com/eveningoutpost/dexdrip"
click node_plugins "https://github.com/nightscoutfoundation/xdrip/tree/master/ipluginda/src/main/java/com/eveningoutpost/dexdrip/plugin"

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_shell,node_models,node_persistence,node_state,node_acquisition,node_processing,node_cloud toneBlue
class node_wearapp toneAmber
class node_plugins toneMint
class node_devices,node_servers,node_automation toneRose
```

## Components

### Android app

- [Android shell and UI](https://github.com/nightscoutfoundation/xdrip/tree/master/app/src/main/java/com/eveningoutpost/dexdrip): Android application boundary · Manifest-declared activities, services, receivers, widgets, notifications, and web endpoints. · `app/src/main/java/com/eveningoutpost/dexdrip`
- [Domain models](https://github.com/nightscoutfoundation/xdrip/tree/master/app/src/main/java/com/eveningoutpost/dexdrip/models): domain model layer · `app/src/main/java/com/eveningoutpost/dexdrip/models`
- [Tables and local persistence](https://github.com/nightscoutfoundation/xdrip/tree/master/app/src/main/java/com/eveningoutpost/dexdrip/tables): persistence layer · `app/src/main/java/com/eveningoutpost/dexdrip/tables`
- [Preferences and state](https://github.com/nightscoutfoundation/xdrip/tree/master/app/src/main/java/com/eveningoutpost/dexdrip/store): state store · `app/src/main/java/com/eveningoutpost/dexdrip/store`
- [Device acquisition](https://github.com/nightscoutfoundation/xdrip/tree/master/app/src/main/java/com/eveningoutpost/dexdrip/services): protocol adapter layer · Collection services and device protocol adapters for glucose and related data. · `app/src/main/java/com/eveningoutpost/dexdrip/services`
- [Processing and therapy logic](https://github.com/nightscoutfoundation/xdrip/tree/master/app/src/main/java/com/eveningoutpost/dexdrip/calibrations): calibration and processing layer · `app/src/main/java/com/eveningoutpost/dexdrip/calibrations`
- [Cloud and network interfaces](https://github.com/nightscoutfoundation/xdrip/tree/master/app/src/main/java/com/eveningoutpost/dexdrip/cloud): external integration layer · Alternative upload, follower, backup, and local-network integrations. · `app/src/main/java/com/eveningoutpost/dexdrip/cloud`

### Wear companion

- [Wear application](https://github.com/nightscoutfoundation/xdrip/tree/master/wear/src/main/java/com/eveningoutpost/dexdrip): Wear OS companion · Watch UI, collection, records, alerts, charts, and phone synchronization. · `wear/src/main/java/com/eveningoutpost/dexdrip`

### Extensions

- [Plugin integrations](https://github.com/nightscoutfoundation/xdrip/tree/master/ipluginda/src/main/java/com/eveningoutpost/dexdrip/plugin): optional extension modules · Plugin, Locale/Tasker, GluPro BLE, and Keks integration boundaries. · `ipluginda/src/main/java/com/eveningoutpost/dexdrip/plugin`

### External actors

- **Devices and pumps**: external device systems
- **Cloud and companion services**: external systems
- **Users and automation tools**: external actors

## Connections

- Devices and pumps → Device acquisition: sends data
- Cloud and companion services → Cloud and network interfaces: exchanges data
- Device acquisition → Domain models: produces records
- Domain models → Tables and local persistence: persists as
- Android shell and UI → Preferences and state: reads and writes
- Domain models → Processing and therapy logic: feeds
- Processing and therapy logic → Android shell and UI: supports presentation
- Processing and therapy logic → Cloud and network interfaces: supports uploads
- Android shell and UI → Users and automation tools: exposes interfaces
- Cloud and network interfaces → Cloud and companion services: uploads and follows
- Wear application → Android shell and UI: synchronizes with
- Plugin integrations → Android shell and UI: extends
- Plugin integrations → Users and automation tools: integrates with
