MediCare is a full stack healthcare assistant that combines a React frontend and a FastAPI backend. It supports AI chat, multimodal diagnosis from image and voice input, medication interaction analysis, appointment booking, and optional Google Calendar sync.
- AI assistant chat with user profile context.
- Diagnostic flow for reports, images, and voice notes.
- Medication interaction risk analysis.
- Doctor and appointment management endpoints.
- Optional Google Calendar event creation for appointments.
- Firebase authentication and Firestore backed user data flows.
- frontend contains the React app built with Vite and TypeScript.
- backend contains the FastAPI service and AI integrations.
- backend/services contains core service logic for chat, diagnosis, medication analysis, calendar integration, and voice utilities.
- frontend/src/components contains UI components for onboarding, appointments, medication, assistant, and landing pages.
- frontend/src/pages contains top level pages for auth, assistant, and diagnosis flows.
- Frontend: React 19, TypeScript, Vite, Tailwind CSS, Framer Motion, Firebase JS SDK.
- Backend: FastAPI, Uvicorn, Pydantic, Python dotenv.
- AI: Google Gemini via google genai SDK and Groq for transcription and LLM responses in diagnosis flow.
- Data and auth: Firebase Authentication and Firestore.
- Integrations: Google Calendar API and Google Text to Speech.
- Deployment: Vercel for frontend and backend.
- Node.js 20 or newer.
- Python 3.10 or newer.
- A Firebase project with web app config and admin credentials.
- A Gemini API key.
- A Groq API key.
- Optional Google OAuth client for Calendar integration.
Create one env file for frontend and one env file for backend.
Create frontend/.env with:
VITE_API_URL=http://localhost:8000
VITE_API_KEY=your_firebase_web_api_key
VITE_AUTH_DOMAIN=your_project.firebaseapp.com
VITE_PROJECT_ID=your_project_id
VITE_STORAGE_BUCKET=your_project.appspot.com
VITE_MESSAGING_SENDER_ID=your_sender_id
VITE_APP_ID=your_app_idCreate backend/.env with:
GEMINI_API_KEY=your_gemini_api_key
GROQ_API_KEY=your_groq_api_key
BACKEND_URL=http://localhost:8000
GOOGLE_CLIENT_ID=your_google_oauth_client_id
GOOGLE_CLIENT_SECRET=your_google_oauth_client_secret
GOOGLE_REDIRECT_URI=http://localhost:5173/calendar-callback.html
GOOGLE_APPLICATION_CREDENTIALS_JSON={"type":"service_account","project_id":"..."}Notes:
GOOGLE_APPLICATION_CREDENTIALS_JSONis expected as a JSON string in environment variables.- In local fallback mode, backend services can also use the JSON file at backend/hackwins-mind-flayers-firebase-adminsdk-fbsvc-ccc4812dec.json.
- Calendar service runs in mock mode if Google OAuth values are not configured.
cd frontend
npm installcd backend
python -m venv .venv
.\.venv\Scripts\activate
pip install -r requirements.txtOpen two terminals.
cd backend
.\.venv\Scripts\activate
uvicorn app:app --reload --port 8000cd frontend
npm run devFrontend runs on http://localhost:5173 by default.
All backend routes are defined in backend/app.py.
-
GET /Returns backend status. -
POST /api/chatInput includesuser_id,query,med_history, and optionaluser_profile. Returns model response text and role. -
POST /api/diagnoseMultipart form with optionalimage, optionalaudio, and requireduser_id. Returns transcription, diagnostic analysis, and optional generated audio url. -
POST /api/analyzeInput includesmedication_list. Returns risk level, interaction count, details, and normalized medication list. -
GET /doctorsReturns in memory doctor list. -
POST /doctorsAdds a doctor record to in memory store. -
POST /appointmentsBooks an appointment and optionally creates a Google Calendar event if credentials are provided. -
GET /appointments/{user_id}Returns appointments for a user id from in memory store. -
GET /api/calendar/auth-url?user_id=...Returns OAuth authorization url and state. -
POST /api/calendar/tokenExchanges auth code for token credentials.
Scripts in frontend/package.json:
npm run devstarts Vite development server.npm run buildruns TypeScript build and Vite production build.npm run lintruns ESLint.npm run previewpreviews the production build locally.
- Backend Vercel config is in backend/vercel.json and serves backend/app.py.
- Frontend Vercel config is in frontend/vercel.json.
- Add all required frontend and backend environment variables in Vercel project settings.
- Ensure backend CORS and frontend
VITE_API_URLpoint to deployed URLs.
- Chat messages are written to Firestore under
chats/{user_id}/messages. - Diagnosis history is written to Firestore under
user_summary/{user_id}/history. - Doctor and appointment data in backend/app.py are currently in memory and reset when the server restarts.
- Generated diagnosis audio files are saved in backend/static and served via
/static.
- If frontend cannot call backend, check
VITE_API_URLin frontend/src/config.ts. - If Firebase fails on backend startup, verify
GOOGLE_APPLICATION_CREDENTIALS_JSONformatting. - If diagnosis audio url is empty, verify
BACKEND_URLin backend env. - If calendar auth returns mock values, set valid Google OAuth env values.
- If
npm installfails in frontend, confirm Node.js version and remove stale lock or cache only inside frontend.
- Root level Node manifests were removed to keep root clean.
- Node dependency management is now scoped to frontend/package.json.
- Root
node_modulesis ignored and should not be committed.
- Do not commit
.envfiles. - Do not commit Firebase admin keys in production workflows.
- Rotate API keys if they were ever exposed.