RxRecon

Drug Interaction Detection for Resource-Constrained Environments

RxRecon detects dangerous drug interactions using a Graph Neural Network (GNN). It accepts vague inputs in 12+ languages via text, voice, or images - designed for patients without access to pharmacists.

Not medical advice. This is a decision-support tool. Always consult a healthcare provider.


Quick Start

# Clone and start (requires Docker)
git clone https://github.com/your-org/rxrecon.git
cd rxrecon
docker-compose up -d

# Access
# Frontend: http://localhost:3000
# API Docs: http://localhost:8000/docs

One-liner for development:

make setup && make dev

Architecture

Architecture Download PDF

System Flow

Input (Text/Voice/Image)
    → Drug Identification (Multilingual + Traditional Medicine)
    → Fast-Path Detection (25+ Critical DDI pairs)
    → GNN Risk Inference (HGT with 17 node types, 20 edge types)
    → Patient Context Modulation (45+ clinical factors)
    → Safety-Lite Final Gate (Rule-based validation)
    → Layered Output (Detection + Optional Guidance)

Components

Backend (backend/)

| Component | Purpose | |———–|———| | app/api/ | FastAPI endpoints | | app/gnn_max/ | GNN model (HGT++, training, inference) | | app/services/ | Safety service, OCR, OpenAI integration | | app/core/ | Config, security, rate limiting |

Frontend (website/)

Next.js 15 + React 19 clinician interface with real-time safety checks.

GNN Engine (backend/app/gnn_max/)

| File | Purpose | |——|———| | hgt_model.py | Heterogeneous Graph Transformer | | config.py | 32 hazard families, 45+ patient flags | | edge_cases.py | Multilingual matcher, traditional medicine | | robust_inference.py | Fast-path detection, consensus layer | | patient_context.py | Graph modulation for patient factors |

Data (backend/data/)

| Directory | Contents | |———–|———-| | processed/bakg.json | Bio-Action Knowledge Graph (87MB) | | gnn_models/ | Trained model weights | | external/ | DrugBank, RxNorm, TCMSP sources |


User Guide

For Patients/Caregivers

  1. Open http://localhost:3000
  2. Enter medications (any language, vague descriptions OK)
  3. Add patient factors (age, conditions, allergies)
  4. Review risk assessment
  5. Export PDF for your doctor visit

For Clinicians

  1. Access http://localhost:3000/clinician
  2. Enter patient’s medication list
  3. Review interaction warnings with evidence tiers
  4. Check mechanistic explanations (e.g., CYP3A4 inhibition)
  5. Export clinical documentation

API Usage

# Quick safety check
curl -X POST http://localhost:8000/api/v1/safety/quick-check \
  -H "Content-Type: application/json" \
  -d '{"drugs": ["warfarin", "aspirin"]}'

# Full safety check with patient context
curl -X POST http://localhost:8000/api/v1/safety/check \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": ["metformin", "ibuprofen"],
    "patient": {"age": 72, "conditions": ["diabetes", "ckd_stage_3"]}
  }'

GNN Training

Prerequisites

Train Model

cd backend

# Full training (recommended)
python scripts/build_bakg_and_train.py --preset max --epochs 50

# Quick training (for testing)
python scripts/build_bakg_and_train.py --preset lite --epochs 10

# Skip BAKG rebuild if already exists
python scripts/build_bakg_and_train.py --skip-bakg --epochs 50

Model Outputs

Verify Installation

python scripts/verify_gnn.py
python scripts/test_system.py

Configuration

Key environment variables (.env):

# Required
DATABASE_URL=postgresql://user:pass@localhost/rxrecon
OPENAI_API_KEY=sk-...

# Optional
REDIS_URL=redis://localhost:6379
GOOGLE_VISION_API_KEY=...
RATE_LIMIT_ENABLED=true

See backend/app/core/config.py for all options.


Safety Design

Quadruple Redundancy

  1. Fast-Path Detection - Rule-based critical DDI (zero latency)
  2. GNN Inference - Neural network prediction
  3. Safety-Lite - Offline rule-based fallback
  4. Escalation Gate - Final rule-based validation

Evidence Tiers

Patient Context Flags (45+)

Critical: dialysis, pregnant, cyp2d6_poor_metabolizer, hla_b5701 Important: long_qt, opioid_naive, on_anticoagulation Additional: penicillin_allergy, heavy_alcohol_use


Deployment

docker-compose up -d

Manual

# Backend
cd backend
pip install -r requirements.txt
uvicorn app.main:app --host 0.0.0.0 --port 8000

# Frontend
cd website
npm install && npm run build && npm start

Production Checklist


License

Research use only. Not for clinical deployment without proper validation.


*RxRecon v2.0 January 2026*