Inspiration
Every year, 125,000 people are hospitalized due to dangerous drug interactions they never knew about. 50% of patients take multiple medications daily, yet most have no reliable way to check if their combination is safe.
I've seen this problem firsthand — elderly family members managing 5+ medications, caregivers juggling complex regimens, and patients who simply trust their prescriptions are safe together. Even pharmacists can miss interactions when patients see multiple doctors.
RxAgent was born from a simple question: what if everyone had access to an intelligent pharmacist, available 24/7, that actually takes action — not just answers questions?
What it does
RxAgent is a full-stack AI medication safety agent that:
- Checks drug interactions — detects dangerous combinations across 3+ medications simultaneously, with severity scoring from Safe to Critical
- Manages medication schedules — add medications via natural conversation, get AI-generated optimal timing based on pharmacology
- Sends smart email reminders — 3-email flow (advance warning → dose time → final reminder) with "Mark as Taken" button that syncs instantly with the dashboard
- Tracks side effects — log symptoms naturally from chat, AI links them to suspected medications
- Understands real people — handles typos ("Warfarim"), brand names ("Panadol" → Paracetamol), and casual language ("my tummy hurts after my pill")
- Caregiver mode — manage medications for multiple family members from one account, switching between profiles instantly. Perfect for elderly parents or anyone who needs medication oversight.
All through a natural conversational interface with a transparent 5-step AI reasoning pipeline visible to the user in real time.
How we built it
The Agent Pipeline
The core of RxAgent is a deterministic 5-step reasoning pipeline:
UNDERSTAND → Extract and resolve medication names (150+ brand-to-generic mappings)
RETRIEVE → Vector search MongoDB Atlas for semantically relevant interactions
REASON → Gemini 2.5 Flash analyses every pairwise combination with patient context
ASSESS → Severity scoring: Safe → Mild → Moderate → Severe → Critical
RESPOND → Structured response with severity badges, symptoms, and emergency guidance
MongoDB as the AI Backbone
MongoDB Atlas isn't just a database — it's an active part of the reasoning pipeline:
- Atlas Vector Search powers semantic drug interaction lookup
- Atlas Search enables real-time medication name autocomplete
- Aggregation Pipelines compute live analytics across users and medications
- Embedded Documents track daily dose history (taken/missed/skipped per day)
- MongoDB MCP Server gives the agent direct read access to live patient data during reasoning
- 256 curated drug interactions across Critical, Severe, Moderate, Mild and Safe severity levels — with full vector embeddings for semantic search
Smart Email Reminder System
- Background job runs every 60 seconds on Railway
- Detects medications due in next 30 minutes
- Sends personalized email with "Mark as Taken" button
- At dose time → second urgent reminder email
- After 15 minutes → final reminder, no more snooze
- Clicking email button updates MongoDB directly — no login needed
- Timezone-aware for users worldwide
Tech Stack
- Frontend: Next.js + Tailwind CSS → Vercel
- Backend: ASP.NET Core .NET 10 → Railway
- AI: Google Gemini 2.5 Flash
- Database: MongoDB Atlas (Vector Search + Atlas Search + MCP Server)
- Email: Gmail SMTP with .NET BackgroundService
- Auth: JWT with BCrypt
Challenges we ran into
Brand Name Deduplication — Early versions flagged "Coumadin + Warfarin" as a Critical overdose because they're the same drug. Building deduplication that resolves brands to generics before checking interactions was critical for patient safety.
Timezone-Aware Reminders — Railway runs UTC but users are in Jordan, USA, Japan. Had to detect and store each user's timezone on every login, then convert server time per-user in the background job.
Intent Detection — "I take Warfarin and Aspirin" should add to schedule. "I take Warfarin and Aspirin, are they safe?" should check interactions. Getting the agent to distinguish these required combining C#-level classification with system prompt engineering.
Safety Before Schedule — When a user says "I take Warfarin and Ibuprofen daily", the agent must check interactions FIRST and block dangerous medications from being added. Getting this order of operations correct while keeping natural conversation flow was complex.
Streaming Animation — Implementing smooth letter-by-letter typing that doesn't pause when switching browser tabs required replacing setTimeout with requestAnimationFrame and performance.now() for time-based positioning.
Accomplishments that we're proud of
- Built a true AI agent — not just a chatbot. RxAgent takes real actions: writes to MongoDB, sends emails, blocks dangerous medications, tracks doses
- 150+ brand name mappings — real users say "Panadol" not "Paracetamol". The agent understands both
- Fully synced reminder system — email and app always reflect the same state, no matter which one the user interacts with
- Natural language that actually works — "my tummy hurts after my pill" correctly triggers symptom logging flow
- Production-grade security — JWT auth, BCrypt passwords, rate limiting, CORS, userId checks on every query
- Built entirely solo in under 5 weeks while learning Next.js and React from scratch
What we learned
- MongoDB Atlas Vector Search is genuinely powerful for semantic medical data — meaning-aware matching finds interactions even for medications not explicitly in the database
- MCP Server integration opens a new paradigm for agents that need live data context during reasoning
- The difference between a chatbot and a true agent is taking action — not just generating text
- Building for real users means handling typos, brand names, casual language, and edge cases no spec ever mentions
- Background jobs in .NET need proper fault tolerance — one user's failure must never crash the job for everyone else
What's next for RxAgent
- Mobile app (React Native) with push notifications
- Enhanced caregiver dashboard — shared alerts and family medication reports
- Doctor appointment summaries — AI-generated visit preparation notes shared directly with your doctor
- Expanded drug database — currently 256 interactions, targeting 500+
- Multi-language support — Arabic already supported, expanding to more languages
- Refill reminders — notify when medication is running low based on dose tracking
- Wearable integration — Apple Health / Google Fit for automatic dose confirmation
- Pharmacy integration — connect with local pharmacies for refill ordering
Built With
- .net
- 10
- ai
- api
- asp.net
- authentication
- c#
- cloud
- core
- css
- gmail
- javascript
- jwt
- next.js
- railway
- react
- smtp
- tailwind
- typescript
- vercel
Log in or sign up for Devpost to join the conversation.