Skip to content

thechaoticsportsguy/RxBuddy

Repository files navigation

πŸ’Š RxBuddy β€” AI-Powered Pharmacy Consultation App

A full-stack AI web application that allows patients to search 500+ common pharmacy questions β€” covering drug interactions, OTC medications, dosage guidance, and more β€” powered by semantic search, voice recognition, and the Claude AI API.


🧠 What It Does

Patients visiting a pharmacy often have simple but important questions:

  • "Can I take ibuprofen with my blood pressure medication?"
  • "What cold medicine is safe if I have diabetes?"
  • "How much Tylenol can I take per day?"

RxBuddy lets patients get instant, AI-powered answers without waiting for a pharmacist consultation β€” available 24/7 on any device. Just type or speak your question and RxBuddy handles the rest.


πŸ—οΈ Project Structure

rxbuddy/
β”‚
β”œβ”€β”€ backend/                  # FastAPI Python backend
β”‚   β”œβ”€β”€ main.py               # API entry point
β”‚   β”œβ”€β”€ search.py             # ML search engine (TF-IDF + KNN)
β”‚   β”œβ”€β”€ database.py           # PostgreSQL connection & queries
β”‚   β”œβ”€β”€ claude_client.py      # Anthropic Claude API integration
β”‚   └── models.py             # Data models / schemas
β”‚
β”œβ”€β”€ data/                     # Data pipeline
β”‚   β”œβ”€β”€ questions.csv         # 500+ pharmacy questions dataset
β”‚   β”œβ”€β”€ load_data.py          # Pandas pipeline to clean & load data
β”‚   └── seed_db.py            # Seeds PostgreSQL database
β”‚
β”œβ”€β”€ ml/                       # Machine Learning
β”‚   β”œβ”€β”€ tfidf_search.py       # TF-IDF + Cosine Similarity baseline
β”‚   β”œβ”€β”€ knn_search.py         # KNN + Sentence Embeddings
β”‚   └── train.py              # Model training & retraining pipeline
β”‚
β”œβ”€β”€ frontend/                 # React / Next.js frontend
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ index.js          # Home / search page
β”‚   β”‚   β”œβ”€β”€ results.js        # Search results page
β”‚   β”‚   └── category.js       # Browse by category page
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ SearchBar.js      # Includes voice recognition button
β”‚   β”‚   β”œβ”€β”€ QuestionCard.js
β”‚   β”‚   └── AnswerModal.js
β”‚   └── styles/
β”‚
β”œβ”€β”€ dashboard/                # Streamlit analytics dashboard
β”‚   └── app.py                # Most searched queries, usage trends
β”‚
β”œβ”€β”€ .env.example              # Environment variables template
β”œβ”€β”€ requirements.txt          # Python dependencies
β”œβ”€β”€ package.json              # Node dependencies
└── README.md

πŸ› οΈ Tech Stack

Languages

Language Usage
Python Backend, ML pipeline, data processing
JavaScript React frontend
SQL PostgreSQL queries, search logging

Machine Learning & Data

Library Usage
scikit-learn TF-IDF vectorizer, KNN model, cosine similarity
pandas Data cleaning, structuring 500 questions dataset
NumPy Numerical operations, vector math
sentence-transformers Sentence embeddings for semantic search
NLTK Drug name extraction, NLP preprocessing

Backend

Tool Usage
FastAPI REST API server
PostgreSQL Questions database + search logs
SQLAlchemy ORM for database interaction
Anthropic Claude API AI-generated answers

Frontend

Tool Usage
React / Next.js Patient-facing web interface
Tailwind CSS Styling
Web Speech API Voice recognition for hands-free search

Analytics

Tool Usage
Streamlit Internal analytics dashboard
Matplotlib / Seaborn Search trend visualizations

Project Management

Tool Usage
JIRA Sprint planning, ticket tracking, team collaboration
GitHub Version control, pull requests, code review

DevOps

Tool Usage
Vercel Frontend deployment
Railway Backend + PostgreSQL hosting

πŸ€– ML Architecture

User types or speaks a query
            ↓
   Web Speech API (voice β†’ text)
            ↓
TF-IDF + Cosine Similarity  ←── Instant baseline match
            ↓
KNN + Sentence Embeddings   ←── Semantic understanding
            ↓
Popularity weighting        ←── From PostgreSQL search logs
            ↓
Claude API                  ←── Generates full AI answer
            ↓
User clicks result β†’ logged β†’ model improves over time

RxBuddy uses a feedback-driven ML system β€” every user search is logged to PostgreSQL, and the model continuously re-ranks results based on real patient behavior.


πŸ—„οΈ Database Schema

-- Questions table
CREATE TABLE questions (
    id SERIAL PRIMARY KEY,
    question TEXT NOT NULL,
    category VARCHAR(50),
    tags TEXT[],
    answer TEXT,
    created_at TIMESTAMP DEFAULT NOW()
);

-- Search logs table (feeds ML retraining)
CREATE TABLE search_logs (
    id SERIAL PRIMARY KEY,
    query TEXT NOT NULL,
    matched_question_id INT REFERENCES questions(id),
    clicked BOOLEAN DEFAULT FALSE,
    session_id VARCHAR(100),
    searched_at TIMESTAMP DEFAULT NOW()
);

πŸ“Š Analytics Dashboard

The Streamlit dashboard (internal use) shows:

  • Top 20 most searched questions
  • Search volume by category
  • Click-through rate per question
  • Daily/weekly usage trends
  • Unanswered query clustering (questions users ask that don't match anything)

πŸš€ Getting Started

1. Clone the repo

git clone https://github.com/thechaoticsportsguy/rxbuddy.git
cd rxbuddy

2. Set up Python environment

pip install -r requirements.txt

3. Set up environment variables

cp .env.example .env
# Add your Anthropic API key and PostgreSQL connection string

4. Seed the database

python data/seed_db.py

5. Run the backend

uvicorn backend.main:app --reload

6. Run the frontend

cd frontend
npm install
npm run dev

7. Run the analytics dashboard

streamlit run dashboard/app.py

πŸ“‹ Resume Bullets

Built RxBuddy, a full-stack AI pharmacy consultation app using FastAPI, React, PostgreSQL, and the Claude API β€” implementing a hybrid NLP search engine combining TF-IDF, KNN, and sentence embeddings with a PostgreSQL feedback loop that continuously improves from real user search behavior, with voice recognition via Web Speech API, deployed on Vercel + Railway.


⚠️ Disclaimer

RxBuddy is an informational tool only. It does not replace professional medical or pharmaceutical advice. Always consult a licensed pharmacist or physician for medical decisions.


πŸ‘₯ Authors

Om Gohel

Mihir Jani

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors