Spaces:
Running
Running
metadata
title: Egg Catcher
emoji: π₯
colorFrom: yellow
colorTo: red
sdk: docker
app_port: 8080
pinned: false
short_description: Pixel-art arcade β phone is the controller
egg-catcher
Pixel-art egg-catcher arcade. Laptop = main screen with a QR pop-up; phone = controller. MongoDB-backed global leaderboard.
The frontmatter above is for Hugging Face Spaces β it's ignored on GitHub.
Run locally
npm install
npm run dev
http://localhost:5173/ on the laptop. Phone scans the QR (same wifi).
.env (gitignored) needs:
MONGO_URI=mongodb+srv://...
MONGO_DB=news
MONGO_COLLECTION=egg_catcher_scores
Deploy β backend on HF Space, frontend on Vercel
1. Backend on Hugging Face
- Go to https://huggingface.co/new-space
- Owner: your account Β· Space name: e.g.
egg-catcher-apiΒ· License: MIT Β· Space SDK: pick Docker β Blank - Hardware: CPU basic β free
- Create. Then in the Space, Settings β Variables and secrets β add a Secret named
MONGO_URIwith your full Mongo connection string - Settings β Repository β Connect to a GitHub repository β pick
ABHINAY2025/egg-catcher. Every push tomainwill rebuild the Space - The Space will build and come up at
https://<username>-<spacename>.hf.space
2. Frontend on Vercel
- Go to https://vercel.com/new
- Import
ABHINAY2025/egg-catcher - Framework Preset: Vite (auto-detected)
- Environment Variables: add
VITE_API_BASE=https://<your-hf-space-url>(no trailing slash, e.g.https://abhinay-egg-catcher-api.hf.space) - Deploy. Your game lives at
https://<project>.vercel.app
Why split?
- Vercel gives CDN-fast static delivery + instant SPA routing.
- HF Space stays warm with no card required and supports long-lived SSE for the phone-controller pairing.
- Frontend and backend are decoupled β swap either independently.
How it works
- Single Express server: serves
/api/*and (in monolithic deploy) the built Vite frontend. - Game rooms are in-memory; SSE relays controller events laptop β phone.
/api/score,/api/leaderboardwrite to MongoDB collectionegg_catcher_scores.- Controller URL in prod =
${window.location.origin}/controller?room=XXXXXX(the frontend's URL, not the API).