Skip to content

andyDTU/eq-foresight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Eq Foresight

AI-driven hypoglycemia prediction — 30 minutes before it happens.


The Problem

For people living with Type 1 diabetes, hypoglycemia (low blood sugar) can strike without warning — during sleep, exercise, or daily life. Reactive treatment (eating sugar after symptoms appear) is often too late.

The Solution

Eq Foresight is an iOS app that uses on-device AI to predict hypoglycemic events 30 minutes in advance, enabling proactive treatment before symptoms begin.


What It Does

Feature Description
30-Minute Prediction CoreML cascade of 4 models (5, 10, 15, 30 min horizons) running entirely on-device
Real-Time Dashboard Live glucose chart + dotted prediction line with confidence bands
Smart Alerts Escalating notifications (warning → alarm → pump stop) with intelligent cooldowns
Activity Mode Automatically adjusts glucose targets during exercise to prevent workout-induced lows
Morning Briefing Automated overnight analysis — "Your night was stable, lowest point 4.2 mmol/L at 03:15"
Auto-Tune Analyzes 24h of data to suggest personalized insulin sensitivity and carb ratio adjustments
iOS 18 Widget & Live Activity Current glucose, risk trend, and quick-launch on Lock Screen and Home Screen
Privacy-First All AI inference runs locally. No data leaves the device. No cloud. No subscription.

Architecture Overview

┌───────────────────────────────────────────────┐
│              Eq Foresight iOS App             │
│  ┌─────────────┐  ┌─────────────┐  ┌────────┐ │
│  │  Dashboard  │  │   History   │  │Settings│ │
│  │   (SwiftUI) │  │   (SwiftUI) │  │(SwiftUI│ │
│  └──────┬──────┘  └──────┬──────┘  └───┬────┘ │
│         │                │             │      │
│  ┌──────┴────────────────┴─────────────┴────┐ │
│  │         DashboardViewModel (MVVM)        │ │
│  │  ┌────────────┐  ┌────────────────────┐  │ │
│  │  │DataBuffer  │  │   InferenceEngine  │  │ │
│  │  │(23 features│  │  ┌──────────────┐  │  │ │
│  │  │ 36-48 steps│  │  │ HypoPredictor│  │  │ │
│  │  │ 4h history)│  │  │  4 CoreML    │  │  │ │
│  │  └─────┬──────┘  │  │   models     │  │  │ │
│  │        │         │  └──────────────┘  │  │ │
│  └────────┼─────────┴────────────────────┘  │ │ 
│           │                                 │ │
│  ┌────────┴──────────┐  ┌─────────────────┐ │ │
│  │ NightscoutService │  │ HealthKitService│ │ │
│  │  (Glucose +       │  │  (Heart Rate,   │─┘ │
│  │   Treatments)     │  │   Blood Glucose)│   │
│  └───────────────────┘  └─────────────────┘   │
└───────────────────────────────────────────────┘

Data Flow:

  1. HealthKit provides heart rate and (optionally) blood glucose — offline-resilient, low latency
  2. Nightscout provides CGM history and treatment logs (bolus, carbs) — SHA1-authenticated
  3. DataBuffer maintains a rolling 4-hour window of 23 features, normalized to Python training format
  4. InferenceEngine runs 4 CoreML models in parallel, producing probability scores for each horizon
  5. DashboardViewModel orchestrates UI updates, notifications, and widget data sharing

Deep dive: docs/architecture.md


Tech Stack

iOS App

  • SwiftUI + MVVM pattern with @MainActor isolation
  • CoreML (4 bundled .mlpackage models, MLComputeUnits.all)
  • HealthKit (heart rate, blood glucose, workout detection)
  • WidgetKit + Live Activities (iOS 17+)
  • Background Tasks (BGTaskScheduler with 25s timeout guards)
  • User Notifications with custom actions (Log Carbs, Snooze)
  • XcodeGen for reproducible .xcodeproj generation

Machine Learning Pipeline (separate private repo)

  • Python with PyTorch / TensorFlow for model training
  • Feature engineering pipeline producing 23 time-series features from raw CGM, HR, insulin, and carb data
  • Cascade architecture — 4 models trained for different prediction horizons (h1, h2, h3, h6)
  • CoreML export with coremltools for on-device inference
  • Iso-calibration for probability calibration across horizons

Screenshots

📸 Screenshots will be added here. Key views to showcase:

  • Dashboard — hero glucose value, risk gauge, prediction graph
  • Activity Mode — blue-themed workout view with adjusted targets
  • Morning Briefing — overnight summary card with TIR
  • Settings — physiology profile, auto-tune results
  • Widget — Home Screen widget with glucose, trend, and risk bar

Privacy & Ethics

  • All AI inference runs on-device. No server, no cloud processing, no data monetization.
  • No automated dosing. The app provides warnings and carb recommendations, but never controls insulin delivery.
  • Open Nightscout integration. Users own their data; the app only reads what the user already manages.

Status

🟡 Active Development. The iOS app is in late-stage development with on-device inference, background processing, and real-time widgets functional. CoreML models are trained and calibrated. Beta testing planned.


Source Code

The full source code for both the iOS app and the ML training pipeline is available in private repositories. Access is granted to potential employers, collaborators, and investors upon request.

  • iOS App: Private repository (Swift, SwiftUI, CoreML, HealthKit)
  • ML Pipeline: Private repository (Python, PyTorch, feature engineering, CoreML export)

📩 Interested in reviewing the code? Contact me or connect on LinkedIn.


Built By

andyDTU — iOS Engineer & ML Engineer focused on health technology and on-device AI.


Proactive. Private. Powerful.

About

Eq Foresight — AI-driven hypoglycemia prediction for iOS. Showcasing the product, architecture, and impact without revealing proprietary code.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages