# the-momentum/open_wearables_android_sdk architecture

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

- Interactive diagram: https://gitdiagram.com/the-momentum/open_wearables_android_sdk
- Repository: https://github.com/the-momentum/open_wearables_android_sdk

## Overview

Open Wearables Android SDK lets an Android app authorize access to Samsung Health or Health Connect, read and normalize health records, then sync them to a backend. Its facade manages configuration, provider choice, authentication, permissions, and sync controls; SyncManager performs incremental/resumable uploads, while WorkManager runs syncs in the background. The README also documents token refresh, API-key auth, encrypted credentials, and foreground operation. Some implementation details—especially mTLS configuration and unsampled modules—are represented only where the README or source index supports them.

Main entry points: [`sdk/src/main/kotlin/com/openwearables/health/sdk/OpenWearablesHealthSDK.kt`](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/OpenWearablesHealthSDK.kt) (SDK Facade), [`sdk/src/main/kotlin/com/openwearables/health/sdk/SamsungHealthManager.kt`](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/SamsungHealthManager.kt) (Samsung Health), [`sdk/src/main/kotlin/com/openwearables/health/sdk/SyncManager.kt`](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/SyncManager.kt) (Sync Manager), [`sdk/src/main/kotlin/com/openwearables/health/sdk/HealthDataProvider.kt`](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/HealthDataProvider.kt) (Provider Interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["SDK API"]
  node_facade["SDK Facade"]
end

subgraph group_providers["Health Providers"]
  node_provider_api["Provider Interface"]
  node_healthconnect["Health Connect"]
  node_samsung["Samsung Health"]
  node_payload["Unified Payload<br/>[UnifiedPayload.kt]"]
  node_timestamp["Timestamp Checks<br/>[TimestampSanity.kt]"]
  node_samsung_window["Aggregate Windows"]
  node_exercise_types["Exercise Mapping"]
  node_outcome["Provider Outcomes<br/>[Outcome.kt]"]
  node_samsung_models["Samsung Models<br/>[SamsungModels.kt]"]
end

subgraph group_sync["Sync Runtime"]
  node_syncmanager["Sync Manager<br/>[SyncManager.kt]"]
  node_worker["Background Worker"]
  node_dispatchers["Coroutine Dispatchers"]
end

subgraph group_security["Auth and Security"]
  node_storage[("Encrypted Storage<br/>[SecureStorage.kt]")]
  node_auth["Auth Policy<br/>[SyncAuth.kt]"]
  node_mtls["mTLS Setup"]
  node_keychain["KeyChain Certs"]
end

node_app(("Android App"))
node_backend["Backend API"]

node_app -->|"configures SDK"| node_facade
node_facade -->|"selects provider"| node_provider_api
node_facade -->|"controls sync"| node_syncmanager
node_facade -->|"stores credentials"| node_storage
node_facade -->|"configures TLS"| node_mtls
node_facade -->|"uses auth policy"| node_auth
node_facade -->|"selects certificate"| node_keychain
node_provider_api -->|"implemented by"| node_healthconnect
node_provider_api -->|"implemented by"| node_samsung
node_healthconnect -->|"normalizes records"| node_payload
node_samsung -->|"normalizes records"| node_payload
node_healthconnect -->|"checks timestamps"| node_timestamp
node_samsung -->|"checks timestamps"| node_timestamp
node_samsung -->|"uses windows"| node_samsung_window
node_samsung -->|"maps exercises"| node_exercise_types
node_samsung -->|"returns outcomes"| node_outcome
node_syncmanager -->|"reads data"| node_provider_api
node_syncmanager -->|"persists sync state"| node_storage
node_syncmanager -->|"uploads payloads"| node_backend
node_syncmanager -->|"dispatches work"| node_dispatchers
node_worker -->|"runs sync"| node_syncmanager
node_worker -->|"loads credentials"| node_storage
node_worker -->|"creates provider"| node_provider_api
node_mtls -.->|"uses client certs"| node_keychain
node_samsung -.->|"uses models"| node_samsung_models

click node_facade "https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/OpenWearablesHealthSDK.kt"
click node_provider_api "https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/HealthDataProvider.kt"
click node_healthconnect "https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/HealthConnectManager.kt"
click node_samsung "https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/SamsungHealthManager.kt"
click node_payload "https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/UnifiedPayload.kt"
click node_syncmanager "https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/SyncManager.kt"
click node_worker "https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/HealthSyncWorker.kt"
click node_storage "https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/SecureStorage.kt"
click node_auth "https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/SyncAuth.kt"
click node_mtls "https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/MtlsConfigurator.kt"
click node_keychain "https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/KeyChainCertProvider.kt"
click node_timestamp "https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/TimestampSanity.kt"
click node_samsung_window "https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/SamsungAggregateWindow.kt"
click node_exercise_types "https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/SamsungExerciseType.kt"
click node_dispatchers "https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/DispatcherProvider.kt"
click node_outcome "https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/Outcome.kt"
click node_samsung_models "https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/SamsungModels.kt"

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_facade toneBlue
class node_provider_api,node_healthconnect,node_samsung,node_payload,node_timestamp,node_samsung_window,node_exercise_types,node_outcome,node_samsung_models toneAmber
class node_syncmanager,node_worker,node_dispatchers,node_backend toneMint
class node_storage,node_auth,node_mtls,node_keychain toneRose
class node_app toneIndigo
```

## Components

### SDK API

- [SDK Facade](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/OpenWearablesHealthSDK.kt): `sdk/src/main/kotlin/com/openwearables/health/sdk/OpenWearablesHealthSDK.kt`

### Health Providers

- [Provider Interface](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/HealthDataProvider.kt): `sdk/src/main/kotlin/com/openwearables/health/sdk/HealthDataProvider.kt`
- [Health Connect](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/HealthConnectManager.kt): `sdk/src/main/kotlin/com/openwearables/health/sdk/HealthConnectManager.kt`
- [Samsung Health](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/SamsungHealthManager.kt): `sdk/src/main/kotlin/com/openwearables/health/sdk/SamsungHealthManager.kt`
- [Unified Payload](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/UnifiedPayload.kt): `sdk/src/main/kotlin/com/openwearables/health/sdk/UnifiedPayload.kt`
- [Timestamp Checks](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/TimestampSanity.kt): `sdk/src/main/kotlin/com/openwearables/health/sdk/TimestampSanity.kt`
- [Aggregate Windows](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/SamsungAggregateWindow.kt): `sdk/src/main/kotlin/com/openwearables/health/sdk/SamsungAggregateWindow.kt`
- [Exercise Mapping](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/SamsungExerciseType.kt): `sdk/src/main/kotlin/com/openwearables/health/sdk/SamsungExerciseType.kt`
- [Provider Outcomes](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/Outcome.kt): `sdk/src/main/kotlin/com/openwearables/health/sdk/Outcome.kt`
- [Samsung Models](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/SamsungModels.kt): `sdk/src/main/kotlin/com/openwearables/health/sdk/SamsungModels.kt`

### Sync Runtime

- [Sync Manager](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/SyncManager.kt): `sdk/src/main/kotlin/com/openwearables/health/sdk/SyncManager.kt`
- [Background Worker](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/HealthSyncWorker.kt): `sdk/src/main/kotlin/com/openwearables/health/sdk/HealthSyncWorker.kt`
- [Coroutine Dispatchers](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/DispatcherProvider.kt): `sdk/src/main/kotlin/com/openwearables/health/sdk/DispatcherProvider.kt`

### Auth and Security

- [Encrypted Storage](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/SecureStorage.kt): `sdk/src/main/kotlin/com/openwearables/health/sdk/SecureStorage.kt`
- [Auth Policy](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/SyncAuth.kt): `sdk/src/main/kotlin/com/openwearables/health/sdk/SyncAuth.kt`
- [mTLS Setup](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/MtlsConfigurator.kt): `sdk/src/main/kotlin/com/openwearables/health/sdk/MtlsConfigurator.kt`
- [KeyChain Certs](https://github.com/the-momentum/open_wearables_android_sdk/blob/main/sdk/src/main/kotlin/com/openwearables/health/sdk/KeyChainCertProvider.kt): `sdk/src/main/kotlin/com/openwearables/health/sdk/KeyChainCertProvider.kt`

### Other components

- **Android App**
- **Backend API**

## Connections

- Android App → SDK Facade: configures SDK (evidence: `README.md`)
- SDK Facade → Provider Interface: selects provider (evidence: `sdk/src/main/kotlin/com/openwearables/health/sdk/OpenWearablesHealthSDK.kt`)
- SDK Facade → Sync Manager: controls sync (evidence: `sdk/src/main/kotlin/com/openwearables/health/sdk/OpenWearablesHealthSDK.kt`)
- SDK Facade → Encrypted Storage: stores credentials (evidence: `sdk/src/main/kotlin/com/openwearables/health/sdk/OpenWearablesHealthSDK.kt`)
- SDK Facade → mTLS Setup: configures TLS (evidence: `sdk/src/main/kotlin/com/openwearables/health/sdk/OpenWearablesHealthSDK.kt`)
- SDK Facade → Auth Policy: uses auth policy (evidence: `sdk/src/main/kotlin/com/openwearables/health/sdk/OpenWearablesHealthSDK.kt`)
- SDK Facade → KeyChain Certs: selects certificate (evidence: `sdk/src/main/kotlin/com/openwearables/health/sdk/OpenWearablesHealthSDK.kt`)
- Provider Interface → Health Connect: implemented by (evidence: `README.md`)
- Provider Interface → Samsung Health: implemented by (evidence: `README.md`)
- Health Connect → Unified Payload: normalizes records
- Samsung Health → Unified Payload: normalizes records
- Health Connect → Timestamp Checks: checks timestamps (evidence: `sdk/src/main/kotlin/com/openwearables/health/sdk/HealthConnectManager.kt`)
- Samsung Health → Timestamp Checks: checks timestamps (evidence: `sdk/src/main/kotlin/com/openwearables/health/sdk/SamsungHealthManager.kt`)
- Samsung Health → Aggregate Windows: uses windows (evidence: `sdk/src/main/kotlin/com/openwearables/health/sdk/SamsungHealthManager.kt`)
- Samsung Health → Exercise Mapping: maps exercises (evidence: `sdk/src/main/kotlin/com/openwearables/health/sdk/SamsungHealthManager.kt`)
- Samsung Health → Provider Outcomes: returns outcomes (evidence: `sdk/src/main/kotlin/com/openwearables/health/sdk/SamsungHealthManager.kt`)
- Sync Manager → Provider Interface: reads data (evidence: `README.md`)
- Sync Manager → Encrypted Storage: persists sync state (evidence: `sdk/src/main/kotlin/com/openwearables/health/sdk/SyncManager.kt`)
- Sync Manager → Backend API: uploads payloads (evidence: `README.md`)
- Sync Manager → Coroutine Dispatchers: dispatches work (evidence: `sdk/src/main/kotlin/com/openwearables/health/sdk/SyncManager.kt`)
- Background Worker → Sync Manager: runs sync (evidence: `sdk/src/main/kotlin/com/openwearables/health/sdk/HealthSyncWorker.kt`)
- Background Worker → Encrypted Storage: loads credentials (evidence: `sdk/src/main/kotlin/com/openwearables/health/sdk/HealthSyncWorker.kt`)
- Background Worker → Provider Interface: creates provider (evidence: `sdk/src/main/kotlin/com/openwearables/health/sdk/HealthSyncWorker.kt`)
- mTLS Setup → KeyChain Certs: uses client certs
- Samsung Health → Samsung Models: uses models
