A production-grade, failure-aware AI symptom checker built with Next.js 14, TypeScript, and OpenAI.
- Rule-Based Emergency Detection: Instant detection of critical symptoms before AI analysis
- Dual Confidence Scoring: Transparent diagnostic confidence and information completeness metrics
- Risk Stratification: Clear risk levels (Critical, High, Medium, Low) with actionable recommendations
- Emergency Escalation: Full-screen alerts with direct links to emergency services
- OpenAI GPT-4 Integration: Advanced symptom analysis with structured responses
- Differential Diagnosis: Multiple possible conditions with probability estimates
- Follow-up Questions: Intelligent questioning to gather more information
- Uncertainty Transparency: Always expresses limitations and recommends professional care
- Firebase Authentication: Secure Google Sign-In and Email/Password authentication
- Conditional Data Storage: Anonymous users have no data stored; logged-in users can save history
- Encrypted Storage: All data encrypted in transit and at rest
- No Third-Party Sharing: Health information stays private
- Multi-Language Support: English, Hindi, and Marathi
- Caregiver Mode: Describe symptoms for someone else
- Hospital Finder: Quick access to nearby hospitals
- Responsive Design: Works seamlessly on desktop and mobile
- Glass Morphism UI: Modern, accessible design with smooth animations
- Node.js 18+ installed
- OpenAI API key
- Firebase project (optional, for authentication)
- Clone and navigate to the project:
cd symptosafe- Install dependencies:
npm install- Set up environment variables:
cp .env.local.example .env.local- Edit
.env.localand add your keys:
OPENAI_API_KEY=your_openai_api_key_here
# Firebase (optional - app works without auth)
NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project_id.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_project_id.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id- Run the development server:
npm run devTry these test scenarios:
- Normal Symptoms: "I have headache and fever"
- Emergency: "Severe chest pain and breathing problem"
- Vague Symptoms: "I don't feel well"
Use the "Test Scenarios" button in the bottom-right corner for quick testing.
- Runs BEFORE AI analysis
- Detects emergency keywords instantly
- Returns structured emergency results
- Covers: chest pain, stroke, breathing issues, bleeding, suicide, seizures, overdose, burns
- OpenAI GPT-4 integration
- Structured JSON responses
- Confidence scoring (0-100)
- Information completeness tracking
- Risk level assessment
- Follow-up question generation
- Zustand for global state
- User authentication state
- Message history
- Analysis results
- Emergency status
- Language preferences
lib/firebase/config.ts: Firebase initializationlib/firebase/auth-service.ts: Authentication methodslib/firebase/firestore-service.ts: Data persistence
app/api/analyze/route.ts: Main analysis endpoint- Validates request
- Runs safety check
- Performs AI analysis if safe
- Returns structured response
- Framework: Next.js 14 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- AI: OpenAI GPT-4
- Authentication: Firebase Auth
- Database: Firebase Firestore
- State Management: Zustand
- Charts: Recharts
- Animations: Framer Motion
- Icons: Lucide React
- API Key Protection: OpenAI key stored server-side only
- Input Validation: All user inputs validated
- Error Handling: Graceful error messages without exposing internals
- Rate Limiting: Consider implementing rate limiting in production
- HTTPS Only: Always use HTTPS in production
- Firebase Rules: Configure Firestore security rules
Supported languages:
- English (en)
- Hindi (hi)
- Marathi (mr)
Add more languages in lib/i18n/translations.ts
- Mobile-first approach
- Breakpoints: sm (640px), md (768px), lg (1024px), xl (1280px)
- Touch-friendly interface
- Optimized for all screen sizes
- Push code to GitHub
- Import project in Vercel
- Add environment variables
- Deploy
Build the production bundle:
npm run build
npm start- Not Medical Advice: This tool is for informational purposes only
- Emergency Situations: Always call emergency services for serious symptoms
- Professional Care: Always consult healthcare professionals for diagnosis
- AI Limitations: AI can make mistakes and miss rare conditions
- Data Accuracy: Results depend on information quality provided
This project is for educational and demonstration purposes.
Contributions welcome! Please ensure:
- Code follows TypeScript best practices
- All features are tested
- Documentation is updated
- Security best practices are maintained
For issues or questions:
- Check the documentation
- Review test scenarios
- Verify environment variables
- Check browser console for errors
- Voice input for symptoms
- Image upload for visual symptoms
- Integration with telemedicine platforms
- Symptom tracking over time
- Family health profiles
- Medication interaction checker
- Health tips and preventive care
Built with ❤️ for better healthcare accessibility