Nov 10, 2025

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:

  1. Backend API (FastAPI)

    • Responsible for storing users, medications and dose logs.

    • Exposes REST endpoints for CRUD operations, AI queries, and scheduling control.

  2. Scheduler (APScheduler)

    • Periodically checks medication schedules and creates dose-events.

    • Triggers reminders at scheduled times.

  3. 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.

  4. Web Dashboard (optional frontend)

    • A modern, responsive UI (Tailwind) to add medicines, view active medications and chat with an integrated AI assistant.

  5. 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

  1. Create / Configure

    • A user (via the dashboard or Telegram /add) registers a medication with name, dose_text, and schedule_time (HH:MM).

  2. Persistence

    • The backend stores User → Medication → DoseLog entries in a relational DB (SQLite for local; swapable to PostgreSQL for production).

  3. Scheduling

    • APScheduler reads medications and schedules jobs for each medication time (or runs a frequent job to check upcoming doses and create DoseLog entries).

  4. Reminder Delivery

    • When the scheduled time arrives the scheduler creates a DoseLog and calls the reminder service.

    • Reminder service uses the Telegram bot API to send a message with a confirmation button.

  5. User Confirmation

    • User taps “I took it ✅” in Telegram. The bot receives the callback, updates the DoseLog.taken_time and status="taken" via backend API.

  6. AI Assistant Interaction

    • User types a question on the dashboard or via an AI endpoint; ai_service replies (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_URL in config for Postgres.

  • Notifications: isolate reminder logic so you can add SMS/email/push easily.

  • AI plug-in: ai_service.py is 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)

  1. Personal medication adherence — Daily reminders to patients with chronic conditions (diabetes, hypertension).

  2. Caregivers — Manage meds for elderly family members and confirm intake remotely.

  3. Small clinics / pharmacies — Provide follow-up and adherence nudges for prescriptions after discharge.

  4. Clinical trials / research — Lightweight adherence tracking where precise timestamps of dose-taking are useful.

  5. Health coaching apps — Combine AI tips with reminders to increase adherence and habit formation.


Getting started (quick setup)

  1. Create a virtualenv and install requirements (FastAPI, uvicorn, apscheduler, sqlalchemy, python-telegram-bot).

  2. Set TELEGRAM_TOKEN as an environment variable.

  3. Run python main.py.

  4. Open http://127.0.0.1:8000 for dashboard and http://127.0.0.1:8000/docs for API docs.

  5. Add medications and test reminders via Telegram.


Next recommended improvements (prioritized)

  1. Add user authentication and multi-user support.

  2. Timezone handling and support for recurring schedules.

  3. Persistent job store or external worker (Celery) for reliable scheduled tasks.

  4. Upgrade AI to OpenAI (ChatGPT) for meaningful, context-aware responses (with safety filtering).

  5. 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

Hackathon

HackFest

View All Projects

1

Give a star to encourage!Discussion
Start a new conversation!
Login to join the discussion