Skip to content

saksham2001/PulseLoopIOS

Repository files navigation

PulseLoop

PulseLoop

📖 Read the detailed writeup on how the app works here: sakshambhutani.xyz/projects/20_project

An LLM-native health app for iOS that turns a cheap Bluetooth "smart ring" (the generic Chinese 56ff BLE ring sold under dozens of brands) into a real, conversational health tracker.

PulseLoop talks to the ring directly over Bluetooth LE — no vendor cloud, no account — and layers an AI Coach on top of your own data. Instead of static charts, you get a coach that can read your metrics, run its own analysis, draw charts, remember context about you, and answer questions about your sleep, heart rate, activity, and recovery.

Goal: prove that a $20 ring + an LLM can replace a $300 subscription wearable, and that the "intelligence" should live on the phone, not behind a paywall.


What it does

  • Connects to the ring over BLE and decodes its proprietary protocol (heart rate, SpO₂, steps, distance, calories, sleep stages, raw packets).
  • Today / Vitals / Sleep / Activity dashboards built natively in SwiftUI, backed by SwiftData for local persistence.
  • AI Coach — an agentic loop (OpenAI Responses API) with tools for data retrieval, on-the-fly analysis, chart generation, long-term memory, and web search. Every answer is grounded in your actual ring data.
  • Workout recording with live heart-rate zones, GPS route maps, a Live Activity, and a Dynamic Island widget.
  • Daily check-in notifications generated by the coach from your recent trends.

Screenshots

Today AI Coach Sleep
Today Coach Sleep
Activity Vitals Workout Summary
Activity Vitals Workout Summary

How it works

System architecture: four layers on the phone. Data flows up from the ring into local storage; the coach reads sideways through tools, and the only thing that leaves the device is a coach question you choose to ask.

System architecture

The ring link: one custom BLE service, fixed 20-byte cleartext packets, commands out and notifications back.

Ring interaction

The AI coach: an agentic loop that calls tools to read your local data, then answers in a structured format.

AI coach


Getting started (Xcode)

Requirements

  • Xcode 16+ and an iOS 18+ device (Bluetooth and Live Activities need a real device — the simulator can't reach the ring).
  • A compatible 56ff BLE ring.
  • An OpenAI API key (for the Coach features).

Run it

  1. Open PulseLoop.xcodeproj in Xcode.
  2. Select the PulseLoop scheme and your physical device as the run target.
  3. Set your own Team and a unique Bundle Identifier under Signing & Capabilities (the Live Activity extension target needs this too).
  4. Build & run (⌘R).
  5. On first launch, complete onboarding, then keep the ring nearby — the app auto-scans and connects when Bluetooth powers on.
  6. To enable the Coach, open Settings → Coach and paste your OpenAI API key. It's stored in the iOS Keychain and never leaves the device except to call the model. Pick a model (gpt-5.4 is the default).

Demo data (no ring required)

You can explore the UI without hardware: Settings → "Reseed demo data", or launch with the -seedDemo YES argument.


Goals / Roadmap

  • On-device LLM integration — run the coach against a local model (Apple Foundation Models / a quantized on-device LLM) so the app works with no API key, no network, and full privacy.
  • Support more cheap rings — generalize the BLE protocol layer to handle other low-cost ring families beyond the 56ff devices.
  • Custom ring firmware — open firmware to unlock features the stock ring won't do, e.g. automatic activity/workout detection, higher-rate sampling, and richer sensor access.
  • Better onboarding — smoother first-run pairing, permission, and setup journey.
  • LLM tool-call transparency — surface exactly which tools the coach called and what data it read, so every answer is auditable.
  • Multimodal coach input — let the coach accept image and voice input (e.g. snap a meal, speak a question).

Known bugs

  • Sleep page shows the last recorded sleep, not last night's. If no sleep was recorded for the most recent day, the Sleep view falls back to the most recent session on file instead of reflecting that the latest day has no data.

Project layout

PulseLoop/
├─ RingProtocol/      BLE client + packet decoding for the ring
├─ Models/            SwiftData models (vitals, sleep, activity, coach)
├─ Services/          Sync, workouts, GPS, derived summaries
├─ Coach/             The LLM coach: orchestration, tools, prompts, notifications
│  ├─ Orchestration/  Agentic turn loop, tool execution, fallbacks
│  ├─ Tools/          Retrieval, analysis, charts, memory, web search, actions
│  ├─ OpenAI/         Responses API client
│  └─ Notifications/  Daily AI check-ins
├─ Views/             SwiftUI screens (Today, Vitals, Sleep, Activity, Coach)
└─ DesignSystem/      Charts, components, theming

PulseLoopLiveActivity/  Live Activity + Dynamic Island widget
PulseLoopTests/         Unit tests

License

This project is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).

You're free to share and adapt the work, including commercially, as long as you give appropriate credit. Please attribute:

PulseLoop by Saksham Bhutani — https://github.com/sakshambhutani/PulseLoop

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages