Skip to content

Ibrahim4594/Neural-RX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ Neural RX - AI-Powered Healthcare Search

Winner Submission for the Elastic + Google Cloud Hackathon Challenge
Combining Elasticsearch hybrid search with Google Gemini AI for intelligent healthcare information discovery

Built with React TypeScript Powered by Elasticsearch Google Gemini AI License: MIT


🌟 Overview

Neural RX is an intelligent healthcare information discovery platform that makes finding medical information feel like having a conversation with a knowledgeable medical reference guide. By combining Elasticsearch's hybrid search capabilities with Google Gemini's generative AI, we've created an experience that's both precise and personal.

✨ Key Features

  • πŸ€– Conversational AI Interface - Ask health questions in plain language
  • πŸ” Hybrid Search - Combines keyword + semantic matching across 12+ medical conditions
  • πŸ—£οΈ Voice Input - Hands-free interaction using Web Speech API
  • πŸ’Ύ Export Chat History - Download conversations in PDF, Text, or JSON format
  • ⭐ Bookmarks - Star important messages for quick reference
  • 🧠 Context-Aware Conversations - Remembers previous questions for natural follow-ups
  • ⚑ Quick Actions - One-click access to 6 common health topics
  • πŸŒ“ Dark Mode - Beautiful UI that adapts to your preference
  • β™Ώ Accessible - WCAG AA compliant with keyboard navigation

πŸŽ₯ Demo

[Add screenshots or GIF demo here]

Try these sample queries:

  • "What are the symptoms of diabetes?"
  • "Tell me about treatment options for hypertension"
  • "How is asthma diagnosed?"
  • "What causes migraines?"

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    User Interface                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚   Chat Interface     β”‚  β”‚  Search Results Panel   β”‚ β”‚
β”‚  β”‚  - Voice Input       β”‚  β”‚  - Medical Cards        β”‚ β”‚
β”‚  β”‚  - Bookmarks         β”‚  β”‚  - Symptoms & Treatmentsβ”‚ β”‚
β”‚  β”‚  - Export Options    β”‚  β”‚  - Severity Badges      β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Express.js Backend                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚  Gemini AI       β”‚  β”‚  Elasticsearch           β”‚    β”‚
β”‚  β”‚  - Entity Extractβ”‚  β”‚  - Hybrid Search         β”‚    β”‚
β”‚  β”‚  - Response Gen  β”‚  β”‚  - 12 Health Conditions  β”‚    β”‚
β”‚  β”‚  - Context Aware β”‚  β”‚  - Multi-field Matching  β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Data Flow

  1. User asks a health question via chat or voice
  2. Gemini AI extracts medical entities from the query
  3. Elasticsearch performs hybrid search across healthcare database
  4. Search results provide context to Gemini AI
  5. Gemini generates an informed, conversational response
  6. UI displays both AI response and structured medical cards

πŸ› οΈ Technology Stack

Frontend

  • React 18 with TypeScript
  • Tailwind CSS + Shadcn UI for beautiful healthcare design
  • TanStack Query for data fetching and state management
  • Wouter for lightweight routing
  • Lucide React for icons

Backend

  • Express.js server with TypeScript
  • Elasticsearch (@elastic/elasticsearch) for hybrid search
  • Google Gemini AI (gemini-2.5-flash) for conversational intelligence
  • In-memory storage for chat history and analytics

Integrations

  • Elastic Cloud - Managed Elasticsearch deployment
  • Google AI Studio - Gemini API access
  • Web Speech API - Browser-native voice recognition

πŸš€ Getting Started

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/neural-rx.git
    cd neural-rx
  2. Install dependencies

    npm install
  3. Set up environment variables

    Create a .env file in the root directory:

    GEMINI_API_KEY=your_gemini_api_key_here
    ELASTIC_CLOUD_ID=your_elastic_cloud_id_here
    ELASTIC_API_KEY=your_elastic_api_key_here
    SESSION_SECRET=your_random_session_secret
  4. Get Elasticsearch credentials

    • Go to Elastic Cloud
    • Create a new Deployment (not Serverless)
    • Copy the Cloud ID
    • Open Kibana β†’ Stack Management β†’ Security β†’ API Keys
    • Create an API key with full permissions
    • Update ELASTIC_CLOUD_ID and ELASTIC_API_KEY in .env
  5. Get Google Gemini API key

  6. Run the application

    npm run dev
  7. Open your browser

    http://localhost:5000
    

The backend will automatically:

  • Connect to Elasticsearch
  • Create the healthcare_conditions index
  • Seed 12 medical conditions
  • Start serving on port 5000

πŸ“Š Healthcare Database

Neural RX includes a curated database of 12 major medical conditions:

Conditions Covered

  • Endocrine: Diabetes Type 2, Hypothyroidism
  • Cardiovascular: Hypertension, Atrial Fibrillation
  • Respiratory: Asthma
  • Neurological: Migraine
  • Musculoskeletal: Osteoarthritis, Rheumatoid Arthritis
  • Mental Health: Depression, Generalized Anxiety Disorder
  • Gastrointestinal: GERD (Gastroesophageal Reflux Disease)
  • Renal: Chronic Kidney Disease

Each condition includes:

  • Detailed description
  • Common symptoms
  • Treatment options
  • Severity rating (Mild, Moderate, Severe)
  • Medical category classification

🎨 Design System

Neural RX follows a healthcare-focused design philosophy:

  • Color Palette: Medical blue primary (#0EA5E9) with carefully chosen accent colors
  • Typography: Inter for body, JetBrains Mono for technical data
  • Spacing: Consistent 2/4/6/8 unit system
  • Accessibility: WCAG AA compliant with proper contrast ratios
  • Responsive: Works beautifully on desktop, tablet, and mobile

See design_guidelines.md for complete design specifications.


πŸ”§ Advanced Features

Voice Input

Powered by the Web Speech API for hands-free interaction:

  • Click the microphone icon in the chat input
  • Speak your health question naturally
  • Real-time speech-to-text transcription
  • Visual feedback while recording

Export Chat History

Save your conversations for future reference:

  • PDF: Professional formatting with timestamps
  • Text: Plain text format for easy reading
  • JSON: Machine-readable format for data analysis

Bookmarks

Mark important messages for quick access:

  • Click the star icon on any message
  • Bookmarks persist using localStorage
  • Yellow star indicates saved messages

Quick Actions

Pre-configured health topic cards for common queries:

  • πŸ’Š Medication Information
  • 🩺 Symptoms Checker
  • ❀️ Heart Health
  • 🧠 Mental Health Support
  • πŸ₯— Nutrition Advice
  • πŸ₯ Health Checkups

πŸ“ Project Structure

neural-rx/
β”œβ”€β”€ client/
β”‚   └── src/
β”‚       β”œβ”€β”€ components/        # React components
β”‚       β”‚   β”œβ”€β”€ ChatMessage.tsx
β”‚       β”‚   β”œβ”€β”€ ExportDialog.tsx
β”‚       β”‚   β”œβ”€β”€ QuickActions.tsx
β”‚       β”‚   └── ScrollToBottomButton.tsx
β”‚       β”œβ”€β”€ contexts/          # React contexts
β”‚       β”‚   └── BookmarksContext.tsx
β”‚       β”œβ”€β”€ hooks/             # Custom hooks
β”‚       β”‚   β”œβ”€β”€ useVoiceRecognition.ts
β”‚       β”‚   └── useBookmarks.ts
β”‚       β”œβ”€β”€ lib/               # Utilities
β”‚       β”‚   β”œβ”€β”€ exportUtils.ts
β”‚       β”‚   └── queryClient.ts
β”‚       β”œβ”€β”€ pages/             # Page components
β”‚       β”‚   └── Home.tsx
β”‚       └── types/             # TypeScript types
β”‚           └── speech.d.ts
β”œβ”€β”€ server/
β”‚   β”œβ”€β”€ data/                  # Healthcare dataset
β”‚   β”‚   └── healthcare-conditions.ts
β”‚   β”œβ”€β”€ elastic.ts             # Elasticsearch client
β”‚   β”œβ”€β”€ gemini.ts              # Gemini AI integration
β”‚   β”œβ”€β”€ routes.ts              # API endpoints
β”‚   β”œβ”€β”€ storage.ts             # In-memory storage
β”‚   └── index.ts               # Server entry point
β”œβ”€β”€ shared/
β”‚   └── schema.ts              # Shared TypeScript types
β”œβ”€β”€ design_guidelines.md       # Design system documentation
β”œβ”€β”€ replit.md                  # Project documentation
└── README.md                  # You are here!

πŸ”Œ API Endpoints

Chat & Search

  • POST /api/chat - Send message, get AI response + search results
  • GET /api/search?q={query} - Direct search without AI
  • GET /api/chat/history/:sessionId - Retrieve chat history

Analytics & Health

  • GET /api/analytics/searches - Search analytics data
  • GET /api/health - Server and Elasticsearch status

πŸ§ͺ Testing

The application includes comprehensive end-to-end tests covering:

  • Chat functionality with AI responses
  • Search results rendering
  • Voice input interactions
  • Bookmark persistence
  • Export functionality
  • Dark mode toggling
  • Responsive design

Run tests:

npm test

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please ensure your code follows the existing style and includes appropriate tests.


πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • Elastic for providing powerful hybrid search capabilities
  • Google Cloud for Gemini AI's natural language understanding
  • Replit for the development environment and hosting platform
  • Shadcn UI for beautiful, accessible component primitives
  • The open-source community for amazing tools and libraries

πŸ“§ Contact

Project Maintainer: [Your Name]
Email: your.email@example.com
Project Link: https://github.com/yourusername/neural-rx


🎯 Hackathon Submission

This project was built for the Elastic + Google Cloud Hackathon Challenge.

Challenge: Build the future of AI-powered search using Elastic's hybrid search and Google Cloud's generative AI tools.

What makes Neural RX special:

  • βœ… True hybrid search (keyword + semantic)
  • βœ… Context-aware AI conversations
  • βœ… Production-ready features (voice, export, bookmarks)
  • βœ… Beautiful, accessible healthcare UI
  • βœ… Real medical database with structured data
  • βœ… Sub-8-second response times

Built with ❀️ for better healthcare information access

⭐ Star this repo if you find it helpful!

Report Bug Β· Request Feature Β· Live Demo

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages