Minimal Firebase-hosted backend API has been added using Cloud Functions + Express.
The backend runs on Firebase Cloud Functions (serverless), not on the frontend client.
-
Frontend calls HTTPS endpoints
-
Cloud Functions reads/writes Firestore + Firebase Auth
-
Raspberry Pi device continues using Firestore commands + session/live writes
Base URL after deploy:
https://<region>-<project-id>.cloudfunctions.net/api
Endpoints:
-
GET /health -
POST /startbody:{ "deviceId": "..." } -
POST /endbody:{ "deviceId": "..." } -
POST /create-userbody:{ "email": "...", "password": "...", "displayName": "..." } -
POST /sign-upbody: same as create-user -
POST /loginbody:{ "email": "...", "password": "..." } -
GET /getAllSessionInfo/:userId -
GET /sessionInfo/:sessionId -
GET /live?sessionId=<id>&limit=200 -
GET /live/current?deviceId=<id> -
PATCH /sessionInfo/:sessionIdbody:{ "description": "...", "comments": ["..."] }
Full request/response contracts are documented in docs/api-contracts.md.
For hackathon/demo prep, use the backend seeder to create a demo login and patterned historical sessions:
npm --prefix functions run seed:demo -- --reset
Detailed guide and flags are in docs/demo-data-seeder.md.
-
functions/index.js(Express routes) -
functions/package.json -
firebase.json -
.firebaserc
From EngageMint/:
-
Install Firebase CLI (if not installed):
npm i -g firebase-tools -
Login:
firebase login -
Install function deps:
npm --prefix functions install -
Set login API key (needed for
/login):-
Emulator/local: export env var before run
-
Deploy:
firebase functions:secrets:set FIREBASE_WEB_API_KEY
-
-
Deploy:
firebase deploy --only functions
From EngageMint/:
-
npm --prefix functions install -
firebase emulators:start --only functions
Local base URL:
http://127.0.0.1:5001/<project-id>/us-central1/api
Per request, this is a minimal no-auth middleware API for now.
If you want, next iteration can add token verification and role-based access with minimal route changes.