Health monitoring apps are everywhere, but most rely on external wearables.
What if you could track your heart rate directly on your phone and still sync results to the cloud for secure storage and analysis?
Thatβs exactly what I built as part of my MSc dissertation: a Heart Rate Monitoring App powered by Kotlin (Jetpack Compose) and a Python + Firestore backend.
π© Problem
Wearables are expensive and not always accessible.
So the question was:
Can we capture, process, and store heart rate data using only a smartphone, and still keep it reliable and secure?
β¨ Features
- π± Real-time heart rate monitoring
- π¨ Threshold alerts (notify if BPM is abnormal)
- βοΈ Cloud sync with Firestore
- π Reports + trends visualization
- π User authentication with Firebase
π Tech Stack
- Frontend: Kotlin, Jetpack Compose, MVVM, Coroutines
- Backend: Python Flask microservice
- Cloud: Google Cloud Firestore
- Auth: Firebase Authentication
- CI/CD: GitHub Actions
βοΈ How It Works
- User signs in (Firebase Auth).
- The app captures heart rate (camera/sensor).
- Readings are sent to Firestore.
- A Python backend checks for alerts.
- Users view reports + trends in the app.
π» Sample Code
Kotlin β Saving Data to Firestore
val db = FirebaseFirestore.getInstance()
val heartRateData = hashMapOf(
"userId" to userId,
"heartRate" to bpm,
"status" to status,
"timestamp" to System.currentTimeMillis()
)
db.collection("HeartRateReading")
.add(heartRateData)
.addOnSuccessListener { Log.d("Firestore", "Saved!") }
.addOnFailureListener { e -> Log.w("Firestore", "Error", e) }
Jetpack Compose β Displaying Trends
@Composable
fun HeartRateCard(avg: Int, max: Int, min: Int) {
Column(
modifier = Modifier.padding(16.dp)
) {
Text("Avg: $avg BPM", fontWeight = FontWeight.Bold)
Text("Max: $max BPM", color = Color.Red)
Text("Min: $min BPM", color = Color.Blue)
}
}
Python β Simple Alerting Service
from google.cloud import firestore
db = firestore.Client()
def check_alerts():
docs = db.collection("HeartRateReading").stream()
for doc in docs:
data = doc.to_dict()
if data["heartRate"] > 140:
print(f"β οΈ High HR detected: {data['heartRate']} BPM for {data['userId']}")
π Screenshots
(Add your app UI and Firestore console screenshots here)
π Lessons Learned
- On-device vs cloud β trade-offs between privacy and performance
- Importance of data security in healthcare apps
- A clean UI/UX makes adoption easier
- Cloud pipelines = real-time dashboards + analysis
πΊ Roadmap
- π€ Add ML models for anomaly detection
- β€οΈ Expand to other vitals (SpO2, BP)
- π Build iOS client with Kotlin Multiplatform
- π₯ Healthcare integration (e.g., NHS)
β Conclusion
This project showed me how AI + Mobile + Cloud can combine to deliver meaningful health insights.
π Code available here: HeartRateMobile
π Medium version (more detailed): Real-Time Health Monitoring on Android
Thanks for reading! Follow me for more posts about Android, AI, and cross-platform development π
Top comments (0)