CP-Hub uses Firebase for authentication, Firestore for user/event/leaderboard data, and (optionally) Firebase Storage for event images. Follow these one-time steps before running the app.
- Go to https://console.firebase.google.com and click Add project.
- Name it something like
cp-hub(the actual ID can differ). You can disable Google Analytics — it isn't needed. - Wait for the project to finish provisioning, then open it.
- On the project overview page click the
</>(Web) icon. - App nickname:
cp-hub-web. Skip Firebase Hosting for now. - Firebase shows a
firebaseConfigobject — keep this tab open, you'll paste these values in step 6.
- Left sidebar → Build → Authentication → Get started.
- Sign-in method tab → Email/Password → toggle Enable → Save.
- Left sidebar → Buildwe → Firestore Database → Create database.
- Choose Production mode.
- Pick a region near you (e.g.
asia-south1for India). This can't be changed later. - Click Enable.
- In Firestore, open the Rules tab.
- Replace the contents with the rules from
firestore.rulesat the repo root. - Click Publish.
- Left sidebar → Build → Storage → Get started.
- Production mode, same region as Firestore.
- ⚙ (Project settings) → Service accounts → Generate new private key → confirm.
- Save the downloaded JSON as
backend/serviceAccountKey.jsonin this repo. It's already gitignored — never commit it.
For deployments where you can't ship a JSON file (e.g. Vercel) base64-encode the file (
base64 -i serviceAccountKey.json | pbcopy) and setFIREBASE_SERVICE_ACCOUNT_B64instead of mounting the file.
Copy frontend/.env.example to frontend/.env.local, then fill in the values from step 2:
VITE_FIREBASE_API_KEY=...
VITE_FIREBASE_AUTH_DOMAIN=cp-hub.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=cp-hub
VITE_FIREBASE_STORAGE_BUCKET=cp-hub.appspot.com
VITE_FIREBASE_MESSAGING_SENDER_ID=...
VITE_FIREBASE_APP_ID=...
Create backend/.env:
PORT=3001
FIREBASE_SERVICE_ACCOUNT_PATH=./serviceAccountKey.json
# Or, for hosted environments:
# FIREBASE_SERVICE_ACCOUNT_B64=...
The very first admin has to be promoted manually — there's no UI bootstrap for it on purpose.
- Register a user normally through the website's
/registerpage. - Open the Firebase console → Firestore →
userscollection → click the doc whoseemailmatches you. - Edit the
rolefield fromuser→admin. Save.
You can now sign back in and the /admin/* pages will be visible.
# From repo root
cd frontend && npm install
cd ../backend && npm install
cd ..
npm run dev:backend # in one terminal
npm run dev:frontend # in anotherThat's it.