Skip to main content

What is Synheart Session?

Synheart Session is an SDK for running timed biometric sessions. A session buffers heart-rate samples from a pluggable BiosignalProvider in a sliding window, emits a SessionFrame with flat metrics at a fixed interval, and delivers a SessionSummary when the session ends. A BehaviorProvider can add timing-based behavioral signals to each frame. The SDK computes mean heart rate on-device. It does not compute HRV: hr_sdnn_ms, rmssd_ms, and pnn50 come from the host through ingestHsiMetrics() (typically from the Synheart runtime) and are 0.0 until the host supplies them. For real-time data from a smartwatch, Synheart’s companion watch apps (watchOS and Wear OS) run the session on the watch and stream events to the phone. The phone SDKs relay start/stop commands and receive those events. There is no automatic fallback to a phone-side source: if no watch is reachable, the session gets no heart-rate data. See Lifecycle.

Key Features

Session Lifecycle

  • Configurable sessions: Set mode (focus, breathing, typing), duration, and compute profile
  • Streaming session frames: Periodic frames with flat metrics during the session
  • Session summary: A final frame computed when the session ends
  • Typed event stream: SessionStarted, SessionFrame, BiosignalFrame, SessionSummary, SessionError
  • Optional raw biosignal streaming: Opt-in includeRawSamples for a live HR trace

Pluggable Providers

  • BiosignalProvider: HR source — mock (sinusoidal), BLE HRM and Health Connect (Kotlin, via synheart-wear), HealthKit and BLE HRM (Swift, via synheart-wear), companion watch (Flutter)
  • BehaviorProvider: Optional pull-based behavioral source — mock, or synheart-behavior (bundled wrapper in Kotlin and Swift)
  • Providers are constructor arguments of SynheartSession and are optional; the Kotlin and Swift default biosignal provider is the mock

Phone-Watch Streaming

  • Flutter: pass a WatchBiosignalProvider and the SDK sends start/stop commands to the companion app on Apple Watch (WatchConnectivity) or Wear OS (Wearable Data Layer)
  • Kotlin: WatchSessionRelay drives a session on a Wear OS watch and returns the watch’s events as a Flow<SessionEvent>
  • Swift: the Swift SDK runs sessions on the device it is linked into (including watchOS); it does not include a phone-side relay

Cross-Platform

  • Flutter/Dart: SynheartSession() (live) and SynheartSession.mock() (simulated)
  • Kotlin: SynheartSession returning a SharedFlow<SessionEvent>
  • Swift: SynheartSession returning an AsyncStream<SessionEvent>
  • Wire format: every SDK serializes events to the same snake_case map (toJson() / toMap() / toDictionary())

Architecture

With a companion watch, the session on the watch produces the events and the phone receives them:
See Watch Protocol for the message format.

Event Flow

  1. You call startSession(config), which returns a stream of SessionEvents
  2. SessionStarted is emitted immediately
  3. SessionFrame events arrive every emitIntervalSec
  4. If includeRawSamples is true, BiosignalFrame events also arrive every rawEmitIntervalSec (defaults to emitIntervalSec) — Kotlin, Swift, and the Flutter mock engine
  5. When the duration elapses or you call stopSession, a SessionSummary is emitted
  6. The Flutter stream and the Swift stream finish after the summary. The Kotlin SharedFlow never completes, so stop collecting on SessionSummary or SessionErrorEvent

Session Modes

The phone-side engines compute the same metrics in every mode. The mode is carried in the config and forwarded to the watch in the start_session command.

Compute Profile

The ComputeProfile controls the window size and how often frames are emitted:

Raw Biosignal Streaming

When includeRawSamples is enabled in SessionConfig, the Kotlin and Swift engines and the Flutter mock engine emit BiosignalFrame events alongside session frames. The Flutter live engine does not emit BiosignalFrame. Kotlin and Swift samples are maps with these keys: In Dart, BiosignalFrame.samples is a List<BiosignalSample> with timestampMs, bpm, rrIntervalMs, accelerometer, and spo2. The mock engine fills accelerometer with synthetic values.

Available SDKs

Flutter SDK

Cross-platform SDK for iOS and Android with a mock mode for development.

Flutter SDK Documentation

Flutter integration guide
Installation:
Version: 0.3.0 Requirements: Dart >=3.8.0 <4.0.0, Flutter >=3.22.0 Repository: synheart-session-flutter · runnable example

Swift SDK

Native Swift SDK with SynheartSession and pluggable BiosignalProvider and BehaviorProvider.

Swift SDK Documentation

Swift and watchOS integration guide
Installation:
Version: 0.3.0 Platforms (Swift Package Manager): iOS 13.0+ / macOS 13.0+ / watchOS 8.0+ Repository: synheart-session-swift

Kotlin SDK

Native Kotlin SDK for Android with SynheartSession, pluggable providers (reflection-based wrappers for synheart-wear and synheart-behavior), and WatchSessionRelay for Wear OS.

Kotlin SDK Documentation

Android integration guide
Installation:
Version: 0.4.0 Min OS: Android API 21+ (Android 5.0) Repository: synheart-session-kotlin

Stability

Synheart Session is pre-1.0. Minor version bumps may include breaking API changes — pin exact versions in production, and read the CHANGELOG before upgrading. Kotlin 0.4.0 and Swift 0.3.0 are minor bumps because the new typing mode breaks exhaustive when / switch statements over SessionMode.

Session Frame Structure

Each SessionFrame carries a flat metrics map. When a BehaviorProvider is configured and returns a snapshot, a behavior map is included too:

Frame Metrics

Platform differences:
  • Flutter also puts session_id, mode, and seq inside metrics. The Flutter live engine emits frames even when the window is empty (sample_count 0, hr_mean_bpm 0.0).
  • Flutter mock engine emits synthetic hr_sdnn_ms and rmssd_ms derived from its generated data, adds "mock": true, and does not emit pnn50.
  • Kotlin and Swift skip a frame when the window holds no samples.
Events relayed from a companion watch app can include extra metric keys that the watch app adds. The phone SDKs do not produce them.

Next Steps

Flutter SDK

Flutter integration guide

Swift SDK

Swift and watchOS guide

Kotlin SDK

Android integration guide

Community

  • GitHub: github.com/synheart-ai — every Session SDK lives in its per-language repo (synheart-session-flutter, synheart-session-kotlin, synheart-session-swift).
  • Issues: file against the relevant per-language repo.