- Overview
- Features
- Project Structure
- Requirements
- Installation
- Usage Guide
- API Reference
- Database Schema
- Security
- Roadmap
- Author
A real-time interactive competition platform that allows agents to register participants and generate unique QR codes, while the admin monitors everything live from a fully-featured dashboard. Admin controls settings โโโบ Agent registers participants โโโบ Participant scans QR โโโบ Challenge begins
โโโโโโโโโโโโโ login + register โโโโโโโโโโโโโโโโโโโโ โ Agent โ โโโโโโโโโโโโโโโโโโโบ โ Registration UI โ โโโโโโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโโ โ generates QR โผ โโโโโโโโโโโโโ scans QR code โโโโโโโโโโโโโโโโโโโโ โParticipantโ โโโโโโโโโโโโโโโโโโโบ โ Challenge Page โ โโโโโโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโโ โ sends result โผ โโโโโโโโโโโโโ real-time update โโโโโโโโโโโโโโโโโโโโ โ Admin โ โโโโโโโโโโโโโโโโโโโ โ Server โ โโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
| Feature | Description |
|---|---|
| ๐ Auth System | Separate accounts for admin and agents |
| ๐ฑ Unique QR Codes | Every participant gets a personal QR code |
| โฑ๏ธ Interactive Timer | Circular animated stopwatch in seconds |
| ๐ Prize System | First prize + two secondary prizes with configurable probability weights |
| ๐ Live Dashboard | Stats that refresh every 5 seconds |
| ๐ข Company Branding | Upload logo + custom welcome message |
| ๐ก๏ธ QR Protection | Each QR code can only be used once |
| ๐๏ธ Result Management | Delete individual results or clear all records |
competition-app/ โ โโโ ๐ src/ # Frontend source code โ โโโ ๐ main.jsx # Entry point โ โโโ ๐ App.jsx # Router & routes โ โโโ ๐ index.css # Global styles & design tokens โ โ โ โโโ ๐ pages/ โ โ โโโ ๐ AgentPage.jsx # Agent login + QR generation โ โ โโโ ๐ ChallengePage.jsx # Participant challenge screen โ โ โโโ ๐ AdminLogin.jsx # Admin login โ โ โโโ ๐ AdminDashboard.jsx # Full admin control panel โ โ โ โโโ ๐ components/ โ โ โโโ ๐ ProtectedRoute.jsx # Route guard for admin pages โ โ โ โโโ ๐ utils/ โ โโโ ๐ api.js # Server communication functions โ โโโ ๐ server/ โ โโโ ๐ index.cjs # Node.js HTTP server โ โโโ ๐ db.json # JSON database (auto-created) โ โโโ ๐ db.example.json # Database template โ โโโ ๐ uploads/ # Uploaded logo images โ โโโ ๐ dist/ # Production build output โโโ ๐ .gitignore โโโ ๐ CHANGELOG.md โโโ ๐ CONTRIBUTING.md โโโ ๐ LICENSE โโโ ๐ README.md โโโ ๐ SECURITY.md โโโ ๐ package.json โโโ ๐ vite.config.js
| Requirement | Version |
|---|---|
| Node.js | >= 20.x |
| npm | >= 10.x |
| Browser | Chrome / Firefox / Safari |
git clone https://github.com/mortada313s/competition-app.git
cd competition-appnpm installcp server/db.example.json server/db.jsonnpm run buildnode server/index.cjsAccessing from other devices on the same network: Find your IP with
hostname -I, then openhttp://YOUR_IP:4000
| URL | Description |
|---|---|
/admin |
Admin login page |
/admin/dashboard |
Full control panel |
Default credentials: Username: admin Password: admin1234
โ ๏ธ Change your password immediately after first login from the Account tab.
Admin capabilities:
- Create agents and assign secret codes
- Configure challenge timers (Challenge 1 & 2)
- Set prizes and probability weights for secondary prizes
- Upload company logo and write a custom welcome message
- Monitor all results in real time
- Delete individual results or clear the entire log
- Update admin username and password
| URL | Description |
|---|---|
/agent |
Agent login page |
Workflow:
- Agent opens
/agenton their device - Enters their name and secret code assigned by the admin
- Registers a participant (name + password)
- A QR code is generated โ the participant scans it to start the challenge
- Scans the QR code with their phone camera
- Taps Start Challenge โ the timer begins
- Taps Stop at the target time
- Win on Challenge 1 โ Prize 1 is awarded
- Lose on Challenge 1 โ Moves to Challenge 2
- Win on Challenge 2 โ Random prize (Prize A or B based on admin-set weights)
- Lose on Challenge 2 โ No prize, game over
- Each QR code is valid for one use only
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/admin/login |
Admin login |
POST |
/api/admin/update |
Update admin credentials |
POST |
/api/agent/login |
Agent login |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/db |
Fetch all data |
GET |
/api/check/:token |
Check if QR token has been used |
POST |
/api/participant |
Register a new participant |
POST |
/api/result |
Save a challenge result |
POST |
/api/config |
Save competition settings |
POST |
/api/agents |
Update agents list |
POST |
/api/branding |
Update company branding |
DELETE |
/api/results/:index |
Delete a specific result |
DELETE |
/api/results/all |
Delete all results |
// Agent login
const res = await fetch('/api/agent/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: 'Ahmed', code: '1234' })
})
const data = await res.json()
// { ok: true, agent: { id: 'ahmed-abc123', name: 'Ahmed' } }All data is stored in server/db.json:
{
"admin": {
"name": "admin",
"pass": "admin1234"
},
"agents": [
{
"id": "ahmed-abc123",
"name": "Ahmed",
"code": "1234",
"createdAt": 1234567890
}
],
"participants": {
"TOKEN_ID": {
"name": "Mohammed",
"agentId": "ahmed-abc123",
"timestamp": 1234567890
}
},
"results": [
{
"name": "Mohammed",
"token": "TOKEN_ID",
"prize": "iPhone 15",
"challenge": 1,
"timestamp": 1234567890
}
],
"config": {
"target1": 7.0,
"target2": 4.0,
"max1": 10,
"max2": 10,
"prize1": "First Prize",
"prizeA": "Prize A",
"prizeB": "Prize B",
"prizeAWeight": 70
},
"branding": {
"companyName": "Our Travel Company",
"welcome": "Welcome to our competition!",
"logoUrl": "/uploads/logo.png"
}
}| Aspect | Current | Recommended for Production |
|---|---|---|
| Admin auth | Plain text in JSON | JWT + bcrypt |
| Agent auth | Plain text code | bcrypt hash |
| Database | JSON file | PostgreSQL / MongoDB |
| HTTPS | โ | โ Required |
| Rate Limiting | โ | โ Required |
| Input Validation | Basic | Full server-side validation |
- Password hashing with bcrypt
- JWT session management
- Real database (PostgreSQL or MongoDB)
- Deploy to the internet (Railway / Render)
- Mobile app (React Native / Expo)
- Real-time updates via WebSocket
- Export results to Excel / PDF
- Multi-competition support
- Analytics charts in dashboard
Mortada Mohammed Abdulabbas
- GitHub: @mortada313s
- Location: Iraq ๐ฎ๐ถ
MIT License ยฉ 2026 Mortada Mohammed Abdulabbas