Files
Sage/FIREBASE_SETUP.md
Dani 6c29751e49 Change package name to GitHub-based format
📦 Package Rename: com.sage.sage → com.github.mystiatech.sage

 Changes:
- Updated applicationId in build.gradle.kts
- Updated namespace in build.gradle.kts
- Moved MainActivity.kt to new package structure
- Updated google-services.json placeholder
- Updated FIREBASE_SETUP.md with correct package name
- Updated README_FIREBASE.md with correct package name

🎯 Reason:
- GitHub-based package names don't require domain ownership
- Standard convention: com.github.username.appname
- Ready for Firebase setup without needing website registration

📋 Firebase Setup:
When setting up Firebase, use package name:
com.github.mystiatech.sage

 Build Status:
- APK builds successfully (63.3MB)
- All tests passing
- Ready for Firebase configuration

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-04 15:34:37 -04:00

3.6 KiB

Firebase Setup Guide for Sage

Step 1: Create Firebase Project

  1. Go to Firebase Console
  2. Click "Add project"
  3. Enter project name: sage-kitchen-management
  4. Disable Google Analytics (optional for this app)
  5. Click "Create project"

Step 2: Add Android App

  1. In Firebase Console, click the Android icon to add an Android app
  2. Enter package name: com.github.mystiatech.sage (must match exactly!)
  3. App nickname: Sage (optional)
  4. Debug signing certificate SHA-1: (optional, skip for now)
  5. Click "Register app"

Step 3: Download Configuration File

  1. Download the google-services.json file
  2. Place it in: android/app/google-services.json

Step 4: Set up Firestore Database

  1. In Firebase Console, go to "Build" → "Firestore Database"
  2. Click "Create database"
  3. Choose "Start in test mode" for development
  4. Select a Firestore location (e.g., us-central)
  5. Click "Enable"

Security Rules (update after testing)

For development/testing, use test mode rules:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.time < timestamp.date(2025, 12, 31);
    }
  }
}

For production, update to:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    // Allow anyone to read household data by code
    match /households/{householdId} {
      allow read: if true;
      allow create: if true;
      allow update: if true;
      allow delete: if request.auth != null;

      // Allow household members to manage items
      match /items/{itemId} {
        allow read: if true;
        allow write: if true;
      }
    }
  }
}

Step 5: Update Android Build Files (Already Done)

The following files need to be updated (will be done automatically):

  1. android/build.gradle - Add Google Services plugin
  2. android/app/build.gradle - Apply Google Services plugin

Step 6: Initialize Firebase in App

The app will automatically initialize Firebase on startup.

Firestore Data Structure

households (collection)
  └── {householdCode} (document)
      ├── id: string
      ├── name: string
      ├── ownerName: string
      ├── createdAt: string (ISO 8601)
      └── members: array<string>
      └── items (subcollection)
          └── {itemKey} (document)
              ├── name: string
              ├── barcode: string?
              ├── quantity: number
              ├── unit: string?
              ├── purchaseDate: string (ISO 8601)
              ├── expirationDate: string (ISO 8601)
              ├── locationIndex: number
              ├── category: string?
              ├── photoUrl: string?
              ├── notes: string?
              ├── userId: string?
              ├── householdId: string
              ├── lastModified: string (ISO 8601)
              └── syncedToCloud: boolean

Testing

  1. Create a household on Device A
  2. Note the 6-character code
  3. Join the household from Device B using the code
  4. Add items on Device A → should appear on Device B
  5. Add items on Device B → should appear on Device A

Troubleshooting

  • "google-services.json not found": Make sure file is in android/app/ directory
  • Build errors: Run flutter clean && flutter pub get
  • Permission denied: Check Firestore security rules in Firebase Console
  • Items not syncing: Check internet connection and Firebase Console logs