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.
- 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.
| 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 |
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.
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, orcancelled - optional patient notes
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:
- Fetches the audio file from Convex storage.
- Sends it to Gemini for transcription.
- Fetches prior patient context from Supermemory.
- Sends the transcript and patient context to Gemini.
- Saves the transcript, AI summary, key decisions, and prescriptions to Convex.
- Marks the appointment as completed.
- Stores the session summary back into Supermemory for future visits.
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:
- Uploads the selected file to Convex storage.
- Creates a report record in Convex.
- Fetches patient context from Supermemory.
- Sends the file and prompt to Gemini for multimodal analysis.
- Saves a plain-language summary and critical flags to Convex.
- 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.
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:
- Reads the patient's longitudinal profile from Supermemory.
- Generates a consolidated handoff summary with Gemini.
- Creates a shared context record in Convex.
- 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.
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
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
Using npm:
npm installOr using pnpm:
pnpm installCopy the example file:
Copy-Item .env.example .env.localThen 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=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.
Run Convex in one terminal:
npx convex devIf 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.
Run the app in another terminal:
npm run devOr with pnpm:
pnpm devOpen:
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/
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| 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 |
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.
- Keep
npx convex devrunning while building features that touch Convex functions. - Do not commit
.env.local; use.env.exampleas 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.
Before deploying, run:
npm run lint
npm run buildThis verifies TypeScript, linting, and the production Next.js build.


