Project Story: HealthCostBenefit - Evidence-Based Supplement Analysis

Inspiration

The world of dietary supplements is vast and often confusing, filled with marketing claims that lack scientific backing. As health-conscious individuals, we often struggle to make informed decisions about what supplements are truly beneficial and cost-effective. This challenge inspired us to create HealthCostBenefit, a platform designed to cut through the noise by providing objective, evidence-based analysis of supplements using principles from health economics. Our goal was to empower users to make data-driven choices, focusing on real health outcomes and return on investment (ROI).

What We Learned

Building HealthCostBenefit was an incredible learning journey across several domains:

  • Health Economics & QALYs: We delved deep into the concept of Quality-Adjusted Life Years (QALYs), a standardized measure used in health economics to quantify the health benefit of interventions. Understanding how to translate diverse health outcomes into a single, comparable metric was a significant challenge and a core learning.
  • AI-Powered Data Synthesis: We learned how to leverage AI models (specifically OpenAI) for complex tasks like synthesizing research findings, generating comprehensive supplement profiles, and even validating the legitimacy of supplement names. This involved careful prompt engineering and handling AI outputs.
  • Multi-API Integration & Orchestration: The project required integrating with multiple external APIs – PubMed for medical literature, RapidAPI for real-time pricing data, and OpenAI for content generation. Orchestrating these disparate data sources, managing their unique requirements, and ensuring data consistency was a key technical learning.
  • Robust Supabase Implementation: Supabase served as our backend, and we gained extensive experience with its features, including database schema design, Row Level Security (RLS) policies, and Edge Functions for secure API proxying. We learned the importance of robust error handling and connection management for a seamless user experience.
  • Frontend State Management & User Experience: Developing a responsive and intuitive user interface with React and Tailwind CSS, especially for complex features like real-time AI processing and comparison tables, taught us valuable lessons in state management, performance optimization, and providing clear user feedback.

How We Built It

HealthCostBenefit is a full-stack application built with a modern tech stack:

  • Frontend: The user interface is developed using React with Vite for a fast development experience. Tailwind CSS provides a highly customizable and efficient styling framework, while Lucide React offers a clean and consistent icon set. Chart.js is used for dynamic data visualizations in the single supplement analysis.
  • Backend & Database: Supabase acts as our primary database, storing all supplement data, including AI-generated insights. We defined a clear schema for supplements, capturing details like cost, QALY gain, effectiveness, and evidence levels.
  • AI & External Integrations:
    • AISupplementService: This is the core orchestration layer, managing the entire AI processing pipeline for each supplement.
    • PubMedService: Responsible for searching and extracting information from medical literature. All calls are securely proxied through a Supabase Edge Function to protect API keys and manage rate limits.
    • RapidAPIService: Aggregates real-time pricing data from various retailers, also proxied via a Supabase Edge Function.
    • OpenAIService: Utilizes OpenAI's models to generate detailed, evidence-based supplement profiles, including benefits, typical users, and considerations. This is also proxied via a Supabase Edge Function.
    • QALYEstimationService: Converts extracted health outcomes into QALY equivalent gains, providing a standardized measure of health benefit.
    • SupplementValidationService: Ensures the legitimacy and existence of supplement names by cross-referencing medical literature and commercial databases.
  • Key Features: The application offers three main modes:
    • Single Analysis: Provides a deep dive into one supplement's cost-effectiveness, QALY gain, and detailed profile.
    • Comparison Mode: Allows users to compare up to 10 supplements side-by-side, ranked by ROI.
    • AI Database Expansion: An innovative feature that enables users to add new supplements to the database, which are then automatically researched, analyzed, and profiled by our AI system.

Challenges We Faced

Developing HealthCostBenefit presented several significant challenges:

  • Ensuring Data Accuracy and Reliability: Integrating data from diverse sources (PubMed, commercial APIs, AI models) meant constantly validating the accuracy and consistency of the information. We implemented robust validation layers and confidence scores to reflect the reliability of the data.
  • Managing External API Dependencies: Dealing with API rate limits, potential downtime, and varying data formats from external services required careful design of our service layer, including implementing mock data fallbacks to ensure the application remained functional even when real APIs were unavailable.
  • Supabase RLS Complexity: Configuring Row Level Security policies in Supabase to allow AI-generated inserts and updates by anonymous users while maintaining secure public read access proved to be intricate. We iterated through several policy adjustments to get this right, as reflected in our migration files.
  • AI Hallucination and Bias Mitigation: While powerful, AI models can sometimes "hallucinate" or introduce biases. We designed our system to cross-reference AI-generated content with factual data from PubMed and implemented confidence scores to indicate the reliability of AI-derived information.
  • Performance Optimization: Processing and displaying complex data, especially during AI expansion and comparison, required careful attention to performance, including optimizing data fetching, rendering, and UI responsiveness.
  • Comprehensive Error Handling: Providing clear, actionable error messages to the user during complex, multi-step AI processes was crucial. We focused on identifying specific failure points (e.g., database connection, API key issues) and communicating them effectively.

Built With

  • accessed-via-supabase-edge-function-proxy)-pubmed-(medical-literature-database
  • accessed-via-supabase-edge-function-proxy)-rapidapi-(product-pricing-data
  • and
  • and-edge-functions)-supabase-edge-functions-(serverless-functions-for-api-proxying
  • css
  • database
  • for
  • html
  • javascript
  • jspdf
  • lucide
  • migrations)
  • openai
  • powered-by-deno)-openai-(ai-content-generation
  • pubmed
  • rapidapi
  • row-level-security
  • schema
  • sql
  • supabase
  • tailwind
  • vite
  • ypescript
Share this project:

Updates