Skip to content

Latest commit

 

History

History
93 lines (73 loc) · 2.83 KB

File metadata and controls

93 lines (73 loc) · 2.83 KB

Firebase Setup for CognitiveGames Project

Your Firebase project is already configured! Follow these final steps to enable Firestore database.

🔥 Project Details

⚡ Quick Setup (2 minutes)

1. Enable Firestore Database

  1. Go to your Firebase Console
  2. Click "Firestore Database" in the left sidebar
  3. Click "Create database"
  4. Choose "Start in test mode" (allows read/write access)
  5. Select region closest to your users (recommend us-central1)
  6. Click "Done"

2. That's it! 🎉

Your React app is already configured with your Firebase credentials and will automatically:

  • ✅ Create collections for each game type
  • ✅ Save patient data to both API and Firebase
  • ✅ Handle errors gracefully if either storage fails

The system will automatically create these collections:

  • numberSequenceResults - Number Sequencing game results
  • memoryPalaceResults - Memory Palace game results
  • toneMemoryResults - Tone Memory game results
  • imageMatchingResults - Image Matching game results
  • tickerTapeResults - Ticker Tape game results
  • patientSessions - Patient session data

6. Security Rules (Optional)

For production, update Firestore security rules:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    // Allow read/write to all documents for now
    match /{document=**} {
      allow read, write: if true;
    }
  }
}

🎯 Features

Dual Storage System

  • Primary: Your existing API database (SQL Server)
  • Backup: Firebase Firestore (NoSQL)
  • Fallback: If one fails, the other continues
  • Real-time: Firebase provides real-time data sync
  • Scalable: Firebase handles scaling automatically

Data Structure

Each game result includes:

  • All original game data
  • savedAt: Firebase server timestamp
  • gameType: Identifies which game
  • Patient session information
  • Performance metrics

Console Logging

Check browser console to see:

  • ✅ Successful saves to both databases
  • ❌ Any failures with detailed error messages
  • 📊 Which storage succeeded/failed

🔧 Disable Firebase (Optional)

To disable Firebase and only use your API:

REACT_APP_FIREBASE_ENABLED=false

📊 Data Access

Firebase Console

  • View data in real-time at Firebase Console > Firestore Database
  • Export data as JSON or CSV
  • Set up real-time dashboards

API Access

  • Use Firebase Admin SDK for server-side access
  • Query with complex filters and aggregations
  • Set up automated backups

Your cognitive training platform now has redundant data storage for maximum reliability! 🚀