An AI-powered web application that transforms complex medical reports into clear, understandable explanations. Built with Next.js, Supabase, and advanced AI models for OCR and medical text analysis.
- π Secure Authentication - Google OAuth integration via Supabase
- π€ AI-Powered OCR - Extract text from medical report images using Together AI
- π§ Medical Analysis - Advanced AI analysis using Google Gemini AI
- π Structured Results - Clear test result categorization (Normal, Abnormal, Concerning)
- π± Responsive Design - Beautiful, modern UI that works on all devices
- π Data Security - Row-level security and encrypted data storage
- π Health Scoring - Automatic health score calculation based on test results
- π Report History - Complete analysis history with search and filtering
- β‘ Real-time Processing - Live status updates during analysis
- π₯ Medical Compliance - Comprehensive disclaimers and privacy protection
Visit MedReports AI (Replace with your actual deployment URL)
Frontend:
- Next.js 15.3.3 with App Router
- React 19 with TypeScript
- Tailwind CSS 4 for styling
- Quicksand font from Google Fonts
Backend & Services:
- Supabase for authentication and database
- Google Gemini AI (gemma-3-27b-it) for medical analysis
- Together AI (Llama-Vision-Free) for OCR processing
- PostgreSQL database with Row Level Security
Key Libraries:
@supabase/supabase-js- Database and auth client@google/generative-ai- Google AI integration
The application uses a comprehensive PostgreSQL schema with:
- medical_reports - Main report metadata and analysis status
- test_results - Individual test results with explanations
- processing_logs - Detailed processing history and error tracking
- user_preferences - User settings and preferences
- Custom types - ENUM types for status validation
- RLS policies - Row-level security for data isolation
- Triggers - Automatic timestamp and count updates
- Together AI API - OCR text extraction from images
- Google Gemini AI - Medical report analysis and interpretation
- Supabase Auth - Google OAuth authentication flow
- Supabase Database - Data persistence and real-time updates
- Node.js 18+ and npm
- Supabase account
- Google Cloud Console account (for OAuth and Gemini AI)
- Together AI account
git clone https://github.com/PrajyotMane01/Med-Report.git
cd medical-report
npm installCreate a .env.local file in the root directory:
# Supabase Configuration
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
# AI Service API Keys
NEXT_PUBLIC_GEMINI_API_KEY=your_gemini_api_key
NEXT_PUBLIC_TOGETHER_API_KEY=your_together_api_key
# App Configuration
NEXT_PUBLIC_APP_URL=http://localhost:3000- Create a new project at supabase.com
- Navigate to Authentication > Providers
- Enable Google provider
- Configure OAuth settings:
- Site URL:
http://localhost:3000(development) /https://yourdomain.com(production) - Redirect URLs:
http://localhost:3000/auth/callback,https://yourdomain.com/auth/callback
- Site URL:
- Go to SQL Editor in your Supabase dashboard
- Create a new query and copy the entire contents of
database-schema.sql - Execute the script to create all tables, functions, and policies
The schema includes:
- Complete table structure with relationships
- Row Level Security (RLS) policies
- Custom functions for data operations
- Triggers for automatic updates
- Indexes for optimal performance
- Visit Google Cloud Console
- Create/select a project and enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URIs:
https://your-supabase-project.supabase.co/auth/v1/callback
- Copy Client ID and Secret to Supabase Auth settings
- Go to Google AI Studio
- Create an API key for Gemini AI
- Add the key to your
.env.localasNEXT_PUBLIC_GEMINI_API_KEY
- Sign up at Together AI
- Generate an API key
- Add the key to your
.env.localasNEXT_PUBLIC_TOGETHER_API_KEY
npm run devOpen http://localhost:3000 in your browser.
The application uses a comprehensive PostgreSQL schema. Refer to DATABASE_SETUP.md for detailed setup instructions including:
- Complete table structures and relationships
- Row Level Security (RLS) configuration
- Custom functions and triggers
- Performance optimization indexes
- Sample queries and usage examples
-
Connect Repository
# Using Vercel CLI npm install -g vercel vercel -
Environment Variables Add all environment variables in Vercel dashboard:
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEYNEXT_PUBLIC_GEMINI_API_KEYNEXT_PUBLIC_TOGETHER_API_KEYNEXT_PUBLIC_APP_URL(set to your production domain, e.g.,https://yourdomain.vercel.app)
-
Update Supabase Settings
- Add production URLs to Supabase Auth configuration
- Update redirect URLs to include your domain:
- Site URL:
https://yourdomain.vercel.app - Redirect URLs:
https://yourdomain.vercel.app/auth/callback
- Site URL:
- Make sure to remove or update any localhost URLs for production
- Netlify: Configure build settings and environment variables
- Railway: Connect GitHub and set environment variables
- DigitalOcean App Platform: Use the provided app spec
- Docker: Build container using the provided Dockerfile
The application uses a custom Tailwind CSS configuration with:
- Custom color palette - Matt green theme with CSS variables
- Custom animations - Fade-in and slide-up effects
- Glass morphism effects - Backdrop blur and transparency
- Responsive design - Mobile-first approach
Currently configured models:
- OCR:
meta-llama/Llama-Vision-Free(Together AI) - Analysis:
gemma-3-27b-it(Google Gemini)
Models can be changed in app/analyze/page.tsx by modifying the API calls.
- Sign In - Use Google account to authenticate
- Upload Report - Drag and drop or browse for medical report images
- Processing - Real-time status updates during analysis
- Results - View structured test results with explanations
- History - Access previous analyses in your dashboard
- AuthProvider - Authentication state management
- FileUpload - Drag-and-drop file handling with preview
- TestResults - Structured display of analysis results
- ProcessingStatus - Real-time processing updates
- DatabaseService - Complete data layer abstraction
GET /auth/callback- OAuth callback handler- Custom Supabase functions for data operations
- Real-time subscriptions for live updates
import { db } from '@/lib/database';
// Create a new medical report
const { data: report, error } = await db.createMedicalReport({
user_id: user.id,
file_name: 'blood_test.pdf',
file_size: 1024000,
file_type: 'application/pdf',
original_text: 'Raw OCR text...'
});
// Save analysis results
const { error } = await db.saveCompleteAnalysis({
reportId: report.id,
patientInfo: 'Patient summary...',
testResults: [...]
});# Run type checking
npm run build
# Run linting
npm run lint
# Development with type checking
npm run dev- Authentication flow (sign in/out)
- File upload with different formats
- OCR text extraction accuracy
- AI analysis quality
- Database operations
- Error handling
- Mobile responsiveness
- Cross-browser compatibility
We welcome contributions! Please follow these guidelines:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Make your changes
- Test thoroughly
- Commit with conventional commits
git commit -m "feat: add amazing feature" - Push to your fork
- Open a Pull Request
- Use TypeScript for all new code
- Follow the existing component structure
- Use Tailwind CSS for styling
- Write meaningful commit messages
- Add JSDoc comments for functions
- Ensure proper error handling
- Additional AI model integrations
- Enhanced data visualization
- Mobile app development
- Multi-language support
- Advanced analytics dashboard
- Export functionality (PDF, CSV)
- Batch processing capabilities
- Integration with health platforms
- Row Level Security (RLS) - Database-level access control
- Environment variables - Secure API key management
- HTTPS only - Encrypted data transmission
- OAuth authentication - No password storage
- Input validation - Comprehensive data sanitization
- Data encryption - All sensitive data encrypted at rest
- User consent - Clear terms and privacy policies
- Data retention - Configurable retention periods
- GDPR compliance - User data export and deletion
- Medical disclaimers - Clear AI limitation warnings
IMPORTANT: This application is for educational and informational purposes only. All AI-generated content may contain errors or inaccuracies and should never be used as a substitute for professional medical advice, diagnosis, or treatment. Always consult with qualified healthcare professionals for medical decisions.
Authentication Problems
- Verify Google OAuth credentials in Supabase
- Check redirect URLs configuration
- Ensure environment variables are set correctly
- Production Redirect Issues: Make sure
NEXT_PUBLIC_APP_URLis set to your production domain in environment variables
Localhost Redirect in Production If you're being redirected to localhost after signing in on production:
- Set
NEXT_PUBLIC_APP_URLto your production URL (e.g.,https://yourdomain.vercel.app) - Update Supabase Auth settings to include your production domain
- Remove localhost URLs from Supabase redirect configuration
- Redeploy your application after setting the environment variable
Database Errors
- Verify Supabase connection
- Check RLS policies are properly configured
- Ensure database schema is up to date
AI Processing Failures
- Verify API keys for Together AI and Gemini
- Check API rate limits and quotas
- Ensure image format is supported
Deployment Issues
- Verify all environment variables in production
- Check build logs for missing dependencies
- Ensure Supabase URLs include production domain
This project is licensed under the MIT License - see the LICENSE file for details.
- Supabase - Backend-as-a-Service platform
- Google AI - Gemini AI model for analysis
- Together AI - OCR processing capabilities
- Vercel - Deployment and hosting platform
- Tailwind CSS - Utility-first CSS framework
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@medreports.ai
Made with β€οΈ for the healthcare community