one-build

Build 03: Authentication with Firebase + SQL

How we set up Google and email-based login using Firebase Auth, then connected that identity layer to our custom database for full lifecycle control.

Why Authentication Matters Firebase Cursor AI

Our app lets users store their own recipes, preferences, and pantry items. That means we need user accounts—and a way to manage them securely.

This was my first time building authentication. It came together quickly. In this post, I’ll show you:

  1. How we implemented sign-in via Google and email/password (Facebook to come)
  2. How we link those accounts to a real database
  3. Why we might need to start thinking about account deletion early on.


1. Auth Flow Architecture Firebase Google Cloud SQL Google Cloud Functions

Firebase handles identity. But we also want:

  1. Database-level user metadata
  2. Onboarding logic
  3. Analytics and lifecycle tracking

So we use Firebase for login, then sync to SQL via Cloud Functions.

Endpoints We Built

  1. checkEmailExists: Checks if an email already exists in our user database.

    • ✅ If it does: continue to Firebase login
    • ❌ If not: show sign-up screen
  2. createNewAccount: Stores new user data (name, preferences, etc) in the database.

  3. updateFirebaseUid: After login, this endpoint links the Firebase UID to the correct DB record.

This separation gives us full control over the user experience while still leaning on Firebase for secure auth.


2. Add a Deletion Policy Early Firebase SQL

Even though this is just a proof-of-concept, we’ve already started thinking about deletion policies.

Why? If you want to add Facebook Login, Facebook requires a public data deletion page. But more broadly—it’s just good practice.

Here’s what we’re doing:

  1. Add a status column to the users table: active, deactivated, deleted
  2. When a user deletes their account:
    • Hash their email + Firebase UID
    • Wipe any PII fields (name, preferences)
    • Keep the record for aggregate analytics

This gives us a way to track total usage without retaining personal data.



3. Working With Cursor AI Cursor AI Cloud Functions

Cursor AI was a big help scaffolding functions. But it’s easy to veer off track.

One time, it rewrote a Firebase-style function that didn’t work with our Cloud Functions setup on Cloudflare.

Tips for Working With Cursor

  1. Always remind Cursor what your backend structure is
  2. Ask it to “review code like a senior engineer” after it writes
  3. Use Git early and often—Cursor’s rollback feature is hit-or-miss


Summary: Where We Are Now Firebase SQL Cloud

Right now we support:

  1. Login with Google and email/password
  2. Firebase as identity layer
  3. SQL for app-specific user data

Next up: We’ll be focusing on the actual features that will allow us to start saving recipes and start cooking!