# paulthadev/qrcode-smart-attendance-system-with-geolocation architecture

> Architecture diagram of the GitHub repository paulthadev/qrcode-smart-attendance-system-with-geolocation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/paulthadev/qrcode-smart-attendance-system-with-geolocation
- Repository: https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation

## Overview

#### 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: [`src/utils/supabaseClient.js`](https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/utils/supabaseClient.js) (Supabase client), [`src/page/Attendance.jsx`](https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/page/Attendance.jsx) (Student attendance), [`src/App.jsx`](https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/App.jsx) (Route shell), [`src/page/ClassDetails.jsx`](https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/page/ClassDetails.jsx) (Class details)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["React application"]
  node_main["Application mount<br/>React entry<br/>[main.jsx]"]
  node_shell["Route shell<br/>React router<br/>[App.jsx]"]
end

subgraph group_lecturer["Lecturer workflows"]
  node_auth["Lecturer auth pages<br/>registration/login<br/>[LoginLecturer.jsx]"]
  node_session["Session controls<br/>user hook/logout<br/>[useUserDetails.js]"]
  node_schedule["Class scheduling<br/>lecturer page<br/>[ClassSchedule.jsx]"]
  node_class_details["Class details<br/>lecturer page<br/>[ClassDetails.jsx]"]
  node_map["Location map<br/>Leaflet modal<br/>[MapModal.jsx]"]
  node_qr["QR session handoff<br/>QR modal<br/>[QRCodeModal.jsx]"]
  node_history["Previous classes<br/>review page<br/>[PreviousClass.jsx]"]
  node_attendance_list["Attendance review/export<br/>attendance modal"]
end

subgraph group_student["Student attendance"]
  node_attendance["Student attendance<br/>student page<br/>[Attendance.jsx]"]
  node_distance["Distance validation<br/>Haversine utility"]
  node_success["Attendance success<br/>completion page<br/>[SuccessPage.jsx]"]
end

subgraph group_services["External boundaries"]
  node_supabase_client["Supabase client<br/>frontend client<br/>[supabaseClient.js]"]
  node_supabase[("Supabase")]
  node_geolocation(("Browser geolocation<br/>browser API"))
end

node_main -->|"mounts"| node_shell
node_shell -->|"routes to"| node_auth
node_shell -->|"lecturer routes"| node_schedule
node_shell -->|"student route"| node_attendance
node_auth -->|"auth requests"| node_supabase_client
node_session -->|"reads session / logs out"| node_supabase_client
node_schedule -->|"selects location"| node_map
node_schedule -->|"creates classes"| node_supabase_client
node_class_details -->|"opens"| node_qr
node_class_details -->|"inspects attendance"| node_attendance_list
node_class_details -->|"reads class data"| node_supabase_client
node_history -->|"reviews sessions"| node_attendance_list
node_attendance_list -->|"loads records"| node_supabase_client
node_qr -->|"QR link payload"| node_attendance
node_attendance -->|"requests position"| node_geolocation
node_attendance -->|"validates position"| node_distance
node_attendance -->|"records valid attendance"| node_supabase_client
node_attendance -->|"on completion"| node_success
node_supabase_client -->|"uses"| node_supabase

click node_main "https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/main.jsx"
click node_shell "https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/App.jsx"
click node_auth "https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/page/LoginLecturer.jsx"
click node_session "https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/hooks/useUserDetails.js"
click node_schedule "https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/page/ClassSchedule.jsx"
click node_class_details "https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/page/ClassDetails.jsx"
click node_map "https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/component/MapModal.jsx"
click node_qr "https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/component/QRCodeModal.jsx"
click node_history "https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/page/PreviousClass.jsx"
click node_attendance_list "https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/component/AttendanceListModal.jsx"
click node_attendance "https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/page/Attendance.jsx"
click node_distance "https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/utils/distanceCalculation.js"
click node_success "https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/page/SuccessPage.jsx"
click node_supabase_client "https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/utils/supabaseClient.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_shell toneBlue
class node_auth,node_session,node_schedule,node_class_details,node_map,node_qr,node_history,node_attendance_list toneAmber
class node_attendance,node_distance,node_success toneMint
class node_supabase_client,node_supabase,node_geolocation toneRose
```

## Components

### React application

- [Application mount](https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/main.jsx): React entry · `src/main.jsx`
- [Route shell](https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/App.jsx): React router · Composes public, lecturer, and student views. · `src/App.jsx`

### Lecturer workflows

- [Lecturer auth pages](https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/page/LoginLecturer.jsx): registration/login · `src/page/LoginLecturer.jsx`
- [Session controls](https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/hooks/useUserDetails.js): user hook/logout · `src/hooks/useUserDetails.js`
- [Class scheduling](https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/page/ClassSchedule.jsx): lecturer page · Creates and manages class records. · `src/page/ClassSchedule.jsx`
- [Class details](https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/page/ClassDetails.jsx): lecturer page · Class-specific operations and attendance inspection. · `src/page/ClassDetails.jsx`
- [Location map](https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/component/MapModal.jsx): Leaflet modal · Captures or displays the meeting location. · `src/component/MapModal.jsx`
- [QR session handoff](https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/component/QRCodeModal.jsx): QR modal · Encodes class, location, timestamp, and session token. · `src/component/QRCodeModal.jsx`
- [Previous classes](https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/page/PreviousClass.jsx): review page · `src/page/PreviousClass.jsx`
- [Attendance review/export](https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/component/AttendanceListModal.jsx): attendance modal · Lists stored attendance and supports XLSX export. · `src/component/AttendanceListModal.jsx`

### Student attendance

- [Student attendance](https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/page/Attendance.jsx): student page · Consumes QR session data and collects student details. · `src/page/Attendance.jsx`
- [Distance validation](https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/utils/distanceCalculation.js): Haversine utility · Validates browser position within the 20 m threshold. · `src/utils/distanceCalculation.js`
- [Attendance success](https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/page/SuccessPage.jsx): completion page · `src/page/SuccessPage.jsx`

### External boundaries

- [Supabase client](https://github.com/paulthadev/qrcode-smart-attendance-system-with-geolocation/blob/main/src/utils/supabaseClient.js): frontend client · Single browser boundary for backend interaction. · `src/utils/supabaseClient.js`
- **Supabase**: Auth + database + RLS · Provides lecturer authentication and classes/attendance persistence.
- **Browser geolocation**: browser API

## Connections

- 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
