✨ New Features: - Firebase Firestore integration for real-time household sharing - Create household → generates code stored in cloud - Join household → looks up code from Firebase across devices - Leave household → updates member list in cloud - Cloud-first with local Hive fallback for offline 🔧 Technical Implementation: - Added firebase_core and cloud_firestore dependencies - Created FirebaseHouseholdService for all cloud operations - Updated HouseholdScreen to use Firebase for create/join/leave - Modified gradle files to support Google Services plugin - Increased minSdk to 21 for Firebase compatibility - Version bumped to 1.1.0+2 (MAJOR.MINOR.BUGFIX) 📁 New Files: - lib/features/household/services/firebase_household_service.dart - FIREBASE_SETUP.md - Complete setup instructions - android/app/google-services.json - Placeholder (needs replacement) - android/app/README_FIREBASE.md - Firebase config reminder ⚙️ Setup Required: 1. Create Firebase project at console.firebase.google.com 2. Add Android app with package name: com.sage.sage 3. Download real google-services.json 4. Enable Firestore Database in test mode 5. See FIREBASE_SETUP.md for complete instructions 🎯 How it works: - Device A creates household → stored in Firestore - Device B joins with code → reads from Firestore - Both devices now share same household ID - Inventory items sync via shared household ID 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
3.6 KiB
3.6 KiB
Firebase Setup Guide for Sage
Step 1: Create Firebase Project
- Go to Firebase Console
- Click "Add project"
- Enter project name:
sage-kitchen-management
- Disable Google Analytics (optional for this app)
- Click "Create project"
Step 2: Add Android App
- In Firebase Console, click the Android icon to add an Android app
- Enter package name:
com.example.sage
(must match AndroidManifest.xml) - App nickname:
Sage
(optional) - Debug signing certificate SHA-1: (optional, skip for now)
- Click "Register app"
Step 3: Download Configuration File
- Download the
google-services.json
file - Place it in:
android/app/google-services.json
Step 4: Set up Firestore Database
- In Firebase Console, go to "Build" → "Firestore Database"
- Click "Create database"
- Choose "Start in test mode" for development
- Select a Firestore location (e.g.,
us-central
) - 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):
android/build.gradle
- Add Google Services pluginandroid/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
- Create a household on Device A
- Note the 6-character code
- Join the household from Device B using the code
- Add items on Device A → should appear on Device B
- 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