Firebase Baas

Installation
SKILL.md

2.3.1 Firebase Baas

This skill defines the architectural patterns for leveraging Firebase as a complete Backend-as-a-Service across all projects, with emphasis on cost efficiency for indie/bootstrapped applications.

1. Firebase Authentication

Goal: Frictionless, secure user identity management.

  • Anonymous Auth: Always implement signInAnonymously() as the default on first launch. This enables immediate usage without barriers while creating a persistent UID for data association.
  • Account Linking: When the user is ready to commit (after value delivery), use linkWithCredential() to upgrade their anonymous account to Google OAuth, Apple Sign-In, or Email/Password. All their existing data travels with them — zero data loss.
  • Provider Priority: Google OAuth first (highest conversion on Android), Apple Sign-In (required by Apple for apps with third-party login), Email/Password as fallback.
  • Security: Enable Email Enumeration Protection in Firebase Console. Set session duration appropriately. Implement multi-factor authentication (MFA) for admin/sensitive flows.

2. Firestore Data Modeling

Goal: Schema design optimized for read performance, cost, and real-time sync.

  • Denormalization: Firestore is not a relational database. Duplicate data across documents to avoid joins. A user's display name should exist in every document that renders it — not fetched via a reference.
  • Collection Structure: Use top-level collections for primary entities (users, games, sessions). Use subcollections for owned data (users/{uid}/tickets, games/{gameId}/players).
  • Document Size: Keep documents under 20KB for fast reads and real-time sync efficiency. Move large blobs (images, audio) to Cloud Storage and store only the URL reference.
  • Indexes: Create composite indexes proactively for any query combining where() clauses on different fields with orderBy(). Monitor the Firestore console for auto-suggested indexes.
  • Reads Optimization: Use getDoc() for one-time reads, onSnapshot() only when real-time updates are needed. Implement pagination with startAfter() and limit() to cap reads.
Installs
–
GitHub Stars
8
First Seen
–
Firebase Baas — mayurrathi/awesome-agent-skills