Firebase and Serverless
What is Serverless?
Section titled “What is Serverless?”Serverless doesn’t mean there are no servers - it means you don’t have to manage them. Instead of provisioning, scaling, and maintaining servers yourself, cloud providers handle all of that for you.
Benefits of Serverless:
- No server management - Focus on code, not infrastructure
- Auto-scaling - Automatically scales up/down based on demand
- Pay per use - Only pay for actual execution time
- Faster deployment - Deploy functions in seconds
What is Firebase?
Section titled “What is Firebase?”Firebase is Google’s Backend-as-a-Service (BaaS) platform. It provides a suite of tools for building web and mobile applications:
| Service | Description |
|---|---|
| Cloud Functions | Serverless functions that run your backend code |
| Firestore | NoSQL document database |
| Hosting | Fast, secure static hosting |
| Authentication | User authentication service |
| Storage | File storage for user-generated content |
Screencast channel
Section titled “Screencast channel”You can see all video playlist for Week 3 here: https://screenpal.com/channels/c0fvXvVYvQ
Getting Started
Section titled “Getting Started”Learn how to set up a Firebase project and understand the Firebase Console.
Key concepts covered:
- Creating a Firebase project
- Navigating the Firebase Console
- Understanding project settings and configurations
Firebase Functions
Section titled “Firebase Functions”Cloud Functions for Firebase lets you run backend code in response to events triggered by Firebase features and HTTPS requests. Your code is stored in Google’s cloud and runs in a managed environment.
Key concepts covered:
- Setting up Firebase CLI
- Writing your first Cloud Function
- Deploying functions to Firebase
- Understanding function triggers (HTTP, Firestore, Pub/Sub)
Firebase Functions and KoaJS
Section titled “Firebase Functions and KoaJS”Learn how to integrate the KoaJS framework you learned in Week 1 with Firebase Cloud Functions. This allows you to use familiar routing patterns and middleware in a serverless environment.
Key concepts covered:
- Wrapping KoaJS app in a Firebase Function
- Using
koa-routerwith Cloud Functions - Handling middleware in serverless context
Firebase Hosting
Section titled “Firebase Hosting”Firebase Hosting provides fast and secure hosting for your web app, static and dynamic content. It’s where we deploy our React applications.
Key concepts covered:
- Deploying static files to Firebase Hosting
- Configuring
firebase.jsonfor hosting - Setting up custom domains
- Understanding CDN and caching
Firestore
Section titled “Firestore”Cloud Firestore is a flexible, scalable NoSQL cloud database. Unlike traditional SQL databases, Firestore stores data in documents organized into collections.
Key concepts covered:
- Documents and Collections structure
- CRUD operations (Create, Read, Update, Delete)
- Querying data with
where,orderBy,limit - Real-time listeners
- Understanding NoSQL data modeling
Exercise
Section titled “Exercise”After this Firestore lesson, your exercise would be to change the repository of the todo app we have been working on so far to Firestore instead of saving and loading data from file.
Requirements:
- Create a Firestore collection called
todos - Migrate all CRUD operations from file-based storage to Firestore
- Each todo should be a document with fields:
id,title,completed,createdAt - Test all API endpoints still work correctly