# VerifyID — ID Verification App

Flutter mobile app + Laravel API for secure identity verification with AI-powered face comparison.

## Stack

| Layer | Technology |
|---|---|
| Mobile App | Flutter (Dart) |
| Backend API | Laravel 11 (PHP 8.4) |
| AI Face Comparison | OpenAI GPT Vision |
| Database | SQLite (default, swap for MySQL/PostgreSQL in production) |

## Project Structure

```
/
├── flutter-app/          # Flutter mobile app (Dart)
│   ├── lib/
│   │   ├── main.dart
│   │   ├── constants/app_colors.dart
│   │   ├── models/verification_state.dart
│   │   ├── services/api_service.dart
│   │   ├── widgets/
│   │   │   ├── step_indicator.dart
│   │   │   └── primary_button.dart
│   │   └── screens/
│   │       ├── welcome_screen.dart
│   │       ├── register_screen.dart
│   │       ├── id_capture_screen.dart
│   │       ├── face_verify_screen.dart
│   │       └── verified_screen.dart
│   └── pubspec.yaml
│
└── laravel-app/          # Laravel API backend (PHP)
    ├── routes/api.php
    ├── app/Http/Controllers/VerificationController.php
    └── .env
```

## Running Locally (Flutter)

```bash
# Install Flutter SDK: https://flutter.dev/docs/get-started/install
cd flutter-app
flutter pub get
flutter run                      # mobile (iOS/Android)
flutter run -d chrome            # web browser
```

Set the API URL at build/run time:
```bash
flutter run --dart-define=API_URL=https://YOUR_DOMAIN
```

## Running the Laravel API (in Replit)

The Laravel API is already running at `/api`. It handles:
- `GET  /api/health` — health check
- `POST /api/verify/face` — AI face comparison

## Verification Flow

1. **Register** — name, email, country selection (18 countries supported)
2. **ID Capture** — take photo or upload from gallery (country-specific ID guidance)
3. **Face Verify** — take a selfie with front camera
4. **Result** — AI compares faces, shows verified/failed with confidence level

## Environment Variables

| Variable | Description |
|---|---|
| `AI_INTEGRATIONS_OPENAI_BASE_URL` | Auto-set by Replit AI integration |
| `AI_INTEGRATIONS_OPENAI_API_KEY` | Auto-set by Replit AI integration |

## API Contract

### POST /api/verify/face

Request:
```json
{
  "id_image": "<base64 JPEG>",
  "face_image": "<base64 JPEG>",
  "country": "EG",
  "name": "John Doe",
  "email": "john@example.com"
}
```

Response:
```json
{
  "match": true,
  "confidence": "high",
  "reason": "Facial features match with high similarity"
}
```

## Notes

- Flutter requires a local Flutter SDK to run — the Replit environment can run the Laravel API only
- The OpenAI integration is pre-configured via Replit AI integrations (no API key needed)
- CORS is open in development (`config/cors.php`), restrict in production
