Skip to content

This project contains Firebase Cloud Functions to support a real-time cricket scoring web application using Firestore. It processes ball-by-ball data and updates match state documents such as live scores, batting and bowling summaries, and innings info.

License

Notifications You must be signed in to change notification settings

webteam-mcg/lq-score-functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏏 Cricket Score Firebase Cloud Functions

This project contains Firebase Cloud Functions to support a real-time cricket scoring web application using Firestore. It processes ball-by-ball data and updates match state documents such as live scores, batting and bowling summaries, and innings info.

πŸ“ Project Structure

cricket-score-functions/
β”œβ”€β”€ firebase.json        # Firebase configuration (emulators, deploy targets, etc.)
β”œβ”€β”€ .firebaserc          # Project alias and default Firebase project
└── functions/           
    β”œβ”€β”€ package.json     # NPM dependencies and scripts
    β”œβ”€β”€ tsconfig.json    # TypeScript compiler settings
    β”œβ”€β”€ src/
    β”‚   └── index.ts     # Main entry for cloud functions
    └── lib/             # Compiled JS output (auto-generated)

πŸš€ Setup Instructions

1. Prerequisites

2. Clone and Install

git clone https://github.com/your-username/cricket-score-functions.git
cd cricket-score-functions/functions
yarn install   # or npm install

3. Development

Run Firebase emulators locally:

firebase emulators:start

Compile TypeScript in watch mode:

yarn run build:watch   # or npm run build:watch

You can edit src/index.ts β€” compiled code appears in lib/.


4. Deploy

To deploy functions to your Firebase project:

firebase deploy --only functions

πŸ”₯ Function Overview

Your Cloud Functions listen to writes/updates/deletes on:

  • /feed/{id} β€” each ball in the match
    • On create: processes the ball and updates game state
    • On update/delete: recalculates totals and cleans up affected documents

And update:

  • /main/live β€” live match summary
  • /batting β€” current batting lineup with stats
  • /bowling/{id} β€” current bowling stats
  • /inning β€” track innings progression and scores

πŸ› οΈ Scripts

Script Description
build Compiles TypeScript β†’ JS
build:watch Watch mode for development
deploy Deploys functions to Firebase
emulators Starts local emulator suite

You can add these to package.json:

"scripts": {
  "build": "tsc",
  "build:watch": "tsc --watch",
  "deploy": "firebase deploy --only functions",
  "emulators": "firebase emulators:start"
}

About

This project contains Firebase Cloud Functions to support a real-time cricket scoring web application using Firestore. It processes ball-by-ball data and updates match state documents such as live scores, batting and bowling summaries, and innings info.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published