MGPC Web Fallback - Deployment Guide
This guide covers deploying both the HTML and React versions of the MGPC web fallback.
Quick Start
Option 1: HTML Version (Recommended for Quick Deploy)
- Upload HTML files to your website:
# Copy these files to your web server cp scoreboard.html /path/to/your/website/mgpc/ cp leaderboard.html /path/to/your/website/mgpc/ cp join.html /path/to/your/website/mgpc/ cp transfer.html /path/to/your/website/mgpc/ cp index.html /path/to/your/website/mgpc/
- Test the URLs:
https://mrajan.com.np/mgpc/scoreboard?gameId=ABC123
https://mrajan.com.np/mgpc/leaderboard?gameId=ABC123
Option 2: React Version (Recommended for Long-term)
- Build the React app:
cd react-app npm install npm run build
- Deploy the built files:
# The build output will be in ../dist/ cp -r dist/* /path/to/your/website/mgpc/
File Structure
mgpc/
├── index.html # Router page
├── join.html # Join game page
├── scoreboard.html # Live scoreboard
├── leaderboard.html # Live leaderboard
├── transfer.html # Transfer host page
├── README.md # Documentation
├── .gitignore # Git ignore rules
├── react-app/ # React version
│ ├── src/
│ ├── package.json
│ ├── vite.config.js
│ └── README.md
└── dist/ # Built React app (after build)
Firebase Configuration
Both versions use your existing Firebase project (mgpc-v3
):
- Collection:
mgpc-streaming-games
- Real-time updates: Uses
onSnapshot
listeners - API Key: Already configured in the code
URL Structure
The web fallback handles these URL patterns:
- Join Game:
https://mrajan.com.np/mgpc/join?gameId=ABC123
- Transfer Host:
https://mrajan.com.np/mgpc/transfer?code=XYZ789
- Scoreboard:
https://mrajan.com.np/mgpc/scoreboard?gameId=ABC123
- Leaderboard:
https://mrajan.com.np/mgpc/leaderboard?gameId=ABC123
Testing
- Generate QR code from your MGPC app
- Test on different devices:
- Device with app → Should open app
- Device without app → Should open web page
- Test different browsers → Should work consistently
Security Considerations
- Firebase API Key: Currently exposed in client-side code
- CORS: Ensure your Firebase project allows web requests
- Rate Limiting: Consider implementing rate limiting for production
Performance
- HTML Version: ~50KB per page
- React Version: ~200KB (gzipped) for initial load
- Firestore: Real-time updates with minimal bandwidth
Maintenance
HTML Version
- Edit HTML files directly
- No build process required
- Easy to update
React Version
- Edit components in
src/
- Run
npm run build
after changes - More maintainable for complex features
Troubleshooting
Common Issues
- “Game not found” error:
- Check if game ID is correct
- Verify game is still streaming
- Check Firebase connection
- “Connection error”:
- Check internet connection
- Verify Firebase configuration
- Check browser console for errors
- Styling issues:
- Ensure Poppins font is loaded
- Check CSS file paths
- Verify responsive design
Debug Mode
Add ?debug=true
to any URL to see console logs:
https://mrajan.com.np/mgpc/scoreboard?gameId=ABC123&debug=true
Updates
Updating HTML Version
- Edit the HTML files
- Upload to your web server
- Clear browser cache if needed
Updating React Version
- Edit components in
src/
- Run
npm run build
- Upload
dist/
contents to web server - Clear browser cache
Support
For issues or questions:
- Check the browser console for errors
- Verify Firebase connection
- Test with different game IDs
- Check network connectivity
Next Steps
- Deploy to production
- Test with real QR codes
- Monitor performance
- Gather user feedback
- Iterate and improve