# Jarvis Mobile

Flutter mobile app for Jarvis internal management system.

**Platform:** Android & iOS  
**Backend:** `https://jarvis.goteku.com/api/v1`  
**Access:** Admin only

---

## Prerequisites

| Tool | Version | Install |
|------|---------|---------|
| Flutter | 3.24.x | [flutter.dev](https://flutter.dev/docs/get-started/install) |
| Dart | 3.5.x | Included with Flutter |
| Android Studio | Latest | For Android SDK & emulator |
| Xcode | 15+ | For iOS (macOS only) |

Verify installation:
```bash
flutter doctor
```

---

## Setup

### 1. Install dependencies

```bash
cd mobile
flutter pub get
```

### 2. Firebase setup (required for push notifications)

Firebase config files are excluded from git. Generate them:

```bash
# Install FlutterFire CLI (one-time)
dart pub global activate flutterfire_cli

# Run from /mobile folder
flutterfire configure --project=jarvis-the-brain
```

This generates:
- `android/app/google-services.json`
- `ios/Runner/GoogleService-Info.plist`
- `lib/firebase_options.dart`

> Ask the project admin for access to the Firebase project `jarvis-the-brain`.

### 3. Environment files

| File | Usage |
|------|-------|
| `env/prod.json` | Production — `https://jarvis.goteku.com/api/v1` |
| `env/dev.json` | Local dev — `http://10.0.2.2:8000/api/v1` (Android emulator) |

---

## Running the App

### Connect to live server (production)

```bash
flutter run --dart-define-from-file=env/prod.json
```

### Local development

```bash
flutter run --dart-define-from-file=env/dev.json
```

---

## Build APK (Android)

```bash
flutter build apk --dart-define-from-file=env/prod.json
```

APK location: `build/app/outputs/flutter-apk/app-release.apk`

**Install to device:**
```bash
# Via ADB (USB cable)
adb install build/app/outputs/flutter-apk/app-release.apk

# Or transfer APK via WhatsApp/Drive and install manually.
# Enable "Install from unknown sources" in Android Settings first.
```

---

## Build iOS (macOS only)

```bash
flutter build ios --dart-define-from-file=env/prod.json
```

Requires Apple Developer account for device install or TestFlight.

---

## Project Structure

```
mobile/
├── env/
│   ├── prod.json          # Production API URL
│   └── dev.json           # Local dev API URL
├── lib/
│   ├── main.dart
│   ├── app.dart           # Router + bottom nav shell
│   ├── core/
│   │   ├── api/           # Dio + JWT interceptor
│   │   ├── auth/          # Auth state + notifier
│   │   ├── theme/         # Colors + theme
│   │   └── widgets/       # Shared widgets
│   ├── features/
│   │   ├── auth/
│   │   ├── dashboard/
│   │   ├── tasks/
│   │   ├── surat/         # Letters
│   │   ├── contracts/
│   │   ├── notifications/
│   │   └── profile/
│   └── shared/
│       ├── models/
│       └── providers/     # Riverpod providers
└── pubspec.yaml
```

---

## Tech Stack

| Package | Purpose |
|---------|---------|
| `flutter_riverpod` | State management |
| `go_router` | Navigation + deep links |
| `dio` | HTTP client + JWT interceptor |
| `flutter_secure_storage` | Secure JWT token storage |
| `firebase_messaging` | Push notifications (FCM) |
| `file_picker` | PDF upload for contracts |
| `intl` | Date formatting |
