Build Full stack WebApp plus Firebase - Channel Profit Studio
https://www.youtube.com/watch?v=juEfJERgBE8 Here is a comprehensive Markdown guide based on the video tutorial.
Building a Full-Stack Web App with Google AI Studio & Firebase
This guide outlines how to transform a static website design into a functional web application with user accounts, database storage, and file uploads using Google AI Studio and Firebase. The Goal: Build an app where users can sign up, log in, manage their own data, and upload files—where every user only sees their own information.
📋 Roadmap
- User Authentication: Sign up, Log in, Log out.
- Store User Data: Save user settings and text data (Firestore).
- File Uploads: Upload and manage files (Firebase Storage).
- Connect to UI: Make the interface react to the user state.
🛠️ Phase 1: User Authentication
The goal is to allow users to create accounts and log in securely.
1. Firebase Setup
- Go to the Firebase Console and create a new project.
- Select Web App (
</>) icon to register your app. - Copy the
**firebaseConfig**code provided (SDK setup). You will need this for the AI prompt.
2. Configure Authentication
- In Firebase, go to Build > Authentication.
- Click Get Started.
- Enable Email/Password: Toggle to enable and save.
- Enable Google Sign-In:
- Add new provider > Google.
- Set the Project Support Email.
- Note: Google Sign-in requires the app to be deployed to a live URL to function fully.
- Customize Emails (Templates Tab):
- Edit the “Sender Name” to your App Name (e.g., “VaultFlow”) so users trust the email.
3. AI Studio Implementation
Go to Google AI Studio and use the following prompt logic to connect the backend:
Prompt: “Connect my existing web app to Firebase using this SDK: [PASTE CONFIG HERE]. Requirements: Use Firebase Auth only. Do not use Firestore/Storage yet. Do not redesign UI. Authenticate users via Email/Password and Google.”
🗄️ Phase 2: Store User Data (Firestore)
Authentication identifies who the user is, but the Database stores what belongs to them.
1. Enable Firestore
- In Firebase, go to Build > Firestore Database.
- Click Create Database.
- Select Standard or Production Mode (Never use Test Mode for real apps).
- Select the Region closest to your users.
2. Set Security Rules
Delete default rules and use rules that ensure data isolation (User A cannot see User B’s data).
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Root user document
match /users/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
// Subcollections (files, notes, etc.)
match /{allPaths=**} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
}
}
}
3. AI Studio Implementation
Update the dashboard to show user-specific data.
Prompt: “Dashboard Upgrade: Add sections for ‘My Files’, ‘My Notes’, and ‘Team’. Store this data in Firestore. Structure: Users > [UserID] > Collections. Ensure each user only sees their own data.”
☁️ Phase 3: File Uploads (Storage)
Firestore is for text/JSON. Firebase Storage is for images, PDFs, and audio.
1. Enable Storage
- In Firebase, go to Build > Storage.
- Upgrade to Blaze Plan (Pay as you go):
- Note: This is required to enable Storage, but the free tier is generous. Set a budget alert (e.g., $5) to avoid surprises.
- Create a Default Bucket (select a “No Cost” region like
us-central1if available). - Set to Production Mode.
2. Storage Security Rules
Replace default rules with specific user-isolation rules:
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /user_uploads/{userId}/{allPaths=**} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
}
}
3. AI Studio Implementation
Enable the file upload button functionality.
Prompt: “Connect the ‘Add File’ button to Firebase Storage. Requirements: Upload files from device. Save file metadata (name, type, URL) to Firestore. Store actual file in Storage path:
user_uploads/{uid}/{filename}.”
🔗 Phase 4: Connect & Logic
Now, ensure the UI reacts to the backend logic dynamically.
1. Dynamic UI
The app should greet the user by name and display their specific content.
- Logic: When
AuthStatechanges to “Logged In”, fetch data from Firestoreusers/{uid}and populate the Dashboard.
2. Implementing Limits (SaaS Features)
You can use logic to simulate paid plans.
Prompt: “Implement a Free Plan limit. Max 5 files per user. Check Firestore count. If user has 5+ files, disable the ‘Upload’ button and show a modal: ‘Limit Reached - Upgrade Plan’.”
🚀 Deployment (Crucial Step)
For features like Google Sign-In to work properly, your app must be hosted on a live domain, not just a local preview.
- Deploy your code (e.g., via Vercel, Netlify, or Firebase Hosting).
- Copy your new domain (e.g.,
https://myapp.com). - Go to Firebase Console > Authentication > Settings > Authorized Domains.
- Add Domain: Paste your live URL here.
Result: You now have a fully functional web application with secure authentication, database management, and file storage.