# How To Build Your First App with AI - Lesson 6 (user sign up)

Source: https://www.youtube.com/watch?v=90-tFUITfvM
Recap page: https://rapidrecap.app/video/90-tFUITfvM
Generated: 2025-12-07T15:33:50.716+00:00

---
## Quick Overview

The tutorial successfully sets up the backend infrastructure for user authentication and data handling using Firebase, including creating a Firebase project, configuring Auth with Google and email/password sign-in, setting up Cloud Firestore with a specific schema, and initializing a local Firebase emulator environment for development, all while emphasizing best practices like using unique IDs and avoiding risky practices like committing secrets.

**Key Points:**
- The video demonstrates setting up Firebase backend services for a web application, focusing on user authentication (Google and email/password) and data persistence via Cloud Firestore.
- A new Firebase project named "thumio-prod" was created, followed by enabling Google and Email/Password sign-in providers in the Authentication settings.
- The Cloud Firestore database was initialized using the standard edition, setting up the basic 'users' collection structure with documents containing user-specific data like email, creation timestamps, and a unique 'studioId'.
- The user demonstrated the importance of referencing the provided Firestore schema document (`firestore-data-schema.md`) to ensure all necessary data points (e.g., preferences, achievements, billing) are initialized correctly in the Cloud Function upon user creation.
- The local Firebase emulator suite was successfully started (Auth on port 9099, Firestore on 8080, Functions on 5001) to allow local testing, confirming that the functions were correctly triggered upon user creation.
- The developer used Git to manage changes, creating a separate 'auth' branch for the authentication setup and committing changes like setting up the Firebase configuration files and the initial user data creation function (`onDocumentCreated`).
- The process emphasizes best practices such as using the Firebase CLI for setup, avoiding hardcoding secrets, and ensuring unique IDs for new studios are generated server-side.

![Screenshot at 00:00: Host begins the tutorial by displaying the Thumio landing page and outlining the plan to set up Firebase for user authentication and data handling.](https://ss.rapidrecap.app/screens/90-tFUITfvM/00-00-00.png)

**Context:** This video is episode six of a series detailing the backend setup for an AI thumbnail generation platform called 'Thumio', moving from frontend setup to integrating Google Firebase services. The host focuses on securely setting up user authentication (Auth) and database (Firestore) structures using TypeScript functions, while also running the Firebase emulator locally to test these backend changes.

## Detailed Analysis

The tutorial walks through setting up the Firebase backend infrastructure, starting with creating a Firebase project named "thumio-prod" and configuring Authentication to support Google Sign-In and Email/Password sign-in, including passwordless email link sign-in. The host emphasizes the importance of using the Firebase CLI to manage the setup and commits changes to a dedicated Git branch named 'auth'. Crucially, the Firestore database is initialized, and the corresponding Cloud Function (`onDocumentCreated` in `functions/src/index.ts`) is modified to create comprehensive user data documents that adhere to a defined Firestore schema (`docs/architecture/firestore-data-schema.md`). This schema structure is shown, highlighting fields like user preferences, achievements, billing, and a unique `studioId`. The host also sets up the local Firebase emulator suite (running on ports 4000, 9099, 8080, 5001) to test the backend logic locally, confirming that the user creation function successfully populates the necessary data points in the Firestore emulator. The process concludes with the successful initialization of the backend services, providing a solid foundation for subsequent development, particularly regarding protected routes and UI implementation.

### Firebase Project & Auth Setup

- Created Firebase project "thumio-prod"
- Enabled Google and Email/Password authentication providers
- Set up a separate Git branch named 'auth' for changes.

### Firestore Setup

- Initialized Cloud Firestore using the standard edition
- Confirmed the data structure in `firestore-data-schema.md` must be followed for user creation.

### Cloud Function Updates (index.ts)

- Modified the `onDocumentCreated` function to initialize user data and create a unique `studioId` document for new users.

### Local Development Environment

- Ran `npm run emulators` to start Auth (9099), Firestore (8080), and Functions (5001) emulators locally
- Verified successful local setup via emulator overview and console logs.

### Security & Data Integrity

- Emphasized the need for secure Firestore rules (shown in `firestore.rules`) and ensuring the studio ID is unique and tied to the user UID upon creation, avoiding hardcoding secrets from `.env.local`.

![Screenshot at 00:00: Host introduces the goal: setting up Firebase authentication and connecting it to the backend structure for user sign-up.](https://ss.rapidrecap.app/screens/90-tFUITfvM/00-00-00.png)
![Screenshot at 01:21: The host details the required Firebase components \(Auth via Node.js, Python for AI/Stripe\) and emphasizes the need to create a Firebase project.](https://ss.rapidrecap.app/screens/90-tFUITfvM/00-01-21.png)
![Screenshot at 03:11: The process of creating a new Firebase project in the console, naming it 'thumio-prod', and opting into Google Analytics is shown.](https://ss.rapidrecap.app/screens/90-tFUITfvM/00-03-11.png)
![Screenshot at 04:51: The host shows the Firebase Authentication console where Email/Password and Google sign-in methods are enabled.](https://ss.rapidrecap.app/screens/90-tFUITfvM/00-04-51.png)
![Screenshot at 07:39: The host navigates to the Firebase console to begin setting up Authentication, showing the available sign-in providers.](https://ss.rapidrecap.app/screens/90-tFUITfvM/00-07-39.png)
