https://github.com/and3rn3t/health
Tinkering with Apple HealthKit and the LiDAR sensors in Apple iPhones.
https://github.com/and3rn3t/health
ai gait-analysis health healthkit lidar ml walking wellness
Last synced: 3 months ago
JSON representation
Tinkering with Apple HealthKit and the LiDAR sensors in Apple iPhones.
- Host: GitHub
- URL: https://github.com/and3rn3t/health
- Owner: and3rn3t
- License: mit
- Created: 2025-08-30T21:38:34.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2026-03-01T10:54:44.000Z (3 months ago)
- Last Synced: 2026-03-01T14:49:11.486Z (3 months ago)
- Topics: ai, gait-analysis, health, healthkit, lidar, ml, walking, wellness
- Language: TypeScript
- Homepage: https://health.andernet.dev
- Size: 29.9 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 46
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# π₯ VitalSense - Apple Health Insights & Fall Risk Monitor
> **A comprehensive health data analysis platform that transforms Apple Health data into actionable insights while providing proactive fall risk monitoring, real-time gait analysis, and emergency response capabilities.**
**π Now Live:** [https://health.andernet.dev](https://health.andernet.dev)
[](https://www.typescriptlang.org/)
[](https://reactjs.org/)
[](https://workers.cloudflare.com/)
[](https://developer.apple.com/ios/)
[](LICENSE)
[](https://health.andernet.dev)
[](.github/workflows/branding-audit.yml)
[](https://github.com/and3rn3t/health/actions/workflows/ios-tests.yml)
[](https://github.com/and3rn3t/health/actions/workflows/ci-core.yml)
[](https://github.com/and3rn3t/health/actions/workflows/security-quality.yml)
[](https://github.com/and3rn3t/health/actions/workflows/optimized-pipeline.yml)
[](https://github.com/and3rn3t/health/actions/workflows/smoke.yml)
> Badges above are lightweight SVGs committed by CI (no external shield calls) keeping repo self-contained & offline-view friendly.
## π Quick Start
### Web Application (5 minutes)
```bash
# Install dependencies
npm install
# Start development servers
npm run dev # React app on http://localhost:5173
npm run cf:dev # Cloudflare Worker on http://localhost:8787
npm run ws:dev # WebSocket server on ws://localhost:3001
```
### π³ Docker (Worker + WebSocket)
```bash
# Build and start both services
docker compose up --build -d
# Access
# - Worker (API + static): http://localhost:8789
# - WebSocket server: ws://localhost:3001
# View logs
docker compose logs -f worker
docker compose logs -f websocket
# Stop
docker compose down
```
See also: docs/DOCKER.md for full usage and environment details.
#### Docker Dev Workflow (VS Code Tasks)
- Bring up everything and run health checks:
- Tasks β "π³ Docker: Dev Workflow (no logs)"
- Tail logs:
- "π³ Docker: Logs (worker)" and "π³ Docker: Logs (websocket)"
- Quick probes:
- Worker: "probe-health-8789-curl" β
- WebSocket: "π³ Docker: Health (websocket)" β
Endpoints:
- API + static:
- WebSocket REST health:
### iOS Application (15 minutes on Mac)
1. **Open Xcode** and create new iOS project
2. **Add HealthKit capability** in project settings
3. **Copy Swift files** from `ios/HealthKitBridge/` to your project
4. **Configure Info.plist** with HealthKit permissions
5. **Build and run** on physical device (HealthKit requires real device)
π **[Complete Setup Guide β](docs/SETUP_GUIDE.md)**
## ποΈ Architecture
```text
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β iOS App β β React Web App β β Caregiver β
β (HealthKit) βββββΊβ (Dashboard) βββββΊβ Dashboard β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Cloudflare Workers (API + Static) β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββββββ β
β β Health β β Auth & β β Emergency Alert β β
β β Analytics β β Privacy β β System β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Cloudflare KV β β Cloudflare R2 β β WebSocket β
β (Health Data) β β (File Storage) β β (Real-time) β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
```
## β¨ Key Features
### π₯ Health Analytics
- **Comprehensive Data Analysis**: Import and analyze all Apple Health metrics
- **Advanced Insights**: Correlation analysis and trend detection beyond Apple Health
- **Personalized Recommendations**: AI-driven health insights and interventions
- **Clinical Integration**: HIPAA-compliant health record management
### β οΈ Fall Risk Monitoring
- **Proactive Assessment**: Real-time gait and balance analysis
- **Predictive Modeling**: Machine learning for fall risk prediction
- **Personalized Alerts**: Custom risk thresholds and notifications
- **Intervention Tracking**: Monitor effectiveness of prevention strategies
### π¨ Emergency Response
- **Automatic Fall Detection**: Real-time monitoring with immediate alerts
- **Emergency Contacts**: Instant notification system for caregivers
- **Location Sharing**: GPS coordinates for emergency responders
- **Incident Documentation**: Comprehensive fall tracking and reporting
### π¨ββοΈ Caregiver Dashboard
- **Real-time Monitoring**: Live health metrics and status updates
- **Collaborative Care**: Multi-stakeholder communication platform
- **Clinical Documentation**: Professional reporting and record keeping
- **Privacy Controls**: Granular consent and access management
## π οΈ Technology Stack
### Frontend
- **React 19** with TypeScript for type-safe UI development
- **Vite** for fast development and optimized builds
- **Tailwind CSS v4** with semantic design tokens
- **Radix UI** for accessible component primitives
- **TanStack Query** for server state management
### Backend
- **Cloudflare Workers** for serverless edge computing
- **Hono** for lightweight API framework
- **Cloudflare KV/R2** for data storage and file handling
- **WebSocket** bridge for real-time communications
### Mobile
- **Swift** with SwiftUI for native iOS experience
- **HealthKit** for secure health data access
- **Core Motion** for advanced sensor data analysis
- **Network** framework for reliable data transmission
### Security & Privacy
- **End-to-end encryption** for all health data
- **Zero-knowledge architecture** - server cannot read personal data
- **HIPAA compliance** with comprehensive audit trails
### Performance & Optimization
- **Production Bundle**: ~187KB optimized with aggressive code splitting
- **React Performance**: Lazy loading, memoization, and Suspense boundaries
- **Edge Computing**: Cloudflare Workers for sub-100ms global response times
- **Real-time Updates**: WebSocket connections with automatic reconnection
- **Incremental Loading**: Component-level code splitting for faster initial loads
_Latest optimization: December 2024 - See `docs/_archive/optimizations/OPTIMIZATION_DEPLOYMENT_COMPLETE.md`_
#### Performance & SLO Monitoring
A new synthetic + config-driven performance layer enforces budgets:
Files:
- `slo.config.json` β central thresholds (JS/CSS gzip budgets, import latency, WebSocket connect time)
- `scripts/node/analysis/perf-slo-sampler.js` β synthetic sampler (writes `reports/perf-sample.json`)
- `scripts/ci/performance-slo-probe.mjs` β existing bundle/import latency probe (writes `reports/perf-slo.json`)
Usage:
```bash
pnpm run perf:sample # Generate synthetic perf sample
pnpm run ci:perf-slo # CI SLO probe (bundle + import latency)
pnpm run pre:release:gate # Includes perf sample + SLO probe (soft-fail unless --strict)
```
Outputs:
- `reports/perf-sample.json` / `perf-sample-history.json`
- `reports/perf-slo.json` / `perf-slo-history.json`
Statuses: `ok`, `degraded` (budget exceeded), `soft-missing-dist` (dist absent but tolerated), or `error`.
Extend later: real-user metrics (LCP, CLS) + daily trend aggregator.
- **JWT authentication** with secure token management
## π Project Status
### β
Completed
- β
React web application with health dashboard
- β
Cloudflare Workers API with secure endpoints
- β
iOS HealthKit bridge with real-time sync
- β
WebSocket server for live data streaming
- β
End-to-end encryption and JWT authentication
- β
Automated deployment pipelines
- β
Comprehensive documentation and troubleshooting guides
- β
Automated branding & rebrand residue audit (HTML markers + legacy term scan)
### π§ In Progress
- π Advanced fall detection algorithms
- π Enhanced caregiver dashboard features
- π Apple Watch companion application
### π Planned
- π
Production deployment optimization
- π
Clinical integration partnerships
- π
Advanced analytics and ML features
- π
Healthcare provider portal
## π§Ύ Branding & Rebrand Integrity
We enforce VitalSense branding consistency in CI:
- Combined audit script: `node scripts/node/branding/branding-audit.js`
- Runs in smoke + deploy workflows (HTML marker verification + legacy "HealthGuard" residue scan)
- Outputs markdown report: `reports/branding-audit-summary.md` (uploaded as artifact)
Local development quick checks:
```bash
npm run branding:audit:local # Against local Worker (port 8787)
npm run verify:branding:local # Simple HTML marker pass
npm run verify:rebrand # Residual term scan only
```
Branding gates fail if required VitalSense markers are missing or any legacy brand strings remain. A dedicated workflow (`branding-audit.yml`) runs in two modes (matrix):
| Mode | Target | Purpose |
| ---------- | ----------------------------- | ----------------------------------------------- |
| local | | Verifies dev Worker build branding consistency |
| production | | Ensures deployed site remains correctly branded |
## β
Pre-Release Gate (Unified Quality Check)
Run a consolidated set of validations before any production (or critical) deployment:
```bash
pnpm run pre:release:gate # Quick tests, standard mode
pnpm run pre:release:gate -- --full # Full test suite
pnpm run pre:release:gate -- --strict # Treat soft-fail steps as hard failures
```
What it runs (in order):
1. Config validator
2. Lint (TypeScript quick; strict with `--strict`)
3. Test suite (quick or full)
4. Production build + bundle size thresholds (JS <400KB gzip, CSS <60KB gzip)
5. Branding + rebrand residue audit (soft-fail unless `--strict`)
6. WebSocket schema drift guard (soft-fail unless `--strict`)
7. Performance SLO probe (if present, soft-fail)
8. Analytics version mismatch snapshot (soft-fail)
9. Privacy / log guard (hard-fail)
Outputs:
- `reports/pre-release-gate.json` structured machine-readable summary
- `reports/pre-release-gate.md` markdown table for CI artifact / PR comment
Flags:
`--skip-build` `--skip-tests` `--skip-branding` `--skip-ws` `--skip-perf` `--json`
Integrate this as a mandatory CI job prior to deploy to enforce performance, branding, and protocol integrity.
## π Documentation
### π Getting Started
### CSS Strategy
We follow a consolidationβfirst CSS approach: one primary hashed CSS bundle from Tailwind (`src/main.css`), with optional codeβsplit CSS only for large, lazyβloaded features. Rationale, guardrails, and workflow live in `docs/development/CSS_STRATEGY.md`.
### π± iOS Development
- **[iOS Setup Guide](docs/IOS_DEPLOYMENT_GUIDE.md)** - Complete iOS build and deployment
- **[Windows Development](docs/IOS_DEVELOPMENT_WINDOWS.md)** - iOS development on Windows
- **[Build Troubleshooting](docs/BUILD_TROUBLESHOOTING.md)** - Common issues and solutions
### ποΈ Architecture & API
- **[Architecture Overview](docs/ARCHITECTURE.md)** - System design and technical decisions
- **[API Documentation](docs/API.md)** - REST endpoints and data schemas
- **[WebSocket Guide](docs/WEBSOCKETS.md)** - Real-time communication patterns
### π§ Advanced Topics
- **[Security Baseline](docs/SECURITY_BASELINE.md)** - Security implementation details
- **[Problem Solutions Database](docs/PROBLEM_SOLUTIONS_DATABASE.md)** - Comprehensive troubleshooting
- **[Lessons Learned](docs/LESSONS_LEARNED.md)** - Project insights and best practices
## π€ Contributing
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on:
- Development setup and workflow
- Code style and quality standards
- Testing requirements and strategies
- Security and privacy considerations
- Documentation expectations
### Development Environment
```bash
# Prerequisites
node >= 18.0.0
npm >= 9.0.0
# For iOS development
Xcode >= 15.0 (macOS only)
```
### Code Quality
- **TypeScript** strict mode enabled
- **ESLint** for code quality
- **Prettier** for consistent formatting
- **Zod** for runtime validation
- **React Testing Library** for component tests
## π License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## π Support
- **Documentation**: Complete guides in [`/docs`](docs/) folder
- **Issues**: [GitHub Issues](https://github.com/and3rn3t/health/issues) for bugs and feature requests
- **Security**: Report security issues via [SECURITY.md](SECURITY.md)
- **Discussions**: [GitHub Discussions](https://github.com/and3rn3t/health/discussions) for questions and ideas
## π₯ About VitalSense
VitalSense represents the next generation of proactive health monitoring, combining the power of Apple's HealthKit with advanced analytics and machine learning to provide unprecedented insights into health trends and fall risk assessment. Built with privacy-first principles and clinical-grade security, it empowers individuals and their care teams to make informed decisions about health and safety.
**Key Principles:**
- **Privacy First**: Your health data stays private with end-to-end encryption
- **Proactive Care**: Early detection and intervention prevent health crises
- **Collaborative**: Seamless communication between patients, families, and providers
- **Evidence-Based**: Decisions backed by comprehensive data analysis
---
Built with β€οΈ for better health outcomes and peace of mind.