# Hey Ayuel - Setup & Run Instructions

## 1. Prerequisites
- Flutter SDK installed (3.0+)
- CocoaPods installed (for iOS)
- A Google Cloud Project with Firebase enabled.
- Gemini API Key.

## 2. Firebase Setup (Critical)
1. **Create Project**: Go to [console.firebase.google.com](https://console.firebase.google.com) and create a project "Hey Ayuel".
2. **Add Apps**:
   - Add **Android** app (package `com.john_gai_apps.hey_ayuel`). Download `google-services.json` to `android/app/`.
   - Add **iOS** app (bundle ID `com.john_gai_apps.heyAyuel`). Download `GoogleService-Info.plist` to `ios/Runner/`.
3. **Authentication**:
   - Go to Authentication > Sign-in method.
   - Enable **Anonymous** auth.
4. **Firestore**:
   - Go to Firestore Database > Create Database.
   - Start in **Test mode** (or Production, but update rules).
   - **Rules**:
     ```
     rules_version = '2';
     service cloud.firestore {
       match /databases/{database}/documents {
         match /users/{userId}/{document=**} {
           allow read, write: if request.auth != null && request.auth.uid == userId;
         }
       }
     }
     ```
5. **FlutterFire**:
   - Alternatively, run `flutterfire configure` in the project root if you have the CLI tool.

## 3. Gemini Setup
1. Get an API Key from [Google AI Studio](https://makersuite.google.com/app/apikey).
2. Open `lib/services/gemini_service.dart`.
3. Replace the placeholder constant:
   ```dart
   const String _kGeminiApiKey = "YOUR_BS_KEY_HERE";
   ```
   *Note: In a real production app, use `flutter_dotenv` or Firebase Remote Config to secure this key.*

## 4. Platform Permissions
### iOS (`ios/Runner/Info.plist`)
Already configured by `permission_handler`, but ensure these keys exist:
```xml
<key>NSMicrophoneUsageDescription</key>
<string>We need access to the microphone to talk to Ayuel.</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>We need speech recognition to understand your commands.</string>
```

### Android (`android/app/src/main/AndroidManifest.xml`)
Ensure permissions are there:
```xml
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.INTERNET"/>
```

## 5. Running the App
1. Install dependencies:
   ```bash
   flutter pub get
   ```
2. Run on Simulator/Device:
   ```bash
   flutter run
   ```

## 6. Usage flow
1. **Onboarding**: Launches on first run. Select your persona and boundaries. Saves to Firestore.
2. **Main Screen**:
   - **Talk**: Press and **HOLD** the mic button. Speak. Release to send.
   - **Transcript**: Shows what you said.
   - **Response**: Gemini analyzes your request + profile + context (Energy level) and suggests a micro-decision.
   - **History**: Check `History` tab for past logs.
