Coder Social home page Coder Social logo

adimail / playbook Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 23.84 MB

Share memories of childhood games

Home Page: https://playbook-e0207.web.app/

License: Apache License 2.0

HTML 13.80% CSS 9.20% JavaScript 77.00%
firebase react webapplication

playbook's Introduction

Build Status

PlayBook : real-time-public-game-archive

PlayBook is a web application built using React, Bootstrap, and Firebase. It serves as a public archive and memory box where users can store and discuss games from their childhood. Firebase is used as BAAS for authentication, real-time database storage, and hosting.

Live application here

Features and use cases

  • User Authentication: Users can sign in using their Google account.
  • Game Archive: Store and explore games from childhood, including their names, descriptions, labels, and rules.
  • Discussion Panel: Engage in discussions with the community through a real-time discussion panel.
  • Discussion Panel for each game: We have an seperate discussion panel for each game.
  • Star games: Users can star the games they like as an endorsements.
  • Stickers: Send stickers in chat messages.

screenshots

login homepage discussions addgame game game

Run locally

Firebase Configuration

To configure Firebase, you need to create a firebaseConfig object. This object includes information such as API keys, authentication settings, and database details. Replace the placeholder config in src/config/firebase.js with your Firebase configuration.

import { initializeApp } from "firebase/app";
import { getAuth, GoogleAuthProvider } from "firebase/auth";
import { getFirestore } from "firebase/firestore";
import { getStorage } from "firebase/storage";

const firebaseConfig = {
  // Your config with firebase API keys
};

const app = initializeApp(firebaseConfig);
export const auth = getAuth(app);
export const googleProvider = new GoogleAuthProvider();

export const db = getFirestore(app);
export const storage = getStorage(app);

Performance

  • onSnapshot: listens for changes in the specified Firestore document or query, and it automatically updates the UI whenever there is a change in the data.
  • limit: When you have a large collection of data, using limit allows you to retrieve only a specific number of records. This reduces the amount of data transferred over the network, making your queries more efficient.
  • read & write rules: The Cloud Firestore security rules you provided are written in the Firebase security rules language. This set of rules grants read and write access to any document in the Firestore database only if the request is authenticated (i.e., request.auth != null).

Debouncing

Debouncing is used to ensure that time-consuming tasks do not fire so often, making them more efficient. Useful when dealing with user input.

When a debounced function is called, it sets up a timer. If the function is called again before the timer runs out, the timer is reset. This way, the function will only be executed if there is a pause in the calls. It prevents rapid firing of the function, optimizing performance.

import React, { useState, useEffect } from "react";

const debounce = (func, delay) => {
  let timeoutId;
  return function (...args) {
    if (timeoutId) {
      clearTimeout(timeoutId);
    }
    timeoutId = setTimeout(() => {
      func.apply(this, args);
    }, delay);
  };
};

function MyComponent() {
  const [inputValue, setInputValue] = useState("");

  // Debounce the API call function
  const debouncedAPICall = debounce(async (value) => {
    // Perform API call with the input value
    console.log("API call with value:", value);
  }, 300); // Set an appropriate debounce delay (e.g., 300 milliseconds)

  useEffect(() => {
    // Call the debounced function on input change
    debouncedAPICall(inputValue);
  }, [inputValue, debouncedAPICall]);

  return (
    <input
      type="text"
      value={inputValue}
      onChange={(e) => setInputValue(e.target.value)}
    />
  );
}

Firestore rules:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.auth != null;
    }
  }
}

Firebase Firestore Limits

Free Tier Quota
Stored data 1 GiB
Document reads 50,000 per day
Document writes 20,000 per day
Document deletes 20,000 per day
Outbound data transfer 10 GiB per month

Firebase documentation

playbook's People

Contributors

adimail avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.