RxAgent is a full-stack AI agent that acts as a personal medication safety assistant. It uses a 5-step reasoning pipeline powered by Google Gemini 2.5 Flash to detect dangerous drug interactions, manage medication schedules, send smart email reminders, and track side effects β all through a natural conversational interface.
Built for the Google Cloud Rapid Agent Hackathon on the MongoDB track, RxAgent uses MongoDB Atlas Vector Search, Atlas Search, and aggregation pipelines as core infrastructure for its AI reasoning engine β not just as a passive data store.
- Natural language interface β talk to RxAgent like a real pharmacist
- Multi-turn conversation memory with MongoDB-persisted session history
- Smart intent detection: interaction check, schedule management, symptom analysis, Q&A
- Handles typos, brand names ("Panadol"), vague descriptions ("my blood thinner"), and casual phrasing ("my tummy hurts after my pill")
- 5-step AI agent reasoning pipeline with a transparent thinking panel
- Severity scoring: Safe β Mild β Moderate β Severe β Critical
- 150+ brand-to-generic name mappings (Panadol β Acetaminophen, Levar β Levetiracetam, etc.)
- Checks every pairwise combination for 3+ medications simultaneously
- Powered by MongoDB Atlas Vector Search across 256 curated drug interaction records (antibiotics, cardiac, diabetes, mental health, pain, immunosuppressants & more)
- Same-drug deduplication: Panadol + Acetaminophen = one drug, not a flagged interaction
- AI-generated optimal daily schedule using standard pharmacological guidelines
- Add, edit, and remove medications via natural conversation
- Per-medication dosage, timing, and instruction management
- 3-email flow: advance notice β dose-time alert β final reminder
- Mark as Taken directly from the email β no app login required
- Dashboard syncs instantly when a dose is confirmed via email
- Per-medication reminder settings (enable or disable individually)
- Timezone-aware β works correctly for users worldwide
- Real-time dose tracking for the current day
- Status tracking: β
Taken /
β οΈ Missed / π Due Now / π Upcoming / βοΈ Skipped - Grouped by time slot for an at-a-glance overview
- Log symptoms naturally from the chat ("I feel dizzy after Metformin")
- Agent recognises symptom mentions and prompts logging contextually
- AI-powered assessment links symptoms to suspected medications
- Full history with severity flags and monitoring status
- Manage medications for multiple family members from one account
- Switch between profiles instantly
- Each profile has independent medication schedule, side effects, and chat history
- Perfect for elderly parents, children, or anyone who needs medication oversight
MongoDB Atlas is used as a core part of the AI agent's reasoning pipeline β not just as a data store.
| Feature | MongoDB Capability |
|---|---|
| Drug interaction lookup | Atlas Vector Search β semantic similarity across interaction database |
| Medication name autocomplete | Atlas Search β real-time prefix search across 10,000+ drug names |
| Usage analytics & stats | Aggregation Pipelines β per-user totals across medications, sessions, side effects |
| Dose status tracking | Embedded documents β taken/missed/skipped state stored per day per entry |
| AI agent tooling | MongoDB MCP Server β agent introspects live database state during reasoning |
| All user data | Collections β schedules, sideEffectLogs, chatSessions, users, interactions |
rxagent/
βββ interactions β 256 curated drug interaction pairs (vector-indexed)
βββ schedules β medication entries with dose times and reminder settings
βββ sideEffectLogs β logged symptoms with AI assessment and suspected medications
βββ chatSessions β persistent conversation history per user
βββ users β authentication, profile, timezone
βββ doseTracking β daily taken/missed/skipped status per medication
256 curated drug interaction records:
- 12 Critical
- 84 Severe
- 119 Moderate
- 15 Mild
- 26 Safe combinations
Drug interactions are stored with semantic embeddings. When the agent checks "Is Warfarin safe with Aspirin?", it uses $vectorSearch to retrieve the most semantically relevant interaction records β enabling fuzzy, meaning-aware matching rather than brittle exact-string lookup.
RxAgent integrates the MongoDB MCP Server, giving the AI agent direct read access to live database state during reasoning. This enables context-aware responses grounded in the patient's actual current schedule.
Most apps use MongoDB as a dumb key-value store. RxAgent uses it as an active part of the AI pipeline:
- Vector Search drives the interaction lookup
- MCP Server lets the agent query live patient data
- Aggregations power the analytics dashboard
- Embedded documents track daily dose history
RxAgent uses a deterministic 5-step reasoning pipeline for drug interaction analysis:
User: "I take Warfarin, Aspirin, and Metformin β are these safe together?"
Step 1 β PARSE Resolve brand names Β· deduplicate Β· extract known drugs
Step 2 β SEARCH Vector search MongoDB interactions database for each drug pair
Step 3 β REASON Gemini 2.5 Flash analyses every combination with patient context
Step 4 β ASSESS Severity scoring: Safe / Mild / Moderate / Severe / Critical
Step 5 β RESPOND Structured response with severity badge + per-pair breakdown
For general questions and symptom queries, a separate prompt pipeline routes between:
- TYPE A β symptom/conversational β empathetic 2-3 sentence response with a follow-up question
- TYPE B β factual/informational β structured bullet-point format
Intent is classified in C# before reaching the AI β minimising unnecessary Gemini calls and keeping latency low.
| Chat + Interaction Check | Email Reminder | Due Today Dashboard |
|---|---|---|
| Schedule Manager | Side Effect Tracker | Agent Thinking Panel |
|---|---|---|
ββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββ
β Next.js 14 β β ASP.NET Core 10 Web API β
β Tailwind CSS β βββββββΊ β β
β Vercel β β ββββββββββββββββ ββββββββββββββββββ β
ββββββββββββββββββββ β βMedicationAgentβ β GeminiService β β
β ββββββββ¬ββββββββ βββββββββ¬βββββββββ β
β β β β
β ββββββββΌββββββββββββββββββββΌββββββββ β
β β MongoDB Atlas β β
β β Vector Search Β· Atlas Search β β
β β Aggregations Β· MCP Server β β
β ββββββββββββββββββββββββββββββββββββ β
β β
β ββββββββββββββββββββββββββββββββββ β
β β Gmail SMTP (Reminders) β β
β ββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββ
- .NET 10 SDK
- Node.js 20+
- MongoDB Atlas account (free tier works)
- Google Gemini API key
git clone https://github.com/HamzaNab-Dev/rxagent.git
cd rxagentcd RxAgent.ApiCreate appsettings.Development.json (gitignored β never commit this file):
{
"MongoDB": {
"ConnectionString": "mongodb+srv://<user>:<password>@<cluster>.mongodb.net",
"DatabaseName": "rxagent"
},
"Gemini": {
"ApiKey": "your-gemini-api-key",
"Model": "gemini-2.5-flash"
},
"Jwt": {
"Secret": "your-jwt-secret-minimum-32-characters",
"Issuer": "RxAgent",
"Audience": "RxAgent"
},
"Email": {
"SmtpHost": "smtp.gmail.com",
"SmtpPort": 587,
"From": "your-email@gmail.com",
"Password": "your-gmail-app-password"
},
"AllowedOrigin": "http://localhost:3000"
}dotnet run --project RxAgent.Api
# API available at http://localhost:5122# Seed interactions (includes vector embeddings β takes ~2 min on first run)
curl -X POST http://localhost:5122/api/dataseed/interactionscd rxagent-webCreate .env.local:
NEXT_PUBLIC_API_URL=http://localhost:5122npm install
npm run dev
# App available at http://localhost:3000| Key | Description |
|---|---|
MongoDB:ConnectionString |
MongoDB Atlas connection string |
MongoDB:DatabaseName |
Database name (default: rxagent) |
Gemini:ApiKey |
Google Gemini API key |
Gemini:Model |
Model ID (e.g. gemini-2.5-flash) |
Jwt:Secret |
JWT signing secret (minimum 32 characters) |
Jwt:Issuer |
JWT issuer (default: RxAgent) |
Jwt:Audience |
JWT audience (default: RxAgent) |
Email:SmtpHost |
SMTP host (e.g. smtp.gmail.com) |
Email:SmtpPort |
SMTP port (e.g. 587) |
Email:From |
Sender email address |
Email:Password |
Gmail App Password |
AllowedOrigin |
Frontend URL for CORS |
| Key | Description |
|---|---|
NEXT_PUBLIC_API_URL |
Backend API base URL |
RxAgent is a hackathon project for informational and educational purposes only. It is not a substitute for professional medical advice, diagnosis, or treatment. Always consult your doctor or pharmacist before making any medication decisions.
MIT License β see LICENSE for details.
Built with β€οΈ for the Google Cloud Rapid Agent Hackathon Β· MongoDB Track
Hamza Maher Nabelsi