MediTrack — Medication Adherence Tracker

🌍 Inspiration

Every year, an estimated 125,000 people die from medication non-adherence globally. The World Health Organization reports that only about 50% of patients with chronic conditions take their medication as prescribed — a silent crisis that quietly undermines healthcare systems worldwide.

I was inspired by a personal observation: a family member managing hypertension frequently forgot their medication schedule, relying on scraps of paper and memory. No app they tried felt simple enough to stick with. I wanted to build something that solves exactly that — clean, fast, no clutter — directly addressing UN SDG Goal 3: Good Health and Well-being, specifically targets:

  • SDG 3.4 — Reduce premature mortality from non-communicable diseases
  • SDG 3.8 — Achieve universal access to healthcare services and essential medicines

🛠️ How I Built It

MediTrack is a full-stack web application built with Flask and SQLite, following clean software engineering principles from day one.

The architecture uses Flask's Application Factory Pattern, keeping the app modular and testable:

meditrack/
├── app/
│   ├── __init__.py        # App factory
│   ├── routes/            # Auth, medications, dashboard blueprints
│   ├── models/            # SQLAlchemy User & Medication models
│   ├── templates/         # Jinja2 HTML templates
│   └── static/            # CSS + JS
├── tests/                 # Unit tests
├── config.py              # Environment-aware configuration
└── run.py                 # Entry point

Authentication is handled with Flask-Login and password hashing via Werkzeug. Forms are protected against CSRF with Flask-WTF.

The streak calculation is the core health-tracking logic. For a user who logs \( n \) consecutive days of full medication adherence, the streak \( S \) is computed as:

$$S = \max_{k} \left{ k \mid \forall\, d \in [D - k + 1,\, D],\; \text{allTaken}(d) = \text{true} \right}$$

where \( D \) is today's date and \(\text{allTaken}(d)\) returns true if every scheduled medication was logged on day \( d \).

Each medication has a configurable frequency, dosage, and scheduled time, stored in SQLite via SQLAlchemy ORM. The dashboard queries today's due medications and renders completion status in real time.


🚧 Challenges I Faced

1. Streak logic with irregular schedules Medications aren't always daily — some are every 2 days, weekly, or "as needed." Calculating streaks correctly across irregular frequency patterns required careful date arithmetic and handling of edge cases like newly added medications.

2. Secure secret key management Hardcoding secrets is a common beginner mistake. I implemented a layered approach: the app raises a RuntimeError in production if SECRET_KEY is not set via environment variable, and generates an ephemeral key in development — meaning no secret ever touches the codebase.

3. Keeping the UI frictionless The biggest UX risk was adding too many features. I deliberately kept the dashboard to a single interaction: see today's medications → check them off. Every feature added was tested against the question: "Does this help someone take their medication?"


📚 What I Learned

  • Application Factory Pattern in Flask for scalable, testable app structure
  • SQLAlchemy ORM relationships — linking UserMedicationIntakeLog models cleanly
  • Environment-aware configuration with python-dotenv and production safety guards
  • The importance of docstrings and code comments — not just for readability, but for AI-powered tools like PresentMe to accurately interpret your codebase
  • How small, consistent UX decisions compound into a product people actually use

🎯 SDG 3 Impact

MediTrack targets the most overlooked layer of healthcare: the space between a doctor's prescription and a patient's daily life. By improving medication adherence, it directly contributes to:

SDG Target How MediTrack helps
3.4 — Non-communicable diseases Consistent medication reduces cardiovascular and chronic illness complications
3.8 — Universal health coverage Low-barrier tool accessible to anyone with a browser, no hardware required
3.b — Access to medicines Helps patients maximise the value of prescribed medicines they already have

Built With

Share this project:

Updates