How paulthadev/qrcode-smart-attendance-system-with-geolocation works
Purpose and Runtime
TrackAS is a Vite-served React single-page attendance system. Lecturers authenticate, manage scheduled classes and attendance records; students access an attendance flow through QR-derived links and must pass browser geolocation validation. Production deployment is configured for Vercel (vercel.json); Supabase supplies authentication and database persistence.
Application Entry and Navigation
src/main.jsx mounts the React application and global styling. src/App.jsx is the application shell and likely owns React Router route composition across the public landing/authentication, lecturer, and student attendance views.
• src/main.jsx
• src/App.jsx
• src/index.css
Identity and Lecturer Session Boundary
Lecturer registration and login are separate page flows backed by Supabase Auth. User/session state is obtained through a dedicated hook, while logout is encapsulated as reusable UI behavior. Lecturer-only operations—such as creating schedules or inspecting attendance—depend on this authenticated boundary and Supabase RLS.
• src/page/RegisterLecturer.jsx
• src/page/LoginLecturer.jsx
• src/hooks/useUserDetails.js
• src/hooks/useLogout.jsx
Class Scheduling and Location Capture
The scheduling flow is the lecturer’s operational hub: it creates/manages class records, associates a physical meeting location, and exposes class-specific detail views. Interactive map selection/display is isolated in a modal, keeping Leaflet/React Leaflet integration at the location boundary.
• src/page/ClassSchedule.jsx
• src/page/ClassDetails.jsx
• src/component/MapModal.jsx
QR Session Handoff
A lecturer opens a QR modal for a class/session. The QR payload/link transfers class identity, location coordinates, timestamp, and session token into the student-facing attendance route. This is a client-side handoff boundary: the scan consumer need not navigate lecturer dashboard state.
• src/component/QRCodeModal.jsx
• src/page/ClassDetails.jsx
• src/page/Attendance.jsx
Attendance Verification and Recording
The student attendance page collects student details, reads browser geolocation, and compares it to the class location. distanceCalculation.js implements the geographic-distance boundary (documented as Haversine-based and subject to a 20 m threshold). Validated attendance is persisted through Supabase; completion is surfaced through a success view.
• src/page/Attendance.jsx
• src/utils/distanceCalculation.js
• src/page/SuccessPage.jsx
Attendance Review and Export
Lecturers can review earlier sessions and inspect class attendance through history/detail pages and an attendance-list modal. The declared XLSX/FileSaver dependencies support exporting stored attendance records, separating operational capture from retrospective reporting.
• src/page/PreviousClass.jsx
• src/page/ClassDetails.jsx
• src/component/AttendanceListModal.jsx
External Service and Client Boundary
All frontend-to-backend interaction should converge on the configured Supabase client, initialized from Vite-exposed environment credentials. Supabase is responsible for Auth, classes and attendance storage, and database-level RLS; the browser supplies geolocation; mapping and QR libraries remain frontend integrations.
• src/utils/supabaseClient.js
• .env.example
• vite.config.js
Main entry points: supabaseClient.js Supabase client · Attendance.jsx Student attendance · App.jsx Route shell · ClassDetails.jsx Class details
Components 16
React application
- Application mount
src/main.jsx - Route shell · Composes public, lecturer, and student views.
src/App.jsx
Lecturer workflows
- Lecturer auth pages
src/page/LoginLecturer.jsx - Session controls
src/hooks/useUserDetails.js - Class scheduling · Creates and manages class records.
src/page/ClassSchedule.jsx - Class details · Class-specific operations and attendance inspection.
src/page/ClassDetails.jsx - Location map · Captures or displays the meeting location.
src/component/MapModal.jsx - QR session handoff · Encodes class, location, timestamp, and session token.
src/component/QRCodeModal.jsx - Previous classes
src/page/PreviousClass.jsx - Attendance review/export · Lists stored attendance and supports XLSX export.
src/component/AttendanceListModal.jsx
Student attendance
- Student attendance · Consumes QR session data and collects student details.
src/page/Attendance.jsx - Distance validation · Validates browser position within the 20 m threshold.
src/utils/distanceCalculation.js - Attendance success
src/page/SuccessPage.jsx
External boundaries
- Supabase client · Single browser boundary for backend interaction.
src/utils/supabaseClient.js - Supabase · Provides lecturer authentication and classes/attendance persistence.
- Browser geolocation
Connections 19
- Application mount → Route shell: mounts
- Route shell → Lecturer auth pages: routes to
- Route shell → Class scheduling: lecturer routes
- Route shell → Student attendance: student route
- Lecturer auth pages → Supabase client: auth requests
- Session controls → Supabase client: reads session / logs out
- Class scheduling → Location map: selects location
- Class scheduling → Supabase client: creates classes
- Class details → QR session handoff: opens
- Class details → Attendance review/export: inspects attendance
- Class details → Supabase client: reads class data
- Previous classes → Attendance review/export: reviews sessions
- Attendance review/export → Supabase client: loads records
- QR session handoff → Student attendance: QR link payload
- Student attendance → Browser geolocation: requests position
- Student attendance → Distance validation: validates position
- Student attendance → Supabase client: records valid attendance
- Student attendance → Attendance success: on completion
- Supabase client → Supabase: uses