"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
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.
ClassGuard treats attendance verification as a zero-trust cryptographic challenge:
- Classroom TV Display Mode: Displays an animated, high-contrast dynamic QR code generated with session-specific HMAC-SHA256 signatures rotating every 12β30 seconds.
- Instant Web-Camera Scanning: Students scan the live TV screen from their mobile devices.
- 7-Layer Fraud Verification Pipeline: Validates student identity, active enrollment, single-use cryptographic nonces, time window, physical proximity, and detects multi-account device anomalies.
- Real-Time Faculty Command Center: Instructors watch their live attendance roster stream updates in real-time via Server-Sent Events (SSE).
- Competitive Gamified Leaderboard: Boosts student punctuality with ClassGuard Scores, consecutive streaks, and automatic 75% minimum semester threshold alerts.
ββββββββββββββββββββββββββββββββββββββββββ
β 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 β
βββββββββββββββββββββββββ
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). |
ClassGuard transforms mundane attendance into a motivating, competitive experience:
- 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).
- 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.
| 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 |
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 factorsManualOverrideAudit: Immutable audit log of faculty corrections (recordId, actorId, reason, timestamp)Device: Device fingerprint registry and trusted hardware associationSystemSetting: Configurable thresholds (HEALTHY_THRESHOLD,WARNING_THRESHOLD)
- Node.js v18+ (tested on v20 and v24)
- npm or yarn
git clone https://github.com/your-username/classguard.git
cd classguard
npm installcp .env.example .env# 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.jsOption A: Standard Development Mode
npm run dev
# Open http://localhost:3000Option 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|team no: 19| | Name | | Abel Bosco | | Adnan Sameer | | Savan Santhosh |
(You can also use the 1-click persona switcher on the /login page).
Run the automated cryptographic and fraud engine test suites:
npm run testIncludes 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
- 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
EventEmitterbus - Styling: Tailwind CSS + Lucide Icons
- Cryptography:
node:cryptoHMAC-SHA256,joseJWTs,scrypthashing - QR Engine:
qrcode,html5-qrcode,BarcodeDetectorAPI - Testing: Vitest
This project is licensed under the MIT License β see the LICENSE file for details.
ClassGuard Β© 2024β2026. All rights reserved.