Skip to content

Repository files navigation

CareMeet – AI-Assisted Telemedicine Platform

Overview

CareMeet is a full-stack telemedicine platform that connects patients with verified doctors through video consultations, supported by an AI-powered symptom analysis system.

The platform handles the complete consultation lifecycle β€” from helping users understand their symptoms using AI, to booking appointments, managing payments through a credit system, and conducting video consultations.

This project focuses on building a real-world healthcare workflow with reliable backend handling. Instead of being just a CRUD application, it addresses practical challenges such as scheduling conflicts, safe payment handling, role-based access, and integration with external systems.


System Flow

User β†’ AI Analysis β†’ Doctor Selection β†’ Booking β†’ Payment β†’ Video β†’ Payout

Step-by-step Flow

  1. Symptom Input

    • User enters symptoms through the AI assistant.
  2. AI Processing

    • Backend sends structured prompt to Gemini API.

    • Response is parsed to extract:

      • urgency level
      • recommended medical specialties
  3. Doctor Selection

    • User browses verified doctors filtered by specialty.
    • Available slots are dynamically generated.
  4. Booking Validation

    • Backend checks:

      • user has sufficient credits
      • slot availability (overlap query)
      • minimum booking buffer (2 hours)
  5. Atomic Booking Execution

    • A database transaction is executed:

      • deduct credits from patient
      • add credits to doctor
      • create appointment record
    • If any step fails β†’ everything is rolled back

  6. Video Consultation

    • Secure Vonage session is generated
    • Doctor and patient join at scheduled time
  7. Payout Flow

    • Doctors accumulate credits
    • Admin processes payout requests safely with balance validation

Core Features

πŸ€– AI Symptom Analysis

  • Uses Google Gemini to analyze user symptoms
  • Returns structured output (urgency + specialty)
  • Includes fallback handling for API failures

πŸ“… Appointment Scheduling

  • Doctors define availability
  • System generates 30-minute slots dynamically
  • Prevents overlapping bookings using database checks
  • Enforces minimum 2-hour buffer before booking

πŸ’³ Credit-Based Payment System

  • Users purchase credits via subscription
  • Each consultation deducts fixed credits
  • Credits are tracked using a ledger-style transaction model
  • Doctor earnings are accumulated and later paid out

πŸŽ₯ Video Consultation Integration

  • Uses Vonage Video API (WebRTC)
  • Session IDs and tokens generated securely on server
  • Supports real-time video/audio communication

πŸ” Role-Based Access Control

  • Roles: PATIENT, DOCTOR, ADMIN
  • Doctors require verification before becoming active
  • Access control enforced in both server logic and UI

System Architecture

The application follows a modern full-stack architecture using Next.js:

  • Next.js Server Actions

    • Handle data mutations securely on the server
    • Reduce need for separate API endpoints
  • Prisma + PostgreSQL

    • Manages relational data (users, appointments, transactions)
    • Ensures type-safe database operations
  • Clerk Authentication

    • Handles user authentication and session management
    • Supports role-based workflows
  • External Integrations

    • Gemini API β†’ symptom analysis
    • Vonage API β†’ video sessions

Key Engineering Decisions

Atomic Transactions for Booking

Booking requires multiple updates (credits + appointment). These are executed inside a single database transaction to ensure:

  • no credit loss
  • no partial state in case of failure

Consistent Payout Handling

Payout processing validates and updates doctor balance inside a transaction, preventing:

  • duplicate payouts
  • inconsistent balances

Scheduling Conflict Prevention

Instead of relying on frontend checks, the system:

  • queries overlapping time slots in database
  • ensures no double booking under concurrent requests

Input Validation with Zod

All critical inputs (booking, availability, payouts) are validated before hitting the database to prevent invalid data.


Role-Based Access Enforcement

Authorization checks are implemented in:

  • server actions
  • layout-level logic

This ensures restricted access to sensitive operations.


Edge Cases & Reliability

  • Prevents double booking using backend overlap checks
  • Rolls back booking if any step fails
  • Enforces 2-hour buffer for realistic scheduling
  • Handles invalid inputs and malformed requests safely
  • Includes fallback handling for AI failures

Tech Stack

Frontend

  • Next.js 15 (App Router)
  • React 19
  • Tailwind CSS
  • Radix UI

Backend

  • Node.js
  • Next.js Server Actions

Database

  • PostgreSQL
  • Prisma ORM

Integrations

  • Clerk (Authentication)
  • Google Gemini (AI)
  • Vonage Video API (WebRTC)

Setup Instructions

git clone https://github.com/Shikhar1504/Doctors_Appointment_Platform.git
cd Doctor
npm install

Create .env.local:

DATABASE_URL=...

NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=...
CLERK_SECRET_KEY=...

GEMINI_API_KEY=...

NEXT_PUBLIC_VONAGE_APPLICATION_ID=...
VONAGE_PRIVATE_KEY=...
npx prisma generate
npx prisma db push
npm run dev

Important Routes

  • /api/ai-health β†’ processes symptom input and returns structured AI response
  • booking & payout logic handled via server actions

What This Project Demonstrates

  • Full-stack application development with real-world workflows
  • Backend correctness using transactions and validation
  • Integration of AI and real-time communication systems
  • Handling scheduling and payment logic reliably
  • Building role-based multi-user systems

Built by Shikhar

About

πŸ₯ CareMeet: Next.js 15 telemedicine platform with AI symptom analysis (Google Gemini), video consultations (Vonage), multi-role auth (Clerk), and HIPAA-compliant design. Features appointment booking, doctor verification, emergency detection, and automated payouts.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages