This project is a complete Rubik's Cube competition system with the following features:
- Secure QR code generation for administrators
- Automatic time validation via QR code
- Real-time leaderboard with positions
- Admin session management with automatic expiration
- Admin authentication system by email
- Modern user interface with React and Tailwind CSS
- Strict admin email validation (whitelist)
- QR codes with expiration (24h)
- Traceable sessions with unique IDs
- CORS protection configured
- Secure environment variables
- Modern and responsive user interface
- Integrated QR code scanner
- Precise timer management
- Real-time leaderboard
- Automatic proxy to backend
- Complete REST API
- PostgreSQL database
- Automatic email sending
- QR code generation
- Secure validation
- Unique QR code generation per email
- Automatic email sending with attachment
- Active session management
- Competition data cleanup
- Authorized email whitelist
- Precise timers for different cube categories
- Automatic participant ID generation
- Admin QR code validation
- Automatic time saving
- Times sorted in ascending order
- Automatic positions
- Filtering by session or admin
- Complete performance history
- Gmail configuration with App Passwords
- Automatic QR code sending
- Custom HTML templates
- Complete error handling
- Node.js (v16+ recommended)
- PostgreSQL (v13+ recommended)
- Gmail account for sending emails
cd backend
npm installcd frontend
npm installTerminal 1 - Backend:
cd backend
npm startโ
Backend running on http://localhost:5000
Terminal 2 - Frontend:
cd frontend
npm run devโ
Frontend running on http://localhost:5173
- Access the admin panel via the "ADMIN PANEL" button
- Enter your authorized email
- Receive the QR code by email automatically
- Scan the QR code when validating times
- Select the cube type
- Generate a participant ID
- Complete the solve with the timer
- Wait for admin validation via QR code
- Email whitelist in
ADMIN_EMAILS - Automatic validation before QR code generation
- Protection against unauthorized access
- Automatic expiration after 24 hours
- Unique session IDs for traceability
- Encrypted data in the QR code
- Environment variables for passwords
- CORS configured to prevent attacks
- Server-side data validation
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/admin/generate-qr |
Generate and send a QR code |
POST |
/api/admin/validate-qr |
Validate a time with QR code |
GET |
/api/admin/leaderboard |
Retrieve the leaderboard |
POST |
/api/admin/clear-records |
Clear the data |
GET |
/api/admin/sessions/:adminEmail |
Active sessions of an admin |
GET |
/api/admin/admin-emails |
List of authorized admin emails |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/auth/register |
User registration |
POST |
/api/auth/login |
User login |
rubiks-cube-competition/
โโโ ๐ backend/
โ โโโ ๐ .env # Environment variables
โ โโโ ๐ .gitignore # Files to ignore
โ โโโ ๐ server.js # Main server
โ โโโ ๐ src/
โ โ โโโ ๐ controllers/
โ โ โ โโโ ๐ adminController.js # Admin logic
โ โ โ โโโ ๐ authController.js # Authentication
โ โ โโโ ๐ models/
โ โ โ โโโ ๐ QRSession.js # QR session model
โ โ โ โโโ ๐ Leaderboard.js # Leaderboard model
โ โ โ โโโ ๐ User.js # User model
โ โ โโโ ๐ routes/
โ โ โโโ ๐ admin.js # Admin routes
โ โ โโโ ๐ auth.js # Auth routes
โ โโโ ๐ package.json
โ
โโโ ๐ frontend/
โ โโโ ๐ index.html
โ โโโ ๐ package.json
โ โโโ ๐ vite.config.js # Configuration with proxy
โ โโโ ๐ src/
โ โ โโโ ๐ components/
โ โ โ โโโ ๐ QRScanner.jsx # QR scanner
โ โ โ โโโ ๐ Timer.jsx # Timer
โ โ โ โโโ ๐ Leaderboard.jsx # Leaderboard
โ โ โ โโโ ๐ Admin.jsx # Admin panel
โ โ โโโ ๐ config/
โ โ โ โโโ ๐ api.js # API configuration
โ โ โโโ ๐ pages/
โ โ โโโ ๐ Index.jsx # Main page
โ โ โโโ ๐ Admin.jsx # Admin page
โ โโโ ๐ public/
โ
โโโ ๐ README.md # This documentation
- Allow camera access in the browser
- Use HTTPS in production
- Check lighting for scanning
# Check if backend is running
curl http://localhost:5000/api/test
# Check proxy configuration
cat frontend/vite.config.js# Check PostgreSQL connection
cd backend && node -e "console.log('DB test')"# Backend logs
cd backend && npm start
# With more details
DEBUG=* npm startnpm start # Start the server
npm run dev # Development with nodemon
npm test # Testsnpm run dev # Start development
npm run build # Build production
npm run preview # Preview productionThis system provides a complete and secure solution for organizing Rubik's Cube competitions with:
โ Automatic QR code generation โ Secure time validation โ Real-time leaderboard โ Modern user interface โ Enhanced security โ Simple configuration
The system is production-ready and can be deployed immediately! ๐