Health Protocol Tracker
SwiftUI iOS app for peptide inventory, injection logs, reminders, and pharmacokinetic concentration modeling.
Metrics / Signals
Problem
What this project solves
Personal health protocols can become hard to track safely when inventory, dose history, reconstitution, reminders, and half-life math live in separate places.
Architecture
How it is put together
The app follows MVVM with a repository layer for Firestore access across peptide catalog, stock, active vials, blends, logs, schedules, and user profile data. Combine snapshot listeners push repository updates into view models, while all collections are scoped under each anonymous Firebase user.
iOS product
Core Workflow
The app centers on active vials, remaining quantity, injection history, reminders, and concentration-over-time feedback. A dashboard shows vial cards with liquid-level progress, low inventory alerts, depletion warnings, and quick injection actions.
- Inventory tracks peptide catalog metadata, vial stock by size, active vial lifecycle, and reconstitution details.
- The injection sheet auto-populates active vial context, validates dose limits, and logs every injection to Firestore.
- Schedules are persisted and mirrored into local notifications with UNUserNotificationCenter.
Domain math
Pharmacokinetic Engine
HalfLifeService uses a superposition model to calculate current estimated concentration from all prior doses: C(t) = sum dose_i * 0.5^((t - t_i) / half-life). The service handles arbitrary dose histories, single compounds, and blended compounds.
- Generates time-series chart data at configurable resolution and date range.
- Supports normalized and absolute concentration views in Swift Charts.
- Moves the live current-concentration marker as time advances.
Data design
Blend and Safety Modeling
- Blend entities store multiple constituent peptides with concentration ratios.
- Injection against a blend splits dose volume across the underlying compounds for logging and charting.
- Dose cap validation lives in InjectViewModel, making the rule testable and harder to bypass from the UI.
Verification
Testing
- HalfLifeServiceTests cover concentration calculations, zero-dose cases, and future timestamps.
- ReconstitutionServiceTests cover BAC water volume calculation edge cases.
Decisions
Technical choices
- Kept Firestore access out of SwiftUI views by routing all persistence through seven domain repositories.
- Put dose safety checks in the injection view model so remaining-vial validation cannot be bypassed by text field behavior.
- Modeled blends as first-class entities so injection logging and concentration charts can split dose by compound ratio.
Tradeoffs
Constraints and next choices
- Firestore offline persistence avoided a Core Data sync layer, reducing complexity while preserving offline behavior.
- Combine fit real-time snapshot listeners well, even though async/await would be simpler for one-shot reads.
- Anonymous auth reduced onboarding friction but leaves a future migration path for Sign in with Apple.