Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

18 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฌ AMPS CINEquiz

A live, real-time cinema quiz competition platform built for events with large audiences. Participants join on their phones, answer movie-clue questions each round, and the system automatically eliminates wrong/slow answers โ€” progressively narrowing down to finalists. A projector screen shows live results to the audience.


๐Ÿ“ธ Project Flow

Participants (phones)          Admin Panel                  Projector Screen
      โ”‚                             โ”‚                              โ”‚
      โ”‚  Register with Roll No.     โ”‚                              โ”‚
      โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€>โ”‚                              โ”‚
      โ”‚                             โ”‚  Create Round                โ”‚
      โ”‚                             โ”‚  (set emoji clue,            โ”‚
      โ”‚                             โ”‚   correct answers,           โ”‚
      โ”‚                             โ”‚   time limit)                โ”‚
      โ”‚  Receive clue + timer       โ”‚                              โ”‚
      โ”‚<โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚
      โ”‚                             โ”‚                              โ”‚  Shows: emoji clue
      โ”‚  Submit answer option       โ”‚                              โ”‚          + timer
      โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€>โ”‚                              โ”‚          + submission count
      โ”‚                             โ”‚  End Round                   โ”‚
      โ”‚                             โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚
      โ”‚  Receive: Qualified โœ…      โ”‚                              โ”‚  Shows: โœ… Qualified list
      โ”‚        or Eliminated โŒ     โ”‚                              โ”‚          โŒ Eliminated list
      โ”‚                             โ”‚  Repeat for next round       โ”‚
      โ”‚                             โ”‚  (up to 4 rounds)            โ”‚
      โ”‚                             โ”‚                              โ”‚
      โ”‚                    FINALISTS REVEALED                      โ”‚  ๐ŸŽ‰ Finalist roll numbers

๐Ÿ—๏ธ Tech Stack

Layer Technology
Frontend React + TypeScript + Vite + TailwindCSS
Backend Node.js + Express + TypeScript
Real-time Socket.IO (WebSockets)
Database SQLite (via node:sqlite)
Auth JWT (admin) + session tokens (participants)
Package Manager pnpm (monorepo workspace)

๐Ÿ“ Project Structure

โ”œโ”€โ”€ artifacts/
โ”‚   โ”œโ”€โ”€ api-server/          # Backend Express + Socket.IO server
โ”‚   โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ database/    # SQLite setup, schema, seed data
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ middleware/  # JWT auth middleware
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ routes/      # REST API routes
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ services/    # Business logic
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ eliminationService.ts  โ† elimination logic
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ socketService.ts       โ† real-time events
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ timerService.ts        โ† round timer
โ”‚   โ”‚   โ””โ”€โ”€ cinequiz.db      # SQLite database (auto-created, gitignored)
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ cinequiz/            # Frontend React app
โ”‚       โ”œโ”€โ”€ src/
โ”‚       โ”‚   โ”œโ”€โ”€ pages/
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ Landing.tsx            โ† Participant registration
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ Projector.tsx          โ† Big screen display
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ AdminLogin.tsx         โ† Admin sign-in
โ”‚       โ”‚   โ”‚   โ””โ”€โ”€ AdminDashboard.tsx     โ† Admin control panel
โ”‚       โ”‚   โ”‚       admin-tabs/
โ”‚       โ”‚   โ”‚           โ”œโ”€โ”€ SetupTab.tsx   โ† Create/manage rounds
โ”‚       โ”‚   โ”‚           โ”œโ”€โ”€ LiveTab.tsx    โ† Start/end rounds live
โ”‚       โ”‚   โ”‚           โ””โ”€โ”€ ParticipantsTab.tsx
โ”‚       โ”‚   โ””โ”€โ”€ hooks/
โ”‚       โ”‚       โ””โ”€โ”€ useSocket.ts           โ† Socket.IO client hook
โ”‚       โ”œโ”€โ”€ load-test.mjs    โ† Bot simulator for load testing
โ”‚       โ””โ”€โ”€ vite.config.local.ts  โ† Local dev config (no env vars needed)

๐Ÿš€ Running Locally

Prerequisites

  • Node.js v18+
  • pnpm (npm install -g pnpm)

1. Install dependencies

pnpm install

2. Start the API server (port 3000)

cd artifacts/api-server
npm run dev
# If it asks for PORT:
$env:PORT=3000; node --enable-source-maps ./dist/index.mjs

3. Start the frontend (port 5173)

cd artifacts/cinequiz
npm run dev -- --config vite.config.local.ts

4. Open in browser

URL Purpose
http://localhost:5173/ Participant registration page
http://localhost:5173/admin/login Admin control panel
http://localhost:5173/projector Big screen / projector display

๐Ÿ” Default Admin Credentials

Field Value
Username *******
Password ********

โš ๏ธ Change these before any real event โ€” see Customization below.


๐ŸŽฎ How to Run a Competition

  1. Admin logs in โ†’ http://localhost:5173/admin/login
  2. Participants register on http://localhost:5173/ with their roll number
  3. Open Projector on the big screen: http://localhost:5173/projector
  4. Admin โ†’ Setup tab โ†’ Create a round (set emoji clue, correct answers, time limit)
  5. Admin โ†’ Live tab โ†’ Click Start Round
    • Projector shows the emoji clue + countdown timer
    • Participants see the question on their phones
  6. Participants submit answers before time runs out
  7. Admin โ†’ Click End Round
    • System auto-eliminates based on: wrong answers first, then slowest correct
    • Projector shows two columns: โœ… Qualified and โŒ Eliminated
  8. Repeat for up to 4 rounds
  9. Final round โ†’ Finalists revealed with confetti on the projector ๐ŸŽ‰

๐Ÿค– Load Testing with Bots

Simulate multiple participants for testing:

cd artifacts/cinequiz

# Spawn 20 bots (resets competition to 'waiting' first)
node load-test.mjs 20 --reset

# Spawn 50 bots
node load-test.mjs 50 --reset

# Spawn 100 bots
node load-test.mjs 100 --reset

Each run generates a unique run ID so bot roll numbers never clash across runs (e.g. B472P001, B472P002...).


โš™๏ธ Elimination Logic

Each round, participants are ranked by:

  1. Correctness โ€” wrong answers are eliminated first
  2. Response time โ€” among correct answers, slower responses are eliminated
Round % that advance
Round 1 40% (of correct answerers)
Round 2 30%
Round 3 25%
Round 4 Top 2 โ†’ Finalists

Key rule: Wrong answers always eliminate regardless of how few participants remain.
If everyone gets it wrong, 1 person advances (to avoid a deadlock).


๐Ÿ› ๏ธ Customization

Change the competition name

File: artifacts/api-server/src/database/db.ts

// Line ~52 โ€” change "CineQuiz Fest 2024" to your event name
compId, "CineQuiz Fest 2024", "waiting", 0
//      โ†‘ Change this

Note: Delete cinequiz.db and restart the server to apply (it re-seeds on fresh DB).

Change admin username & password

File: artifacts/api-server/src/database/db.ts

const passwordHash = bcrypt.hashSync("cinequiz2024", 10);  // โ† change password
db.prepare(...).run(adminId, "admin", passwordHash);        // โ† change username

Change elimination percentages

File: artifacts/api-server/src/services/eliminationService.ts

switch (round.round_number) {
  case 1: targetCount = Math.floor(n * 0.4);  break;  // โ† 40% advance
  case 2: targetCount = Math.floor(n * 0.3);  break;  // โ† 30% advance
  case 3: targetCount = Math.floor(n * 0.25); break;  // โ† 25% advance
  case 4: targetCount = 2; break;                     // โ† always 2 finalists
}

Change the app title / branding

  • Tab title: artifacts/cinequiz/index.html โ†’ <title> tag
  • Landing page heading: artifacts/cinequiz/src/pages/Landing.tsx
  • Projector header: artifacts/cinequiz/src/pages/Projector.tsx

Change the API port

Set the PORT environment variable when starting the API server:

$env:PORT=4000; node --enable-source-maps ./dist/index.mjs

Then update the proxy in artifacts/cinequiz/vite.config.local.ts:

proxy: {
  '/api':       { target: 'http://localhost:4000' },
  '/socket.io': { target: 'http://localhost:4000', ws: true },
}

Change round time limit

Set in the Admin panel โ†’ Setup tab when creating a round (default: 30 seconds).
Or change the default in artifacts/api-server/src/database/db.ts in the seed data.


๐Ÿ”Œ Socket Events Reference

Event Direction Description
participant_join Client โ†’ Server Participant joins with session token
round_started Server โ†’ Client Round begins, sends clue + timer
submit_answer Client โ†’ Server Participant submits answer
round_ended Server โ†’ Client Round ends
qualification_result Server โ†’ Participant { qualified: true/false }
qualification_summary Server โ†’ Projector Lists of qualified/eliminated roll numbers
finalists_ready Server โ†’ Projector Final 2 contestants

๐Ÿ“ License

@devBitt Licensed

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages