Skip to content

DevaanshPathak/MedReady-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ MedReady AI

AI-Powered Healthcare Workforce Readiness Platform for Rural India

A comprehensive learning and deployment platform designed to train, certify, and deploy healthcare workers in underserved rural areas of India. Built with Next.js 15, Supabase, and Claude AI.

Next.js TypeScript Supabase Anthropic Claude


🌟 Features

πŸŽ“ AI-Powered Learning

  • Adaptive Learning Modules: 8+ medical training modules with AI-generated content
  • Smart Assessments: Practice and certification quizzes with instant feedback
  • Spaced Repetition: Intelligent review system to reinforce weak areas
  • Study Streaks & Gamification: Daily challenges, achievements, and leaderboards
  • Bookmarking: Save important questions and concepts for later review

πŸ’¬ AI Medical Assistant

  • Real-time Chat: Claude Sonnet 4.5 with medical expertise
  • Extended Thinking: See AI's reasoning process for complex questions
  • Live Web Search: Real-time searches of WHO, CDC, ICMR, NIH, and trusted medical sources
  • Context-Aware: Specialized prompts for emergency, maternal, pediatric care
  • Multi-turn Conversations: Maintains context across chat sessions

πŸš‘ Emergency Guidance

  • Instant AI Support: Step-by-step protocols for medical emergencies
  • Evidence-Based: Recommendations backed by WHO/CDC guidelines
  • Offline-Ready: Critical protocols available without internet

πŸ“œ Digital Certifications

  • Blockchain-Verified: Tamper-proof certificates on Ethereum
  • Instant Verification: QR codes for credential checking
  • Career Advancement: Track progress toward advanced certifications

πŸ—ΊοΈ Rural Deployment Matching

  • AI Recommendations: Match healthcare workers to rural opportunities
  • State-wide Coverage: Deployments across all Indian states
  • Transparent Applications: Track application status in real-time

πŸ“Š Social Learning

  • Peer Connections: Connect with fellow healthcare workers
  • Progress Sharing: Share achievements with friends or publicly
  • Collaborative Learning: Learn from the community's experiences

πŸš€ Quick Start

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/DevaanshPathak/MedReady-AI.git
    cd MedReady-AI
  2. Install dependencies

    pnpm install
  3. Set up environment variables

    Create a .env.local file in the root directory:

    # Supabase (public - exposed to client)
    NEXT_PUBLIC_SUPABASE_URL=https://YOUR_PROJECT_ID.supabase.co
    NEXT_PUBLIC_SUPABASE_ANON_KEY=your_anon_key_here
    
    # AI Providers (server-only)
    ANTHROPIC_API_KEY=sk-ant-your-key-here
    EXA_API_KEY=your_exa_key_here
    
    # Optional: Redis Cache (Upstash)
    UPSTASH_REDIS_REST_URL=https://your-redis.upstash.io
    UPSTASH_REDIS_REST_TOKEN=your_token_here
    
    # Optional: AI Gateway (Vercel)
    AI_GATEWAY_API_KEY=your_gateway_key
  4. Set up Supabase database

    Run migrations in order via Supabase SQL Editor:

    # Required migrations
    scripts/001_create_schema.sql          # Core tables
    scripts/003_create_profile_trigger.sql # Auto profile creation
    
    # Optional feature migrations
    scripts/005_create_chat_tables.sql                # Enhanced chat
    scripts/008_add_ai_tables.sql                     # AI caching
    scripts/010_add_learning_features.sql             # Spaced repetition
    scripts/011_add_streaks_and_gamification.sql      # Gamification
  5. Seed demo data (optional)

    # Windows PowerShell
    .\scripts\seed_database.ps1
    
    # Or with Node.js
    node scripts/seed_demo_data.js
  6. Run development server

    pnpm dev
  7. Open in browser

    http://localhost:3000
    

πŸ“ Project Structure

MedReady-AI/
β”œβ”€β”€ app/                          # Next.js 15 App Router
β”‚   β”œβ”€β”€ api/                      # API routes
β”‚   β”‚   β”œβ”€β”€ chat/                 # AI chat endpoint
β”‚   β”‚   β”œβ”€β”€ generate-certificate/ # Blockchain certificates
β”‚   β”‚   β”œβ”€β”€ recommendations/      # Deployment matching
β”‚   β”‚   └── ...                   # Other endpoints
β”‚   β”œβ”€β”€ dashboard/                # Main dashboard
β”‚   β”œβ”€β”€ learn/                    # Learning modules
β”‚   β”œβ”€β”€ chat/                     # AI assistant
β”‚   β”œβ”€β”€ emergency/                # Emergency protocols
β”‚   β”œβ”€β”€ certifications/           # Certificates
β”‚   └── deployments/              # Rural deployments
β”‚
β”œβ”€β”€ components/                   # React components
β”‚   β”œβ”€β”€ chat-interface.tsx        # AI chat UI
β”‚   β”œβ”€β”€ assessment-quiz-enhanced.tsx # Spaced repetition
β”‚   β”œβ”€β”€ progress-social.tsx       # Social learning
β”‚   └── ui/                       # shadcn/ui components
β”‚
β”œβ”€β”€ lib/                          # Core utilities
β”‚   β”œβ”€β”€ ai-provider.ts            # Claude AI setup
β”‚   β”œβ”€β”€ web-search-tool.ts        # Medical web search
β”‚   β”œβ”€β”€ types.ts                  # TypeScript definitions
β”‚   β”œβ”€β”€ redis.ts                  # Caching layer
β”‚   └── supabase/                 # Auth & database
β”‚
β”œβ”€β”€ prompts/                      # AI system prompts
β”‚   β”œβ”€β”€ chat/                     # Category-specific prompts
β”‚   └── emergency-guidance.ts     # Emergency protocols
β”‚
β”œβ”€β”€ scripts/                      # Database setup
β”‚   β”œβ”€β”€ 001_create_schema.sql     # Core tables
β”‚   └── ...                       # Migration files
β”‚
└── __tests__/                    # Comprehensive test suite
    β”œβ”€β”€ api/                      # API tests
    β”œβ”€β”€ components/               # Component tests
    β”œβ”€β”€ lib/                      # Utility tests
    └── integration/              # E2E tests

πŸ§ͺ Testing

Run Tests

# Run all tests
pnpm test

# Watch mode (for development)
pnpm test:watch

# Coverage report
pnpm test:coverage

# Test specific category
pnpm test:components    # UI components
pnpm test:lib           # Library functions

Test Coverage

  • API Routes: Chat streaming, certificates, recommendations, gamification
  • Components: Quiz enhanced, social progress, buttons, cards
  • Database: RLS policies, triggers, PostgreSQL functions
  • Integration: E2E workflows, learning features, authentication

πŸ—οΈ Tech Stack

Frontend

  • Framework: Next.js 15 (App Router, Server Components)
  • UI Library: React 19
  • Styling: Tailwind CSS + shadcn/ui components
  • State Management: React hooks + Supabase realtime
  • Markdown: react-markdown + remark-gfm
  • Charts: Recharts

Backend

  • Database: Supabase (PostgreSQL with Row-Level Security)
  • Authentication: Supabase Auth (email/password, OAuth)
  • API: Next.js API routes (RESTful)
  • Caching: Upstash Redis (optional)

AI & ML

  • LLM: Anthropic Claude Sonnet 4.5
  • Framework: Vercel AI SDK (streaming, tool calling)
  • Web Search: Exa.ai (medical domain-specific)
  • Embeddings: Not used (live search instead)

Blockchain

  • Network: Ethereum (for certificate verification)
  • Libraries: ethers.js (certificate hashing)

DevOps

  • Package Manager: pnpm
  • Testing: Jest + React Testing Library
  • Type Checking: TypeScript (strict mode)
  • Linting: ESLint + Next.js config

πŸ” Security & Privacy

Row-Level Security (RLS)

  • All database tables enforce RLS policies
  • Users can only access their own data (auth.uid() = user_id)
  • Public data (modules, assessments) is read-only
  • Shared progress respects privacy settings (public/friends/specific)

API Authentication

  • Middleware protects all /dashboard, /learn, /chat routes
  • Server components use @/lib/supabase/server for auth
  • Client components use @/lib/supabase/client with automatic token refresh

Data Protection

  • Sensitive API keys stored in environment variables (server-only)
  • No API keys exposed to client-side code
  • Supabase handles password hashing and token management

🌐 Deployment

Vercel (Recommended)

  1. Push to GitHub

    git push origin main
  2. Import to Vercel

    • Go to vercel.com/new
    • Import your repository
    • Vercel auto-detects Next.js
  3. Add environment variables

    • Copy all variables from .env.local
    • Add to Vercel project settings
    • Mark sensitive keys as "Sensitive" (hidden in logs)
  4. Deploy

    • Vercel automatically deploys on push
    • Production URL: https://your-project.vercel.app

Other Platforms

  • Railway: Supports Next.js + PostgreSQL
  • Netlify: Use next export for static export
  • AWS Amplify: Full-stack deployment
  • Self-hosted: Docker + nginx

πŸ“š Key Concepts

AI Chat Features

Extended Thinking: Enable to see Claude's step-by-step reasoning

// In chat header, toggle "Thinking" mode
// Purple blocks show internal reasoning process

Live Web Search: Automatically searches trusted medical sources

// Blue blocks show search results from WHO, CDC, ICMR, etc.
// Click to expand and see sources

Stop Generation: Cancel long responses mid-stream

// Red "Stop" button appears during streaming
// Preserves partial response

Spaced Repetition Algorithm

Uses SuperMemo SM-2 for optimal review scheduling:

  • Quality 0-2: Review again immediately
  • Quality 3-5: Increase interval (1d β†’ 6d β†’ 14d β†’ 30d...)
  • Ease Factor: Adjusts based on recall difficulty
  • Implementation: PostgreSQL functions for efficiency

Gamification System

  • Daily Activities: Track daily learning time, quizzes completed
  • Study Streaks: Consecutive days of activity
  • Achievements: Unlock badges for milestones
  • Leaderboards: (Future) Compare with peers

πŸ› οΈ Development Tips

Adding a New Feature

  1. Create migration (if database changes needed)

    -- scripts/012_new_feature.sql
    CREATE TABLE new_table (
      id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
      user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
      created_at TIMESTAMPTZ DEFAULT NOW()
    );
    
    ALTER TABLE new_table ENABLE ROW LEVEL SECURITY;
    
    CREATE POLICY "Users can access own data"
      ON new_table FOR ALL
      USING (auth.uid() = user_id);
  2. Add TypeScript types in lib/types.ts

    export interface NewFeature {
      id: string
      user_id: string
      created_at: string
    }
  3. Create API route in app/api/new-feature/route.ts

    import { createClient } from "@/lib/supabase/server"
    
    export async function GET(request: Request) {
      const supabase = await createClient()
      const { data: { user } } = await supabase.auth.getUser()
      
      if (!user) {
        return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
      }
      
      const { data } = await supabase.from("new_table").select("*")
      return NextResponse.json(data)
    }
  4. Write tests in __tests__/api/new-feature.test.ts

Debugging Tips

  • Check Supabase logs: Dashboard β†’ Logs β†’ API/Database
  • Use React DevTools: Inspect component state
  • Enable verbose logging: Add console.log in API routes
  • Test RLS policies: Use Supabase SQL Editor with different users

🀝 Contributing

We welcome contributions! Here's how:

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

Contribution Guidelines

  • Follow existing code style (TypeScript strict mode)
  • Write tests for new features
  • Update documentation (this README or AGENTS.md)
  • Ensure all tests pass (pnpm test)
  • Keep commits atomic and descriptive

πŸ“„ License

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


πŸ‘₯ Team

  • Devaansh Pathak - Creator & Lead Developer

πŸ™ Acknowledgments

  • Anthropic - Claude AI models
  • Supabase - Backend infrastructure
  • Vercel - AI SDK and hosting
  • shadcn/ui - Beautiful UI components
  • WHO, CDC, ICMR - Medical guidelines and resources

πŸ“ž Support


πŸ—ΊοΈ Roadmap

Q4 2025

  • Mobile app (React Native)
  • Offline mode for emergency protocols
  • Voice-based AI assistant (Hindi + regional languages)
  • Video learning modules

Q1 2026

  • Telemedicine consultations
  • Community forums
  • Advanced analytics dashboard
  • Integration with government health systems

Q2 2026

  • Multi-language support (10+ Indian languages)
  • AR/VR training simulations
  • Wearable device integration
  • National certification program

πŸ“Š Project Status

  • βœ… Core Platform: Complete
  • βœ… AI Chat: Complete with extended thinking & web search
  • βœ… Learning System: Complete with spaced repetition
  • βœ… Gamification: Complete with streaks & achievements
  • βœ… Certifications: Complete with blockchain verification
  • βœ… Deployments: Complete with AI recommendations
  • 🚧 Mobile App: In planning
  • 🚧 Offline Mode: In planning

Built with ❀️ for rural healthcare workers in India

Making healthcare accessible, one trained worker at a time.

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •