# Medicout Backend

Complete production-ready backend for Medicout — an international telemedicine marketplace.

## Setup Instructions

1. Clone the repository and run `npm install`
2. Copy `.env.example` to `.env` and fill in the environment variables.
3. Import `medicout.sql` into your local MySQL instance.

## Environment Variables
See `.env.example` for the complete list of required configuration.

## How to Run Locally

Start Redis and MySQL locally. Then:

### Step 1 - Start backend
```bash
cd medicout-backend
npm run dev
```
*(Runs on port 3000)*

### Step 2 - Start Flutter on FIXED port
```bash
cd medicout-flutter-app
flutter run -d chrome --web-port 3001
# OR for Edge:
flutter run -d edge --web-port 3001
```

### Step 3 - Verify CORS works
Open your browser console running the Flutter app — no "CORS policy" errors should appear. Login requests should succeed and appear as `POST /api/auth/login 200` in the backend terminal.

### Production
```bash
npm start
```

## API Endpoints Summary
- **Auth**: `/api/auth/register`, `/api/auth/login`, `/api/auth/google`, etc.
- **Profile**: `/api/profile`, `/api/profile/photo`, `/api/profile/completion`
- **Search**: `/api/search/symptoms`, `/api/doctors/search`, `/api/specialties`
- **Appointments**: `/api/appointments`, `/api/appointments/:id`
- **Calendar**: `/api/calendar/connect`, `/api/calendar/callback`
- **Chat**: `/api/chat/threads`, `/api/chat/upload`
- **Notifications**: `/api/notifications`

## Mock Credentials for Testing
- Patient: `patient@test.com` / `test123`
- Doctor: `doctor@test.com` / `test123`
