🔥 Firebase Setup Guide for Magdalena Food Tracker
🔥 Firebase Setup Guide for Magdalena Food Tracker
Step 1: Create Firebase Project
- Go to Firebase Console
- Click “Create a project” or “Add project”
- Name it
magdalena-food-tracker
- Enable Google Analytics (optional)
- Click “Create project”
Step 2: Enable Firestore Database
- In your Firebase project, click “Firestore Database” in the left sidebar
- Click “Create database”
- Choose “Start in test mode” (we’ll secure it later)
- Select a location close to you (e.g.,
us-central1
) - Click “Done”
Step 3: Get Your Configuration
- Click the gear icon ⚙️ next to “Project Overview”
- Select “Project settings”
- Scroll down to “Your apps” section
- Click the web icon (</>)
- Register app with name “Magdalena Food Tracker”
- Copy the configuration object
Step 4: Update Configuration File
Replace the placeholder config in /assets/js/firebase-config.js
with your actual Firebase config:
const firebaseConfig = {
apiKey: "your-actual-api-key",
authDomain: "your-project-id.firebaseapp.com",
projectId: "your-project-id",
storageBucket: "your-project-id.appspot.com",
messagingSenderId: "your-sender-id",
appId: "your-app-id"
};
Step 5: Set Up Security Rules (Optional but Recommended)
In Firestore Database → Rules, replace with:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /food_entries/{document} {
allow read, write: if true; // For now, allow all access
}
}
}
Step 6: Test Your Setup
- Deploy your changes to GitHub Pages
- Visit your food tracker page
- Try adding a new entry
- Check the browser console for any errors
- Verify data appears in Firebase Console → Firestore Database
🎉 Benefits You’ll Get
- Real-time sync across all devices
- Automatic backups in the cloud
- No data loss if browser is cleared
- Access from anywhere - phone, laptop, tablet
- Free tier handles thousands of entries
đź”§ Troubleshooting
If you see “Firebase not initialized” errors:
- Check that your config is correct
- Ensure Firebase SDK scripts are loading
- Verify the order of script tags
If data isn’t saving:
- Check browser console for errors
- Verify Firestore is enabled
- Check security rules
If you want to migrate existing localStorage data:
- The app will automatically create sample data if Firebase fails
- You can manually add entries through the form
📱 Cross-Device Usage
Once set up, Magdalena can:
- Add entries on her phone
- See them instantly on her laptop
- Access from any browser
- Never lose data again!
The app will automatically sync in real-time across all devices. ✨