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.
| Role | Check | Can do |
|---|---|---|
| Admin | Email exists in the admins collection | Manage classes, students and teachers under src/routes/admin/ |
| Teacher | Email exists in the teachers collection | Run attendance and view sheets under src/routes/teacher/ |
| Student | Email matches a student record | Mark 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
- The teacher selects Start attendance. The server creates the session with a start time 30 seconds ahead and ten UUIDs from
crypto.randomUUID(). - Students open the lecture page. The app asks them to turn off their network connection.
- At the start time, the teacher's screen shows the ten UUIDs as QR codes, one per second.
- 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.
- 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. - 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
changeStudentStatusendpoint 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.
-
Clone the repository and install dependencies:
git clone https://github.com/WhyAsh5114/attendance-tracking-system.git cd attendance-tracking-system npm install -
Create a
.envfile in the root. SetMONGODB_URI, which the app requires at startup. Add the credentials that Auth.js needs for the Google and GitHub providers. -
Add documents to the
admins,teachersandstudentscollections with the emails you will sign in with. -
Start the development server:
npm run dev -
Open
http://localhost:5173.
Reference
| Area | Choice | Used for |
|---|---|---|
| Framework | SvelteKit 2, Svelte 4, TypeScript | Pages, API routes, server load functions |
| Auth | Auth.js with the MongoDB adapter | Google and GitHub sign-in, sessions |
| Database | MongoDB (mongodb driver) | Users, classes, lectures, attendance sheets |
| QR codes | qrcode-generator, qr-scanner | Showing and reading codes |
| Styling | Tailwind CSS, DaisyUI | Layout and components |
| PWA | @vite-pwa/sveltekit | Installable 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.