Skip to content

About

AI-powered prescription management system with encrypted QR codes, Gemini AI diagnostics, multi-language report summarization, and skin disease detection. Built for doctors, pharmacists, patients & admins. Next.js · TypeScript · MongoDB · Tailwind CSS

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

🏥 MediScan AI

MediScan AI Logo

AI-Powered Medical Image Analysis & Healthcare Management Platform

Next.js TypeScript MongoDB Google AI

Features • Installation • Usage • Documentation • Contributing


📖 Overview

MediScan AI is a comprehensive healthcare management platform that leverages artificial intelligence to analyze medical images, generate prescriptions, manage medications, and facilitate healthcare workflows. Built with Next.js 15, it provides separate dashboards for administrators, doctors, patients, and pharmacists.

🎯 Key Capabilities

  • 🔍 AI-Powered Medical Image Analysis - OCR and intelligent analysis of medical reports
  • 💊 Smart Prescription Management - Create, scan, and manage digital prescriptions with QR codes
  • 🤖 AI Medical Assistant - Chat with documents and get medication suggestions
  • 👥 Multi-Role System - Separate dashboards for Admin, Doctor, Patient, and Pharmacist
  • 🔐 Secure Authentication - JWT-based auth with OAuth support (Google, GitHub, Apple)
  • 📊 Analytics Dashboard - Real-time insights and healthcare metrics

✨ Features

🏥 For Healthcare Providers

  • Digital Prescription Creation with QR code generation
  • Patient Management system with comprehensive records
  • AI-Powered Medication Suggestions based on symptoms
  • Medical Document Analysis using Google Gemini AI
  • Prescription Tracking with scan limits and validation
  • Team Collaboration tools

💊 For Pharmacists

  • QR Code Scanner for prescription verification
  • Medicine Inventory Management with stock tracking
  • Prescription Validation with real-time status updates
  • AI Assistant for drug information and interactions
  • Order Management system

👤 For Patients

  • Prescription Access via secure QR codes
  • Medical History tracking
  • Healthcare Provider directory
  • Appointment Management (coming soon)

🛡️ For Administrators

  • User Management across all roles
  • System Analytics and monitoring
  • Drug Database management
  • Team Administration
  • Activity Logs and audit trails

🛡️ Screenshot

Homepage

Screenshot 2025-12-01 044622 Screenshot 2025-12-01 052355 Screenshot 2025-12-01 052248 Screenshot 2025-12-01 052426

Loginpage

Screenshot 2025-12-01 044214

Signup

signup

Doctor dashboard

doctor dashboard1

Create a new Prescription

doctor dashboard2

Ai

AI

Pharmacist dashboard

shop1

Phescription scannner

Scan

Qr code example

MediScan_Ai-Prescription-1782572176606

404

404

🚀 Tech Stack

Frontend

  • Framework: Next.js 15 (App Router)
  • Language: TypeScript 5.9
  • Styling: Tailwind CSS 4.1
  • UI Components: Radix UI, Shadcn UI
  • State Management: React Hooks, SWR
  • Forms: React Hook Form + Zod validation
  • Animations: Framer Motion

Backend

  • Runtime: Node.js
  • API: Next.js API Routes
  • Database: MongoDB 7.0 + Mongoose ODM
  • Authentication: JWT (Jose), OAuth 2.0
  • File Upload: Multer
  • QR Codes: QRCode.js

AI & ML

  • AI Platform: Google Genkit
  • Models: Google Gemini (gemini-2.0-flash-exp)
  • OCR: Google Cloud Vision API
  • Vector DB: In-memory (development)

DevOps & Tools

  • Package Manager: npm
  • Linting: ESLint
  • Build Tool: Turbopack (Next.js)
  • Environment: dotenv

📋 Prerequisites

Before you begin, ensure you have:

  • Node.js 18.17 or later
  • npm 9.0 or later
  • MongoDB database (local or cloud)
  • Google Cloud Account with:
    • Gemini API access
    • Cloud Vision API enabled
  • OAuth Credentials (optional, for social login):
    • Google OAuth 2.0
    • GitHub OAuth App
    • Apple Sign In

🛠️ Installation

1. Clone the Repository

git clone https://github.com/Jaykumar122/MediScanAI.git
cd MediScanAi

2. Install Dependencies

npm install

3. Set Up Environment Variables

Create a .env file in the root directory:

# ─── Database ─────────────────────────────────────────────────
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/securerx?retryWrites=true&w=majority

# ─── JWT Authentication ───────────────────────────────────────
JWT_SECRET=your-secret-key-minimum-32-characters-long-for-security

# ─── Google AI (Gemini) ───────────────────────────────────────
GOOGLE_GENAI_API_KEY=your-google-ai-api-key

# ─── Google Cloud Vision (OCR) ────────────────────────────────
GOOGLE_APPLICATION_CREDENTIALS=path/to/service-account-key.json
GOOGLE_CLOUD_PROJECT_ID=your-project-id

# ─── OAuth Providers (Optional) ───────────────────────────────
# Google OAuth
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret

# GitHub OAuth
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret

# Apple Sign In
APPLE_CLIENT_ID=your-apple-client-id
APPLE_TEAM_ID=your-apple-team-id
APPLE_KEY_ID=your-apple-key-id
APPLE_PRIVATE_KEY=your-apple-private-key

# ─── Application ──────────────────────────────────────────────
NEXT_PUBLIC_APP_URL=http://localhost:3000
NODE_ENV=development

4. Set Up Google Cloud Services

Google Gemini API

  1. Go to Google AI Studio
  2. Create an API key
  3. Add to .env as GOOGLE_GENAI_API_KEY

Google Cloud Vision API

  1. Create a project in Google Cloud Console
  2. Enable Cloud Vision API
  3. Create a service account and download JSON key
  4. Set path in .env as GOOGLE_APPLICATION_CREDENTIALS

5. Initialize Database

The database will be automatically initialized on first run. To manually create an admin user:

npm run admin:create admin@mediscan.com YourSecurePassword123

Verify admin creation:

npm run admin:list

🚀 Usage

Development Mode

Start the development server:

npm run dev

The application will be available at: http://localhost:3000

Production Build

Build for production:

npm run build

Start production server:

npm start

🗺️ Application Routes

Authentication

  • /login - User login (Doctor, Patient, Pharmacist)
  • /signup - User registration
  • /admin/login - Admin login portal
  • /role-selection - OAuth role selection

Dashboards

Admin Dashboard (/dashboard/admin)

  • /dashboard/admin - Overview & analytics
  • /dashboard/admin/doctors - Doctor management
  • /dashboard/admin/team - Team administration
  • /dashboard/admin/drugs - Medicine database
  • /dashboard/admin/users - User management
  • /dashboard/admin/pharmacy - Pharmacy management

Doctor Dashboard (/dashboard/doctor)

  • /dashboard/doctor - Doctor overview
  • /dashboard/doctor/prescriptions - Create prescriptions
  • /dashboard/doctor/doctors - Doctor directory
  • /dashboard/doctor/drugs - Medicine lookup
  • /dashboard/doctor/pharmacy - Pharmacy network

Patient Dashboard (/dashboard/patient)

  • /dashboard/patient - Patient overview
  • /dashboard/patient/prescriptions - View prescriptions
  • /dashboard/patient/scan - Scan QR codes

Pharmacist Dashboard (/dashboard/pharmacist)

  • /dashboard/pharmacist - Pharmacy overview
  • /dashboard/pharmacist/scan - Scan prescriptions
  • /dashboard/pharmacist/ai - AI assistant

🔌 API Endpoints

Authentication

POST   /api/login              # User login
POST   /api/signup             # User registration
POST   /api/admin/login        # Admin login
POST   /api/logout             # Logout
GET    /api/auth/[provider]/callback  # OAuth callback

Admin APIs

GET    /api/dashboard/admin             # Dashboard data
GET    /api/dashboard/admin/doctors     # List doctors
GET    /api/dashboard/admin/team        # List team members
GET    /api/dashboard/admin/drugs       # List medicines
POST   /api/dashboard/admin/drugs       # Add medicine
GET    /api/dashboard/admin/users       # List users
PATCH  /api/dashboard/admin/users       # Update user status
GET    /api/dashboard/admin/pharmacy    # List pharmacists

Doctor APIs

GET    /api/dashboard/doctor            # Doctor dashboard
GET    /api/dashboard/doctor/resources  # Resources (doctors, drugs, pharmacy)

📁 Project Structure

mediscan-ai/
├── src/
│   ├── app/                    # Next.js app directory
│   │   ├── (auth)/            # Authentication pages
│   │   │   ├── login/
│   │   │   ├── signup/
│   │   │   └── admin/login/
│   │   ├── dashboard/         # Dashboard pages
│   │   │   ├── admin/
│   │   │   ├── doctor/
│   │   │   ├── patient/
│   │   │   └── pharmacist/
│   │   ├── api/               # API routes
│   │   │   ├── (auth)/
│   │   │   └── dashboard/
│   │   ├── actions.ts         # Server actions
│   │   ├── layout.tsx         # Root layout
│   │   └── page.tsx           # Landing page
│   ├── components/            # React components
│   │   ├── ui/               # UI components
│   │   ├── app-sidebar.tsx
│   │   ├── site-header.tsx
│   │   └── ...
│   ├── lib/                   # Utility libraries
│   │   ├── actions.ts        # Server actions
│   │   ├── crypto.ts         # JWT utilities
│   │   └── definitions.ts    # Zod schemas
│   ├── models/               # MongoDB models
│   │   └── usermodels.ts
│   ├── ai/                   # AI workflows
│   │   ├── genkit.ts         # Genkit configuration
│   │   └── flows/            # AI flows
│   │       ├── medication-suggestion.ts
│   │       ├── ocr-and-summarize.ts
│   │       └── ...
│   ├── dbConfig/             # Database configuration
│   ├── hooks/                # Custom React hooks
│   ├── types/                # TypeScript types
│   └── scripts/              # Utility scripts
├── public/                   # Static assets
├── .env                      # Environment variables
├── next.config.ts           # Next.js configuration
├── tailwind.config.ts       # Tailwind CSS config
├── tsconfig.json            # TypeScript config
└── package.json             # Dependencies

🔐 Authentication Flow

User Authentication

  1. User enters credentials on login page
  2. Server validates against MongoDB
  3. JWT token generated and returned
  4. Token stored in localStorage and cookies
  5. Protected routes verify token on each request

OAuth Flow

  1. User clicks social login button
  2. Redirected to OAuth provider
  3. User authorizes application
  4. Callback with authorization code
  5. If new user: role selection screen
  6. JWT token generated
  7. Redirected to appropriate dashboard

Admin Authentication

  • Separate login portal at /admin/login
  • Only users with role: "admin" can access
  • Enhanced security with audit logging

🤖 AI Features

1. Medical Image OCR & Analysis

// Extract text and analyze medical reports
const result = await ocrAndSummarize({
  imageUrl: uploadedImageUrl
});

2. Medication Suggestions

// Get AI-powered medication suggestions
const result = await getMedicationSuggestions({
  symptoms: "fever, headache, body aches"
});

3. Document Summarization

// Summarize medical documents
const result = await summarizeMedicalDocument({
  documentText: extractedText
});

4. Chat with Documents

// Ask questions about medical documents
const result = await chatWithDocument({
  question: "What is the diagnosis?",
  context: documentContent
});

👥 User Roles & Permissions

Feature Admin Doctor Patient Pharmacist
Create Prescriptions ✅ ✅ ❌ ❌
Scan Prescriptions ✅ ✅ ✅ ✅
Manage Users ✅ ❌ ❌ ❌
Manage Drugs ✅ ❌ ❌ ❌
View Analytics ✅ ✅ ❌ ✅
Access AI Features ✅ ✅ ❌ ✅

🧪 Testing

Run Tests (Coming Soon)

npm test

Run Linter

npm run lint

📚 Documentation


🤝 Contributing

We welcome contributions! 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 some amazing feature'
  4. Push to the branch
    git push origin feature/amazing-feature
  5. Open a Pull Request

Development Guidelines

  • Follow TypeScript best practices
  • Use ESLint for code formatting
  • Write descriptive commit messages
  • Add comments for complex logic
  • Update documentation as needed

🐛 Known Issues & Roadmap

Known Issues

  • OpenTelemetry Jaeger exporter warning (non-breaking)
  • Some OAuth providers may require additional configuration

Roadmap

  • Real-time notifications
  • Appointment scheduling system
  • Video consultation integration
  • Mobile app (React Native)
  • Multi-language support
  • Advanced analytics dashboard
  • Integration with EHR systems
  • Telemedicine features

📄 License

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


👨‍💻 Author

Your Name


🙏 Acknowledgments


Made with ❤️ for Healthcare

⭐ Star this repo if you find it helpful!

Report Bug • Request Feature

About

AI-powered prescription management system with encrypted QR codes, Gemini AI diagnostics, multi-language report summarization, and skin disease detection. Built for doctors, pharmacists, patients & admins. Next.js · TypeScript · MongoDB · Tailwind CSS

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages