TrackMate

Lecture attendance app: teachers show rotating QR codes, students scan them offline, and the app builds attendance sheets and defaulter lists.

Technothon 2k24

🎓 Vivekanand Education Society's Polytechnic

📌 Mumbai, Maharashtra

🚀 24 hours Hackathon Project

🥇 1st

What it is

TrackMate is a web app that records lecture attendance with QR codes. A teacher starts an attendance session and shows a rotating series of QR codes. Students scan them with their phones. The app turns the scans into an attendance sheet and calculates each student's attendance percentage. I built it with a team at Technothon 2k24.

The problem

The app's landing page promises "proxy prevention". Proxy attendance means a student gets marked present without being in the room. A QR code that a student can photograph and forward would allow it, so TrackMate limits when and for how long each code is valid.

How it works

TrackMate is a SvelteKit app written in TypeScript. Auth.js handles sign-in with Google or GitHub accounts. MongoDB stores users and attendance data. The frontend is also a PWA (progressive web app), so it can be installed on a phone.

Roles

The app derives a user's role from the signed-in email address.

RoleCheckCan do
AdminEmail exists in the admins collectionManage classes, students and teachers under src/routes/admin/
TeacherEmail exists in the teachers collectionRun attendance and view sheets under src/routes/teacher/
StudentEmail matches a student recordMark attendance and view the percentage under src/routes/student/

Data model

The types in src/lib/global.d.ts define four documents: students, teachers, classes and lectures. A lecture holds its student IDs, its assigned teacher, a list of finished attendance sheets, and an optional isMarkingAttendance object. That object exists only while a session runs. It holds each student's status (not ready, ready or present), a start timestamp and ten random UUIDs.

Attendance session flow

  1. The teacher selects Start attendance. The server creates the session with a start time 30 seconds ahead and ten UUIDs from crypto.randomUUID().
  2. Students open the lecture page. The app asks them to turn off their network connection.
  3. At the start time, the teacher's screen shows the ten UUIDs as QR codes, one per second.
  4. Each student's phone scans the codes. A scan counts only if the UUID is in the session list and the time is within ten seconds of the start.
  5. The scanner closes after 15 seconds. A student with at least 8 of the 10 distinct codes reconnects and selects Sync attendance. The server sets that student's status to present.
  6. The teacher can tick students manually, then finishes the session. The server writes an attendance sheet with the start timestamp and the present students, and clears isMarkingAttendance.

The teacher's page polls the lecture once per second, so the roster shows who is ready and present as students sync.

The teacher view also lists defaulters for a date range. A student is a defaulter below 75% attendance.

Design decisions

Rotating codes instead of one code. A single static QR code can be photographed and sent to someone outside the room. Ten codes shown for one second each force a student to be present for the whole window. The app requires 8 of 10, which tolerates a few missed frames.

Offline scanning. The app asks students to go offline while they scan. The code in mark_attendance/+page.svelte checks navigator.onLine and starts the scanner only when the device is offline. The aim, as the code implies, is to stop a student from relaying codes to another person in real time. The trade-off is that the check runs in the client, and the server does not see the scans.

Server-held session state. The UUIDs and student statuses live in MongoDB and not in the browser, so the teacher and student pages share one source of truth. A lecture holds at most one active session.

Roles from allow-lists. Admins and teachers are rows in collections, so the owner of the database controls who can run attendance. Auth.js only proves who the user is.

Known limits

These come from reading the code and are not tested claims.

  • The changeStudentStatus endpoint accepts the status from the client. It checks that the caller is signed in, but it does not verify the scan results on the server. A student who calls the endpoint directly can mark themselves present.
  • The API routes I read check only for a valid session, not a role.

Run it locally

Requirements: Node.js, npm and a running MongoDB instance.

  1. Clone the repository and install dependencies:

    git clone https://github.com/WhyAsh5114/attendance-tracking-system.git
    cd attendance-tracking-system
    npm install
    
  2. Create a .env file in the root. Set MONGODB_URI, which the app requires at startup. Add the credentials that Auth.js needs for the Google and GitHub providers.

  3. Add documents to the admins, teachers and students collections with the emails you will sign in with.

  4. Start the development server:

    npm run dev
    
  5. Open http://localhost:5173.

Reference

AreaChoiceUsed for
FrameworkSvelteKit 2, Svelte 4, TypeScriptPages, API routes, server load functions
AuthAuth.js with the MongoDB adapterGoogle and GitHub sign-in, sessions
DatabaseMongoDB (mongodb driver)Users, classes, lectures, attendance sheets
QR codesqrcode-generator, qr-scannerShowing and reading codes
StylingTailwind CSS, DaisyUILayout and components
PWA@vite-pwa/sveltekitInstallable app and service worker

Outcome

TrackMate won first place at Technothon 2k24, a 24-hour hackathon held on 17 February 2024 at Vivekanand Education Society's Polytechnic in Mumbai. The team had four members.

The repository was created on 9 February 2024. The last code change by the team is dated 17 March 2024, and later commits are dependency updates from Dependabot.

Liked TrackMate? Here's my background.

Full-stack TypeScript, shipped to real users.