Skip to content

About

Enterprise-grade smart college attendance platform with dynamic cryptographic TV QR codes, a 7-layer anti-proxy fraud verification engine, 75% semester threshold safeguards, and gamified student leaderboards.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

πŸ›‘οΈ CLASSGUARD

Smart Attendance & Multi-Layer Classroom Verification Platform

Next.js 14 TypeScript Prisma ORM Tailwind CSS License: MIT

"Attendance, verified."
An enterprise-grade, zero-trust attendance ecosystem that eliminates proxy attendance, screenshot sharing, replay attacks, and academic attendance fraud using dynamic cryptographic QR codes and a 7-layer server-side verification engine.

Live Demo Links β€’ Architecture β€’ 7-Layer Security β€’ Gamification β€’ Quickstart


πŸ“Œ Problem Statement

Traditional university and college attendance methods suffer from severe vulnerabilities:

  • ❌ Paper Sign-in Sheets: Easily signed by friends ("proxy attendance").
  • ❌ Static QR Codes: Students photograph the QR code and send it over WhatsApp/Telegram to absent peers who scan from home.
  • ❌ RFID / Smart Cards: Students hand their physical ID cards to friends to swipe for them.
  • ❌ Manual Roll Calls: Consume 10–15 minutes of lecture time and are prone to human logging errors.

πŸ’‘ The ClassGuard Solution

ClassGuard treats attendance verification as a zero-trust cryptographic challenge:

  1. Classroom TV Display Mode: Displays an animated, high-contrast dynamic QR code generated with session-specific HMAC-SHA256 signatures rotating every 12–30 seconds.
  2. Instant Web-Camera Scanning: Students scan the live TV screen from their mobile devices.
  3. 7-Layer Fraud Verification Pipeline: Validates student identity, active enrollment, single-use cryptographic nonces, time window, physical proximity, and detects multi-account device anomalies.
  4. Real-Time Faculty Command Center: Instructors watch their live attendance roster stream updates in real-time via Server-Sent Events (SSE).
  5. Competitive Gamified Leaderboard: Boosts student punctuality with ClassGuard Scores, consecutive streaks, and automatic 75% minimum semester threshold alerts.

πŸ—οΈ Architecture & Data Flow

                               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                               β”‚       Classroom TV Display (/classroom)β”‚
                               β”‚  - Dynamic Rotating QR (HMAC-SHA256)   β”‚
                               β”‚  - Live Verified Counter (Privacy-safe)β”‚
                               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                  β”‚ Realtime SSE Stream
                                                  β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Student Mobile PWA    β”‚             β”‚ ClassGuard Core Backend Engine  β”‚
β”‚ - Instant Camera Scan │────────────▢│ - Route Handlers / REST API    β”‚
β”‚ - Device Fingerprint  β”‚ Attendance  β”‚ - 7-Layer Fraud & Risk Engine  β”‚
β”‚ - Campus Proximity    β”‚ Verificationβ”‚ - Cryptographic HMAC Validator β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ Request     β”‚ - Prisma Relational ORM        β”‚
                                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                              β”‚
β”‚ Teacher Live Command  β”‚β—€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ Realtime Updates
β”‚ - Live Student Roster β”‚ (SSE Broadcast: Verified, Late, Suspicious)
β”‚ - Manual Override/Log β”‚
β”‚ - CSV / Excel Export  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ›‘οΈ The 7-Layer Anti-Proxy Verification Engine

When a student scans the classroom display QR, the backend evaluates 7 independent layers to compute an authoritative Risk Score (0–100):

Layer Verification Signal Mechanism & Defense
Layer 1 Authentication & Enrollment Validates signed JWT session and queries course enrollments to ensure the student is actively registered for the subject.
Layer 2 Session State & Classroom Match Verifies the session is currently ACTIVE (not paused or ended) and matches the physical classroom.
Layer 3 Dynamic HMAC QR & Replay Prevention Verifies HMAC-SHA256 signature generated with the session's secret seed. Enforces short expiration windows and burns nonces in database transactions to prevent replay attacks.
Layer 4 Temporal Attendance Window Validates server timestamp against teacher-configured attendance window (e.g. first 15 mins). Marks late if submitted during grace period.
Layer 5 Classroom BLE Proximity (Configurable) Evaluates classroom Bluetooth beacon UUID or cryptographic proximity signal to ensure in-room presence.
Layer 6 Institutional Campus Network Checks client IP against authorized classroom Wi-Fi subnets (e.g. 10.142.254.x).
Layer 7 Device Anomaly & Multi-Account Detection Detects when 2+ student accounts submit attendance from the same physical device within 15 minutes (friend proxying) or rapid device switching (+50 penalty).

πŸ† Gamification & 75% Semester Threshold Tracker

ClassGuard transforms mundane attendance into a motivating, competitive experience:

1. πŸ“Š 75% Mandatory Attendance Safeguard

  • Automatic Requirement Calculator: Under each subject, students receive real-time notifications:
    • πŸ”΄ ⚠ Need 3 more classes to reach 75% threshold (Prevents exam debarment)
    • 🟒 βœ“ Safe β€” can miss 2 classes
  • Configurable institutional thresholds (e.g., 75% warning, 85% healthy standing).

2. πŸ₯‡ ClassGuard Score & Leaderboard

  • Score Formula: ClassGuard Score = (Attendance % Γ— 70%) + (Streak Bonus Γ— 30% max)
  • Achievement Badges:
    • πŸ”₯ On Fire: 3+ consecutive sessions attended
    • ⭐ Perfect Attendance: 100% attendance rate
    • ⚑ Punctual: 90%+ on-time arrival rate
    • πŸ“š Scholar: 85%+ semester attendance
  • Real-time podium ranking (πŸ₯‡πŸ₯ˆπŸ₯‰) viewable across the college.

🌐 Live Platform Modules & URLs

Role / View Route Description
🏠 Home Portal / Central launchpad directory with quick access to all modules
πŸ”‘ Persona Login /login 1-click persona switcher (Abel, Adnan, Savan, Dr. Alan Turing, Admin)
πŸ“± Mobile Scanner /student/scan Instant camera scanner with automatic token auto-detection
πŸŽ“ Student Dashboard /student Subject-wise breakdown, 75% attendance calculator & timetable
πŸ† Class Leaderboard /leaderboard Real-time semester rankings, podium cards & achievement badges
πŸ“œ Attendance History /student/history Immutable log of all past attendance records & verification methods
πŸ“… Timetable /student/timetable Weekly timetable schedule
πŸ“Ί Classroom Display TV /classroom/lab-2-demo Fullscreen dynamic QR code (auto-rotates) + live counter
πŸ‘¨β€πŸ« Teacher Live Tracker /teacher/session/[id] Real-time SSE command center with live roster & manual overrides
πŸ“‹ Teacher Dashboard /teacher Start new attendance sessions, schedule classes & view past logs
βš™οΈ Admin Control Panel /admin College-wide analytics, audit trail logs, CSV imports & policies

πŸ—„οΈ Relational Database Schema (Prisma)

The application uses a normalized relational schema with full foreign keys, cascade safety, and optimized indexes:

  • User: Identity model (id, email, passwordHash, role, firstName, lastName, phone, isActive)
  • StudentProfile: Student details (rollNumber, admissionYear, departmentId, currentSemester)
  • TeacherProfile: Faculty details (employeeCode, departmentId, designation)
  • Department: Academic departments (name, code, description)
  • Subject: Courses (name, code, semester, credits, departmentId)
  • Classroom: Physical rooms (name, building, roomNumber, capacity, beaconUuid, wifiSubnet)
  • Enrollment: Student-course mappings (studentId, subjectId, academicYear, semester, status)
  • AttendanceSession: Active/past class sessions (subjectId, teacherId, classroomId, status, secretSeed)
  • AttendanceRecord: Attendance logs (sessionId, studentId, status, markedAt, riskScore, deviceFingerprint)
  • QrToken: Single-use nonces burned upon scan for replay protection (sessionId, nonce, expiresAt)
  • VerificationEvent: Diagnostic log storing passed rules, failed rules, and risk factors
  • ManualOverrideAudit: Immutable audit log of faculty corrections (recordId, actorId, reason, timestamp)
  • Device: Device fingerprint registry and trusted hardware association
  • SystemSetting: Configurable thresholds (HEALTHY_THRESHOLD, WARNING_THRESHOLD)

πŸš€ Quickstart Guide

Prerequisites

  • Node.js v18+ (tested on v20 and v24)
  • npm or yarn

1. Clone & Install

git clone https://github.com/your-username/classguard.git
cd classguard
npm install

2. Environment Setup

cp .env.example .env

3. Initialize Database & Seed Pilot Data

# Push schema to SQLite database
npx prisma db push

# Seed demo students (Abel Bosco, Adnan Samwr, Savan Santhosh) & active Lab 2 session
node scripts/seed.js

4. Run the Application

Option A: Standard Development Mode

npm run dev
# Open http://localhost:3000

Option B: Mobile Camera HTTPS Mode (Local Wi-Fi Testing)

node server.js
# Access from mobile phones on same Wi-Fi via https://<YOUR-LOCAL-IP>:3000

5. Default Credentials

|team no: 19| | Name | | Abel Bosco | | Adnan Sameer | | Savan Santhosh |

(You can also use the 1-click persona switcher on the /login page).


πŸ§ͺ Automated Testing

Run the automated cryptographic and fraud engine test suites:

npm run test

Includes tests for:

  • βœ… HMAC-SHA256 dynamic token creation & signature validation
  • βœ… Nonce expiration & single-use replay protection
  • βœ… 7-layer verification risk scoring
  • βœ… Multi-account proxy anomaly detection

πŸ“¦ Tech Stack

  • Framework: Next.js 14 (App Router, Server Actions, API Route Handlers)
  • Language: TypeScript
  • Database ORM: Prisma (SQLite default, ready for PostgreSQL / MySQL)
  • Real-Time Engine: Server-Sent Events (SSE) via EventEmitter bus
  • Styling: Tailwind CSS + Lucide Icons
  • Cryptography: node:crypto HMAC-SHA256, jose JWTs, scrypt hashing
  • QR Engine: qrcode, html5-qrcode, BarcodeDetector API
  • Testing: Vitest

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


Built for Hackathons & Higher Education Innovation
ClassGuard Β© 2024–2026. All rights reserved.

About

Enterprise-grade smart college attendance platform with dynamic cryptographic TV QR codes, a 7-layer anti-proxy fraud verification engine, 75% semester threshold safeguards, and gamified student leaderboards.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages