Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Medicare AI

Medicare AI is a role-based healthcare coordination platform that helps doctors and patients manage appointments, clinical sessions, medical reports, and care handoffs. The application adds an AI layer between doctor and patient: it records and summarizes consultations, analyzes uploaded reports, flags critical findings, and creates reusable patient context so patients do not have to repeat their medical history every time they meet a new doctor.

The frontend is built with Next.js App Router, Clerk authentication, Convex realtime backend functions, Google Gemini, and Supermemory.

Important: AI-generated summaries and report analysis are decision-support outputs. They should always be reviewed by qualified medical professionals before being used for clinical decisions.

Screenshots

Landing Page

Medicare AI landing page

Doctor Dashboard

Medicare AI doctor dashboard

Session Summary

Medicare AI session summary

Key Features

  • Role-based authentication for doctors and patients using Clerk.
  • Guided onboarding that creates a doctor or patient profile in Convex.
  • Doctor portal with dashboard, availability management, appointments, sessions, reports, shared context inbox, and settings.
  • Patient portal with dashboard, appointment booking, doctor search, report uploads, session history, context sharing, and settings.
  • Weekly doctor availability management so patients can book available slots.
  • Appointment lifecycle support for scheduled, completed, and cancelled appointments.
  • Browser-based session recording with audio upload to Convex storage.
  • Gemini-powered medical session transcription and structured summary generation.
  • Patient medical report upload for PDFs and images.
  • Gemini-powered report analysis with plain-language summaries and critical flags.
  • Supermemory-backed patient memory for longitudinal clinical context.
  • AI-generated context sharing between doctors, with pending/viewed status tracking.
  • Light/dark theme support and responsive UI components.

Tech Stack

Area Tools
Framework Next.js 16, React 19, TypeScript
Styling Tailwind CSS 4, shadcn/Radix UI components
Authentication Clerk
Backend Convex queries, mutations, actions, and file storage
AI Google Gemini via @google/genai
Memory Supermemory
UI helpers Lucide React, Sonner, date-fns, next-themes

How It Works

1. Authentication and onboarding

Users sign in or sign up through Clerk. Protected routes are enforced in middleware.ts for /doctor, /patient, and /onboarding.

After authentication, users complete onboarding by choosing one of two roles:

  • Doctor: stores name, email, specialization, license number, bio, and weekly availability.
  • Patient: stores name, email, age, blood group, allergies, and emergency contact.

The onboarding flow writes profile data to Convex and calls /api/set-role to save the selected role in Clerk public metadata. The doctor and patient layouts then redirect users away from the wrong portal if their role does not match.

2. Doctor availability and booking

Doctors set weekly availability in the doctor portal. Patients can search doctors by name or specialization, open a doctor's booking page, select an available slot, add optional notes, and confirm an appointment.

Appointments are stored in Convex with:

  • patient and doctor profile IDs
  • Clerk IDs for both users
  • ISO date/time
  • status: scheduled, completed, or cancelled
  • optional patient notes

3. Clinical session recording and summary

When a doctor starts a scheduled appointment, the browser records audio using the MediaRecorder API. After recording, the audio blob is uploaded to Convex storage.

The Convex summarizeSession action then:

  1. Fetches the audio file from Convex storage.
  2. Sends it to Gemini for transcription.
  3. Fetches prior patient context from Supermemory.
  4. Sends the transcript and patient context to Gemini.
  5. Saves the transcript, AI summary, key decisions, and prescriptions to Convex.
  6. Marks the appointment as completed.
  7. Stores the session summary back into Supermemory for future visits.

4. Report upload and AI analysis

Patients upload medical reports as PDF or image files. Files are stored in Convex storage, then analyzed by the Convex analyzeReport action.

The report pipeline:

  1. Uploads the selected file to Convex storage.
  2. Creates a report record in Convex.
  3. Fetches patient context from Supermemory.
  4. Sends the file and prompt to Gemini for multimodal analysis.
  5. Saves a plain-language summary and critical flags to Convex.
  6. Stores the analysis and original report context in Supermemory.

Critical flags can be surfaced in dashboards and report views so doctors can quickly review high-priority findings.

5. Patient context sharing

Patients can share selected sessions and reports with another doctor. By default, available sessions and reports are pre-selected so the patient can review and remove anything they do not want to include.

The Convex generateSharedContext action:

  1. Reads the patient's longitudinal profile from Supermemory.
  2. Generates a consolidated handoff summary with Gemini.
  3. Creates a shared context record in Convex.
  4. Displays the shared context in the receiving doctor's inbox.

Doctors can open the shared context, review the AI summary, and mark it as viewed.

Project Structure

app/
  api/set-role/              Clerk role metadata API route
  doctor/                    Doctor portal routes
  patient/                   Patient portal routes
  onboarding/                Role and profile setup
  sign-in/, sign-up/         Clerk auth pages

components/
  doctor/                    Doctor-specific session and summary components
  patient/                   Patient-specific booking/report components
  shared/                    Shared app shell, sidebar, theme toggle
  ui/                        shadcn/Radix UI component primitives

convex/
  actions/                   Gemini and Supermemory workflows
  mutations/                 Database writes and storage upload URLs
  queries/                   Database reads for dashboards and pages
  schema.ts                  Convex data model
  users.ts                   User profile mutations and queries

lib/
  constants.ts               Specializations and blood groups
  prompts.ts                 Gemini prompt templates
  utils.ts                   Shared utility helpers

public/
  d1.png                     Landing page screenshot
  d2.png                     Doctor dashboard screenshot
  d3.png                     Session summary screenshot

Local Setup

Prerequisites

Install or create the following before running the project:

  • Node.js 20 or newer
  • npm or pnpm
  • A Clerk application
  • A Convex project/deployment
  • A Google Gemini API key
  • A Supermemory API key

1. Install dependencies

Using npm:

npm install

Or using pnpm:

pnpm install

2. Create the environment file

Copy the example file:

Copy-Item .env.example .env.local

Then fill in .env.local:

# Convex
NEXT_PUBLIC_CONVEX_URL=

# Clerk
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
CLERK_SECRET_KEY=
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/onboarding
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/onboarding

# Google Gemini AI
GOOGLE_GEMINI_API_KEY=

# Supermemory
SUPERMEMORY_API_KEY=

3. Configure Clerk

In the Clerk dashboard, configure the local app URLs:

  • Sign-in URL: http://localhost:3000/sign-in
  • Sign-up URL: http://localhost:3000/sign-up
  • After sign-in URL: http://localhost:3000/onboarding
  • After sign-up URL: http://localhost:3000/onboarding

Make sure your Clerk keys in .env.local match the application you configured.

4. Start Convex

Run Convex in one terminal:

npx convex dev

If this is your first time running Convex for the project, the CLI will ask you to log in and create or select a deployment. It will also keep Convex functions and generated types in sync.

Set the server-side environment variables used by Convex actions:

npx convex env set GOOGLE_GEMINI_API_KEY "your-gemini-api-key"
npx convex env set SUPERMEMORY_API_KEY "your-supermemory-api-key"

You can also set these from the Convex dashboard. They must be available to Convex actions because AI summarization, report analysis, and context sharing run on the Convex side.

5. Start the Next.js app

Run the app in another terminal:

npm run dev

Or with pnpm:

pnpm dev

Open:

http://localhost:3000

For network testing on another device, use your machine's LAN IP instead of localhost, for example:

http://10.255.255.254:3000/

Available Scripts

npm run dev      # Start the local Next.js development server
npm run build    # Build the production app
npm run start    # Start the production server after building
npm run lint     # Run ESLint

Main Routes

Route Purpose
/ Public landing page
/sign-in Clerk sign-in
/sign-up Clerk sign-up
/onboarding Role selection and profile creation
/doctor/dashboard Doctor dashboard
/doctor/availability Weekly availability setup
/doctor/appointments Doctor appointment management
/doctor/session/[appointmentId] Session recording and AI summary
/doctor/shared-context Shared patient context inbox
/patient/dashboard Patient dashboard
/patient/book Browse and search doctors
/patient/book/[doctorId] Book a doctor appointment
/patient/appointments Patient appointment history
/patient/reports Upload and review medical reports
/patient/share Share sessions and reports with another doctor

Data Model Overview

Convex stores the main application records:

  • doctorProfiles: doctor identity, specialization, license, bio, and available slots.
  • patientProfiles: patient identity, age, blood group, allergies, and emergency contact.
  • appointments: patient-doctor bookings and appointment status.
  • sessions: recorded session audio, transcript, AI summary, key decisions, and prescriptions.
  • reports: uploaded medical files, AI summaries, and critical flags.
  • sharedContexts: AI-generated patient handoffs shared between doctors.

Notes for Development

  • Keep npx convex dev running while building features that touch Convex functions.
  • Do not commit .env.local; use .env.example as the public template.
  • For session recording, the browser must allow microphone access.
  • Report upload supports PDF, PNG, JPG, JPEG, and WEBP.
  • If AI features fail while the UI still works, check Convex environment variables first.
  • If role redirects feel wrong, inspect the user's Clerk public metadata and the matching Convex profile table.

Build Check

Before deploying, run:

npm run lint
npm run build

This verifies TypeScript, linting, and the production Next.js build.

About

Medicare AI is a role-based healthcare coordination platform that helps doctors and patients manage appointments, clinical sessions, medical reports, and care handoffs. The application adds an AI layer between doctor and patient: it records and summarizes consultations, analyzes uploaded reports, flags critical findings, and creates reusable patien

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages