A simple, modern web application that demonstrates Firebase authentication with Google sign-in. The app features a clean, responsive interface with a gradient background and smooth animations. Deployed on Firebase Hosting with free tier optimization.
- Google Authentication via Firebase Auth
- Responsive design with modern CSS
- Real-time authentication state management
- Clean, minimal user interface
- Firebase configuration validation
- Graceful profile picture fallback (default avatar for missing/failed photos)
- Asset pipeline for reusable resources
- Firebase Hosting with optimized caching and security headers
- Preview channel deployments for testing
- Vanilla HTML/CSS/JavaScript (ES6 modules)
- Firebase SDK (Authentication)
- Firebase Hosting (Static site hosting with CDN)
- Google OAuth integration
- Modular architecture for scalability
This project supports both local development and remote hosting on Firebase.
- Node.js (for package management and build process)
- Firebase CLI (
npm install -g firebase-tools) - Modern web browser
Use local development for testing changes before deploying.
-
Install dependencies:
npm install
-
Build and start local development server:
npm run dev
This will build the project and start the server at
http://localhost:3000 -
Alternative - Manual build and serve:
npm run build npx http-server public -p 3000
npm run dev- Build project and start development server athttp://localhost:3000npm run build- Full build (runs asset pipeline + environment injection)npm run build:assets- Copy static assets fromsrc/assets/topublic/assets/npm run build:env- Inject environment variables and copy JS modules topublic/js/npm run clean- Remove built files (public/js/andpublic/assets/)
Deploy your application to Firebase Hosting for production use.
The project is configured for Firebase Hosting with:
- Project ID:
base-website-dee90(configured in.firebaserc) - Hosting Config:
firebase.json(caching, security headers, routing) - Public URL:
https://base-website-dee90.web.app
-
Firebase CLI Login:
firebase login
-
Verify Project Connection:
firebase projects:list firebase use base-website-dee90
Production Deployment:
npm run deployBuilds the project and deploys to production (https://base-website-dee90.web.app)
Preview Channel Deployment (Testing):
npm run deploy:previewDeploys to a temporary preview URL (expires in 7 days) for testing before production.
Open Live Site:
npm run firebase:openOpens your deployed site in the browser.
-
Test Locally:
npm run dev # Test at http://localhost:3000 -
Deploy to Preview (Optional):
npm run deploy:preview # Test at preview URL before production -
Deploy to Production:
npm run deploy # Live at https://base-website-dee90.web.app
- Global CDN: Fast load times worldwide
- Free SSL: Automatic HTTPS certificates
- Optimized Caching:
- Static assets (JS/CSS/images): 1 year cache
- HTML files: 1 hour cache with revalidation
- Security Headers: XSS protection, clickjacking prevention
- SPA Routing: All routes serve
index.htmlfor single-page app behavior - Preview Channels: Test deployments before going live (auto-expire after 7 days)
- Storage: 10 GB
- Bandwidth: 360 MB/day (~11 GB/month)
- Build Time: Handled locally (no server-side builds)
- Custom Domains: 1 domain per project
The app uses Firebase Authentication with Google sign-in. Configuration is stored in:
- Source:
src/js/firebase-config.js(template with placeholders) - Environment:
.env(actual Firebase config values) - Runtime: Environment variables injected during build via
scripts/inject-env.js
Firebase Hosting configuration:
- Project:
.firebaserc(Firebase project ID) - Hosting Rules:
firebase.json(deployment config, caching, security headers) - Public Directory:
public/(built files deployed to Firebase)
- Authentication: Google sign-in provider must be enabled
- Authorized Domains: Automatically configured for
*.web.appand*.firebaseapp.com - Support Email: Required for Google OAuth (set in Firebase Console)
├── public/ # Served directory (deployed to Firebase)
│ ├── index.html # Main HTML file
│ ├── js/ # Built JavaScript (generated by build:env)
│ │ ├── modules/
│ │ │ ├── auth.js # Authentication module
│ │ │ ├── firebase-config.js # Firebase configuration (env injected)
│ │ │ └── ui.js # UI utilities module
│ │ └── main.js # Application entry point
│ └── assets/ # Built static assets (generated by build:assets)
│ └── images/
│ └── placeholders/
│ └── default-avatar.svg # Default user avatar fallback
│
├── src/ # Source files
│ ├── js/ # JavaScript source
│ │ ├── modules/
│ │ │ ├── auth.js # Authentication module (source)
│ │ │ └── ui.js # UI utilities module (source)
│ │ ├── firebase-config.js # Firebase configuration (template)
│ │ └── main.js # Application entry point (source)
│ └── assets/ # Static assets (source)
│ └── images/
│ └── placeholders/
│ ├── default-avatar.svg # Default user avatar
│ └── README.md # Asset documentation
│
├── scripts/
│ ├── build-assets.js # Asset pipeline script
│ └── inject-env.js # Environment injection script
│
├── .prompts/ # Development guidance
│ ├── asset-reusability.md # Asset management patterns
│ ├── code-structure.md # Architecture patterns
│ ├── firebase-best-practices.md # Firebase patterns
│ ├── deployment-cicd.md # Deployment strategies
│ └── ... (other guidance files)
│
├── firebase.json # Firebase Hosting configuration
├── .firebaserc # Firebase project ID
├── .env # Environment variables (not committed)
├── .env.example # Environment variables template
├── CLAUDE.md # Claude Code development guide
├── package.json # Dependencies and build scripts
└── README.md # Project documentation
The project uses a two-stage build process:
Copies static resources from src/assets/ to public/assets/:
- Images (SVG, PNG, JPG)
- Icons and placeholders
- Future: fonts, data files, etc.
Example: src/assets/images/placeholders/default-avatar.svg → public/assets/images/placeholders/default-avatar.svg
Processes JavaScript modules with environment variable injection:
- Copies JS files from
src/js/topublic/js/ - Injects Firebase configuration
- Maintains module structure
Running npm run build executes both stages in order:
build:assets- Ensures all static assets are availablebuild:env- Ensures all JavaScript modules are processed
The application uses a modular architecture designed for incremental feature development:
src/js/modules/auth.js- Authentication logic and Firebase Auth integrationsrc/js/modules/ui.js- DOM manipulation and UI state managementsrc/js/modules/firebase.js- Firebase configuration and validationsrc/js/main.js- Application orchestrator that initializes all modules
src/assets/images/placeholders/- Reusable fallback images (avatars, thumbnails, error states)- Assets are referenced by application code via
/assets/path - Documented in individual README files within asset directories
This structure allows easy addition of new features by creating additional modules (e.g., database.js, storage.js) or assets (icons, illustrations) without modifying existing code.
To add new static assets (images, icons, fonts, etc.):
-
Create asset in source directory:
# Example: Adding a new placeholder src/assets/images/placeholders/default-thumbnail.svg -
Document the asset: Update
src/assets/images/placeholders/README.mdwith:- Asset purpose
- Where it's used
- Dimensions/specifications
-
Reference in code:
// Use the /assets/ path (will be available after build) this.thumbnail.src = '/assets/images/placeholders/default-thumbnail.svg';
-
Build the project:
npm run build:assets # or npm run build
The asset will be automatically copied to public/assets/ and available to your application.
- User clicks "Sign in with Google"
- Firebase initiates OAuth flow
- Upon success, user information is displayed (with profile picture or default avatar)
- Authentication state persists across sessions