Skip to content

11KAlYAN11/FirebaseBackend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Firebase To-Do List MVP

๐Ÿ“ŒNote: cd to Backend

A production-ready, end-to-end To-Do List application built entirely with Firebase (Backend-as-a-Service).

๐Ÿ“‹ Features

โœ… Core Features

  • Multi-Provider Authentication

    • Email & Password
    • Google Sign-In
    • GitHub Sign-In
    • Session persistence
    • Secure logout
  • User Management

    • User profile with metadata
    • Profile picture support
    • Provider tracking
    • Automatic user creation
  • To-Do Management

    • Create, Read, Update, Delete (CRUD)
    • Mark as completed
    • Real-time updates
    • User-specific data isolation
  • Security

    • Firestore Security Rules
    • Server-side data validation
    • User-specific access control
  • Real-time Sync

    • Instant updates across devices
    • Firestore listeners
    • Optimistic UI updates

๐ŸŽจ UI/UX

  • Clean, modern interface
  • Responsive design
  • Loading states
  • Error handling
  • Success notifications
  • Dark mode support

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Frontend (Vanilla JS)              โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  โ€ข Authentication UI                            โ”‚
โ”‚  โ€ข Dashboard                                    โ”‚
โ”‚  โ€ข To-Do Management                             โ”‚
โ”‚  โ€ข Real-time listeners                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Firebase Services                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  โ€ข Firebase Auth (Multi-provider)               โ”‚
โ”‚  โ€ข Firestore (NoSQL Database)                   โ”‚
โ”‚  โ€ข Security Rules (Server-side validation)      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“Š Data Model

Users Collection (users)

{
  uid: string,           // Firebase Auth UID
  name: string,          // Display name
  email: string,         // Email address
  photoURL: string,      // Profile picture URL
  provider: string,      // 'email' | 'google' | 'github'
  createdAt: timestamp,  // Account creation time
  updatedAt: timestamp   // Last update time
}

Todos Collection (todos)

{
  id: string,            // Auto-generated document ID
  title: string,         // To-do title
  description: string,   // Optional description
  status: string,        // 'pending' | 'completed'
  priority: string,      // 'low' | 'medium' | 'high' (optional)
  dueDate: timestamp,    // Optional due date
  ownerUID: string,      // User ID (for security)
  createdAt: timestamp,  // Creation time
  updatedAt: timestamp   // Last update time
}

๐Ÿ” Security Rules

Firestore Security Rules ensure:

  • Users can only read/write their own to-dos
  • User metadata is protected
  • All writes are validated server-side
  • No client-side security bypasses

๐Ÿš€ Setup Instructions

Prerequisites

  • Node.js (v14+)
  • npm or yarn
  • Firebase account
  • Git

Step 1: Firebase Project Setup

  1. Create Firebase Project

    • Go to Firebase Console
    • Click "Add project"
    • Enter project name: todo-list-mvp
    • Disable Google Analytics (optional for MVP)
    • Click "Create project"
  2. Enable Authentication Providers

    • Navigate to Authentication โ†’ Sign-in method
    • Enable Email/Password
    • Enable Google
    • Enable GitHub (requires OAuth app setup)
      • Go to GitHub Settings โ†’ Developer settings โ†’ OAuth Apps
      • Create new OAuth App
      • Copy Client ID and Secret to Firebase
  3. Create Firestore Database (optional)

    • Navigate to Firestore Database
    • Click "Create database"
    • Start in Test mode (we'll add rules later)
    • Choose a location (e.g., us-central1)
  4. Get Firebase Config

    • Go to Project Settings (gear icon)
    • Scroll to "Your apps"
    • Click web icon (</>)
    • Register app name: todo-web-app
    • Copy the Firebase configuration object

Step 2: Project Configuration

  1. Clone/Navigate to Project

    cd /home/pavan/javaPS/BackendDemo
  2. Create Firebase Config

    • Copy js/config/firebase.config.example.js to js/config/firebase.config.js
    • Paste your Firebase configuration:
    export const firebaseConfig = {
      apiKey: "YOUR_API_KEY",
      authDomain: "YOUR_PROJECT_ID.firebaseapp.com",
      projectId: "YOUR_PROJECT_ID",
      storageBucket: "YOUR_PROJECT_ID.appspot.com",
      messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
      appId: "YOUR_APP_ID"
    };
  3. Install Dependencies (Optional - for development server)

    npm install

Step 3: Deploy Security Rules (Optional)

  1. Install Firebase CLI

    npm install -g firebase-tools
  2. Login to Firebase

    firebase login
  3. Initialize Firebase

    firebase init firestore
    • Select your project
    • Use firestore.rules for rules
    • Use firestore.indexes.json for indexes
  4. Deploy Rules

    firebase deploy --only firestore:rules

Step 4: Run the Application

Option 1: Using Live Server (Recommended)

npm run dev

Open browser to http://localhost:8080

Option 2: Using Python

python3 -m http.server 8080

Option 3: Using Node.js

npx http-server -p 8080

Option 4: Using Firebase Hosting (Production)

firebase init hosting
firebase deploy --only hosting

๐Ÿ“ Project Structure

BackendDemo/
โ”œโ”€โ”€ index.html                 # Login/Signup page
โ”œโ”€โ”€ dashboard.html             # Main to-do dashboard
โ”œโ”€โ”€ package.json              # Dependencies
โ”œโ”€โ”€ firestore.rules           # Security rules
โ”œโ”€โ”€ firestore.indexes.json    # Firestore indexes
โ”œโ”€โ”€ firebase.json             # Firebase config
โ”œโ”€โ”€ .firebaserc              # Firebase project
โ”œโ”€โ”€ css/
โ”‚   โ”œโ”€โ”€ auth.css             # Authentication styles
โ”‚   โ”œโ”€โ”€ dashboard.css        # Dashboard styles
โ”‚   โ””โ”€โ”€ common.css           # Shared styles
โ”œโ”€โ”€ js/
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ”œโ”€โ”€ firebase.config.js         # Firebase config (gitignored)
โ”‚   โ”‚   โ””โ”€โ”€ firebase.config.example.js # Example config
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ”œโ”€โ”€ auth.service.js           # Authentication logic
โ”‚   โ”‚   โ”œโ”€โ”€ user.service.js           # User management
โ”‚   โ”‚   โ””โ”€โ”€ todo.service.js           # To-do CRUD operations
โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ”‚   โ”œโ”€โ”€ firebase.init.js          # Firebase initialization
โ”‚   โ”‚   โ”œโ”€โ”€ ui.utils.js               # UI helpers
โ”‚   โ”‚   โ””โ”€โ”€ validators.js             # Input validation
โ”‚   โ”œโ”€โ”€ auth.js                       # Auth page controller
โ”‚   โ””โ”€โ”€ dashboard.js                  # Dashboard controller
โ””โ”€โ”€ README.md                         # This file

๐ŸŽฎ Usage

Authentication

  1. Open the application
  2. Sign up with email/password or use Google/GitHub
  3. Automatically redirected to dashboard

Managing To-Dos

  1. Create: Click "Add To-Do" button
  2. Edit: Click on a to-do to edit
  3. Complete: Click checkbox to mark complete
  4. Delete: Click delete icon
  5. Filter: Use status filter (All/Pending/Completed)

Real-time Updates

  • Open the app in multiple tabs/devices
  • Changes sync instantly across all instances

๐Ÿ”’ Security Features

  • Authentication Required: All routes protected
  • User Isolation: Users can only access their own data
  • Server-side Validation: Firestore rules validate all operations
  • XSS Protection: Input sanitization
  • CSRF Protection: Firebase handles token management

๐Ÿ› Common Pitfalls & Solutions

Issue: "Missing or insufficient permissions"

Solution: Deploy Firestore security rules

firebase deploy --only firestore:rules

Issue: GitHub Sign-In not working

Solution:

  1. Create GitHub OAuth App
  2. Add credentials to Firebase Console
  3. Ensure callback URL matches Firebase auth domain

Issue: Real-time updates not working

Solution: Check Firestore listeners are properly attached and not detached prematurely

Issue: CORS errors

Solution: Use a proper web server (not file:// protocol)

๐Ÿš€ Future Enhancements

Phase 2

  • Due date reminders
  • Priority sorting
  • Search functionality
  • Tags/categories
  • Bulk operations

Phase 3

  • Collaborative to-dos
  • File attachments (Firebase Storage)
  • Email notifications (Cloud Functions)
  • Analytics dashboard

Phase 4

  • Mobile app (React Native/Flutter)
  • Offline support (better caching)
  • Export to PDF/CSV
  • Recurring tasks

๐Ÿ“š Tech Stack

  • Frontend: HTML5, CSS3, Vanilla JavaScript (ES6+)
  • Backend: Firebase (BaaS)
    • Firebase Authentication
    • Cloud Firestore
    • Firebase Hosting (optional)
  • Security: Firestore Security Rules
  • Real-time: Firestore listeners

๐Ÿค Contributing

This is an MVP project. To extend:

  1. Fork the repository
  2. Create a feature branch
  3. Implement your feature
  4. Test thoroughly
  5. Submit a pull request

๐Ÿ“„ License

MIT License - feel free to use for learning and production

๐Ÿ‘จโ€๐Ÿ’ป Author Kalyan Reddy

Built as a demonstration of Firebase BaaS capabilities


Happy Coding! ๐ŸŽ‰

Releases

No releases published

Packages

 
 
 

Contributors