Skip to content

mortada313s/competition-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ† Competition App

An interactive QR-based competition platform for events and companies

Report Bug ยท Request Feature

Maintained by Mortada Mohammed Abdulabbas โ€” Iraq ๐Ÿ‡ฎ๐Ÿ‡ถ


๐Ÿ“‹ Table of Contents


๐ŸŽฏ Overview

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

How it works

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” login + register โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Agent โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚ Registration UI โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ generates QR โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” scans QR code โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚Participantโ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚ Challenge Page โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ sends result โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” real-time update โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Admin โ”‚ โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”‚ Server โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜


โœจ Features

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

๐Ÿ“ Project Structure

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


โš™๏ธ Requirements

Requirement Version
Node.js >= 20.x
npm >= 10.x
Browser Chrome / Firefox / Safari

๐Ÿš€ Installation

1. Clone the repository

git clone https://github.com/mortada313s/competition-app.git
cd competition-app

2. Install dependencies

npm install

3. Set up the database

cp server/db.example.json server/db.json

4. Build the project

npm run build

5. Start the server

node server/index.cjs

6. Open the app

http://localhost:4000

Accessing from other devices on the same network: Find your IP with hostname -I, then open http://YOUR_IP:4000


๐Ÿ“– Usage Guide

๐Ÿ‘‘ Admin

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

๐Ÿ‘ค Agent

URL Description
/agent Agent login page

Workflow:

  1. Agent opens /agent on their device
  2. Enters their name and secret code assigned by the admin
  3. Registers a participant (name + password)
  4. A QR code is generated โ€” the participant scans it to start the challenge

๐ŸŽฎ Participant

  1. Scans the QR code with their phone camera
  2. Taps Start Challenge โ€” the timer begins
  3. Taps Stop at the target time
  4. Win on Challenge 1 โ†’ Prize 1 is awarded
  5. Lose on Challenge 1 โ†’ Moves to Challenge 2
  6. Win on Challenge 2 โ†’ Random prize (Prize A or B based on admin-set weights)
  7. Lose on Challenge 2 โ†’ No prize, game over
  8. Each QR code is valid for one use only

๐Ÿ”Œ API Reference

Authentication

Method Endpoint Description
POST /api/admin/login Admin login
POST /api/admin/update Update admin credentials
POST /api/agent/login Agent login

Data

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

Example Request

// 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' } }

๐Ÿ—„๏ธ Database Schema

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"
  }
}

๐Ÿ›ก๏ธ Security

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

๐Ÿ—บ๏ธ Roadmap

  • 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

๐Ÿ‘ค Author

Mortada Mohammed Abdulabbas


๐Ÿ“„ License

MIT License ยฉ 2026 Mortada Mohammed Abdulabbas


Built with โค๏ธ from Iraq ๐Ÿ‡ฎ๐Ÿ‡ถ โ€” Competition App 2026

About

๐Ÿ† Interactive QR-based competition platform for events and companies | React + Vite + Node.js

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors