AI Meditation Reminder
Link to open source: https://github.com/MDADILIFTEKHAR/AI-Meditation-Reminder.git
Link to Live Project: https://mdadiliftekhar.github.io/AI-Meditation-Reminder/
Smart Medication Reminder with AI Assistant — Project Overview
What this build is
This project is a full-stack Medication Reminder system with three tightly integrated parts:
-
Backend API (FastAPI)
-
Responsible for storing users, medications and dose logs.
-
Exposes REST endpoints for CRUD operations, AI queries, and scheduling control.
-
-
Scheduler (APScheduler)
-
Periodically checks medication schedules and creates dose-events.
-
Triggers reminders at scheduled times.
-
-
Notifications (Telegram Bot)
-
Sends reminder messages to users via Telegram, with an interactive “I took it ✅” button.
-
Receives basic commands (e.g.,
/add) and callback actions from users.
-
-
Web Dashboard (optional frontend)
-
A modern, responsive UI (Tailwind) to add medicines, view active medications and chat with an integrated AI assistant.
-
-
AI Assistant
-
A simple local AI module now (rule-based) that can be swapped for a real model (OpenAI, local LLM) to answer health or medication questions, give tips and help guide users.
-
Why this was built (motivation)
-
Medication non-adherence is a common and serious problem — missed doses reduce treatment effectiveness and can cause harm.
-
Many people need simple, reliable reminders tied to their routine (time-based reminders, confirmation of intake).
-
Telegram is ubiquitous and easy to use — it removes friction for users who already use messaging apps.
-
Adding an AI assistant makes the product more engaging: it can answer routine questions, give quick advice, and reduce user friction for tasks like scheduling or clarifying dose instructions.
-
A modular backend architecture makes it easy to extend (mobile apps, SMS, voice assistants, clinic integrations).
How it works — end-to-end flow
-
Create / Configure
-
A user (via the dashboard or Telegram
/add) registers a medication withname,dose_text, andschedule_time(HH:MM).
-
-
Persistence
-
The backend stores User → Medication → DoseLog entries in a relational DB (SQLite for local; swapable to PostgreSQL for production).
-
-
Scheduling
-
APScheduler reads medications and schedules jobs for each medication time (or runs a frequent job to check upcoming doses and create DoseLog entries).
-
-
Reminder Delivery
-
When the scheduled time arrives the scheduler creates a
DoseLogand calls the reminder service. -
Reminder service uses the Telegram bot API to send a message with a confirmation button.
-
-
User Confirmation
-
User taps “I took it ✅” in Telegram. The bot receives the callback, updates the
DoseLog.taken_timeandstatus="taken"via backend API.
-
-
AI Assistant Interaction
-
User types a question on the dashboard or via an AI endpoint;
ai_servicereplies (rule-based or real LLM). This helps with quick guidance (e.g., “Can I take this with food?”).
-
Key features (current and planned)
Current
-
Add medications (name, time, dose_text).
-
Persistent storage of medicines and dose logs.
-
Scheduler runs in background and triggers reminders.
-
Telegram bot sends reminders with actionable buttons.
-
Simple AI assistant endpoint and dashboard chat UI.
Planned / Easy to add
-
Multi-user support with authentication.
-
Support for multiple reminders per day, variable schedules (every X hours, weekdays only).
-
Snooze, skip, recurring patterns (cron-like).
-
Real LLM integration (OpenAI, local LLM) for richer AI responses.
-
SMS, email, push notifications.
-
Analytics dashboard (adherence rates, missed doses, weekly summary).
-
Clinical integrations (EHR export, clinician notifications).
Architecture / Tech stack
-
Backend: FastAPI (Python) — lightweight, async-ready, auto docs (
/docs). -
Scheduler: APScheduler — job management in-process or using external worker later.
-
ORM/DB: SQLAlchemy with SQLite (dev); PostgreSQL (prod suggested).
-
Bot: python-telegram-bot v20+ (async API).
-
Frontend: HTML + Tailwind (simple) — can swap to React for a richer UI.
-
AI: local rule-based service now (
ai_service.py) — upgradeable to OpenAI or other LLM. -
Deployment: Local dev via
uvicorn, production via container/ASGI server + process manager, and a reliable scheduler or worker for jobs.
Example API endpoints (what you get)
-
POST /medication/add— Add a medication (form or JSON). -
GET /— Dashboard UI showing medicines. -
POST /ai/ask— Ask the AI assistant a question. -
POST /mark_taken/{dose_id}— Mark a dose as taken (used by bot callback). -
GET /docs— Swagger UI for testing APIs.
Security, privacy & compliance considerations
-
Sensitive data: medication & health data is sensitive. If used beyond local demo:
-
Use HTTPS everywhere.
-
Use authentication (JWT / OAuth) and per-user authorization.
-
Store minimal personal data and consider encryption at rest for sensitive fields.
-
Provide privacy policy and data retention rules.
-
-
Telegram tokens: keep tokens secret (use environment variables).
-
GDPR/HIPAA: for production or clinical contexts, ensure compliance (data transfer, audit logs, patient consent).
Configurability & extensibility
-
Swap DB: change
DATABASE_URLin config for Postgres. -
Notifications: isolate reminder logic so you can add SMS/email/push easily.
-
AI plug-in:
ai_service.pyis a single place to replace the rule-based logic with an LLM API call. -
Scaling: move scheduler to a separate worker (Celery/RQ, or external job scheduler). Run the bot as a separate deployment process or serverless function if needed.
Limitations & risks (honest view)
-
Rule-based AI is limited; complex medical advice should be given only by qualified professionals.
-
This system currently assumes correct user-provided schedules (no timezone handling). Add timezone awareness for global users.
-
Single-instance scheduler may fail if the process restarts — consider persistent job store (e.g., APScheduler with DB job store) or a distributed worker.
How this can be useful (concrete use cases)
-
Personal medication adherence — Daily reminders to patients with chronic conditions (diabetes, hypertension).
-
Caregivers — Manage meds for elderly family members and confirm intake remotely.
-
Small clinics / pharmacies — Provide follow-up and adherence nudges for prescriptions after discharge.
-
Clinical trials / research — Lightweight adherence tracking where precise timestamps of dose-taking are useful.
-
Health coaching apps — Combine AI tips with reminders to increase adherence and habit formation.
Getting started (quick setup)
-
Create a virtualenv and install requirements (FastAPI, uvicorn, apscheduler, sqlalchemy, python-telegram-bot).
-
Set
TELEGRAM_TOKENas an environment variable. -
Run
python main.py. -
Open
http://127.0.0.1:8000for dashboard andhttp://127.0.0.1:8000/docsfor API docs. -
Add medications and test reminders via Telegram.
Next recommended improvements (prioritized)
-
Add user authentication and multi-user support.
-
Timezone handling and support for recurring schedules.
-
Persistent job store or external worker (Celery) for reliable scheduled tasks.
-
Upgrade AI to OpenAI (ChatGPT) for meaningful, context-aware responses (with safety filtering).
-
Analytics & reporting for adherence insights and exportable reports.
Final summary
This project is a practical, extensible system designed to increase medication adherence using automated reminders, an easy-to-use Telegram interface, and an AI assistant for user support. The backend is modular and scalable, so you can start local and grow to a production-grade service with user auth, analytics, and richer AI capabilities.
This build was uploaded as a hackathon project
