DEV Community

sneh1117
sneh1117

Posted on

🏥 I Built a Full-Stack AI-Powered Health Tracker with Django, React & Celery

What if medication reminders, symptom tracking, and AI-powered health insights lived in one clean dashboard?

That’s why I built MediTrack — a production-ready health & medication tracking system with automated reminders and AI-driven analysis.

🔗 Frontend Repo: https://github.com/sneh1117/meditrack-frontend
🔗 Backend Repo: https://github.com/sneh1117/MediTrack
🌐 Live App: https://meditrack7.vercel.app/
⚙️ API Docs: https://meditrack.up.railway.app/api/docs/


🚀 What is MediTrack?

MediTrack is a full-stack health management system that allows users to:

  • Track medications
  • Log daily symptoms & moods
  • Get AI-powered health insights
  • Receive automated medication reminders via email
  • Monitor adherence rates
  • Enable doctor-patient data access with role-based permissions

It’s built with real-world production concepts like JWT auth, background tasks, rate limiting, object-level permissions, and secure deployment.


🧠 The Problem I Wanted to Solve

Many people:

  • Forget medications
  • Don’t track symptom severity properly
  • Can’t see trends over time
  • Don’t know when symptoms correlate with medications

I wanted to build something that:

  • Feels like a modern SaaS dashboard
  • Uses AI responsibly
  • Implements real backend architecture patterns
  • Is portfolio-ready & production-structured

🏗️ Architecture Overview

Frontend: React + Vite (deployed on Vercel)
Backend: Django REST Framework (deployed on Railway)
Database: PostgreSQL
Background Tasks: Celery + Redis
AI Layer: Google Gemini
Docs: Swagger via drf-spectacular

The system is split cleanly:

  • React handles UI + API calls
  • Django REST handles business logic
  • Celery manages reminders asynchronously
  • Gemini analyzes symptom history
  • PostgreSQL stores structured health data

🎨 Frontend Stack

  • React 18
  • Vite
  • Tailwind CSS
  • Lucide Icons
  • JWT authentication
  • Responsive dashboard layout

Features

  • Secure login & registration
  • Medication CRUD
  • Symptom logging (1–10 severity scale)
  • Mood tracking (1–5 scale)
  • AI insights display
  • Dashboard charts
  • Production-ready API configuration

⚙️ Backend Stack

Built using:

  • Django 5.0
  • Django REST Framework
  • PostgreSQL
  • Celery 5.3
  • Redis
  • Google Gemini (gemini-pro)
  • Railway

🔐 Security Implementations

This wasn’t just a CRUD API. I implemented:

  • JWT authentication (1hr access / 7-day refresh)
  • Role-based permissions (Patient & Doctor)
  • Object-level access control
  • Rate limiting on login & registration
  • Input sanitization (XSS prevention)
  • HTTPS + HSTS in production
  • Environment-based config (no secrets in code)
  • CORS & CSRF protection

🤖 AI Health Insights

The /api/symptoms/ai_insights/ endpoint:

  • Detects recurring patterns
  • Identifies medication correlations
  • Suggests when medical attention may be needed
  • Provides lifestyle suggestions

AI responses are cached for 24 hours per user to avoid unnecessary API calls.

⚠️ The AI does not diagnose — it only provides observations.


⏰ Automated Medication Reminders

Using Celery Beat:

  • Once Daily → 08:00 UTC
  • Twice Daily → 08:00 & 20:00
  • Three Times Daily → 08:00, 14:00, 20:00
  • Custom schedules supported

Railway runs:

  • Web process
  • Celery worker
  • Celery beat scheduler

This mimics real SaaS production architecture.


📊 Dashboard API (Chart.js Ready)

The backend returns pre-formatted datasets for charts:

  • Symptom trends
  • Average severity
  • Common symptoms
  • Medication adherence rates
  • Mood trends

This separation keeps frontend logic clean.


🧩 Challenges I Faced

  1. Managing Celery on cloud deployment
  2. Designing doctor-patient permissions securely
  3. Structuring reusable serializers
  4. Handling AI rate limits
  5. Coordinating frontend & backend CORS correctly
  6. Ensuring reminder scheduling works across timezones

Each problem forced me to think beyond tutorials.


📚 What I Learned

  • Production architecture matters more than features
  • Background tasks change how you design systems
  • AI integration needs caching + safety boundaries
  • Security layers are essential, not optional
  • Clean API design makes frontend easier

This project helped me move from “building apps” to “building systems.”


🔮 Roadmap

  • WebSocket notifications (Django Channels)
  • Predictive health analytics
  • PDF health reports
  • CI/CD pipeline
  • More frontend visualizations

🛠️ How to Run Locally

Backend

git clone https://github.com/sneh1117/MediTrack
cd meditrack
python -m venv venv
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver
Enter fullscreen mode Exit fullscreen mode

Run Celery:

celery -A config worker --loglevel=info
celery -A config beat --loglevel=info
Enter fullscreen mode Exit fullscreen mode

Frontend

git clone https://github.com/sneh1117/meditrack-frontend.git
cd meditrack-frontend
npm install
npm run dev
Enter fullscreen mode Exit fullscreen mode

💡 Final Thoughts

MediTrack started as a medication tracker…

But it became a deep dive into:

  • Secure backend design
  • Async task processing
  • AI integration
  • Production deployment
  • Clean frontend architecture

If you're learning full-stack development, I highly recommend building something that includes:

  • Authentication
  • Background jobs
  • Role-based permissions
  • Deployment to cloud
  • API documentation

That’s where real growth happens.


If you have feedback or suggestions, I’d love to hear them 🙌
Thanks for reading!

— Sneha

Top comments (0)