# samruth07/smart-attendance-guard architecture

> Architecture diagram of the GitHub repository samruth07/smart-attendance-guard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/samruth07/smart-attendance-guard
- Repository: https://github.com/samruth07/smart-attendance-guard

## Overview

Smart Attendance Guard is a role-based attendance ERP. Users authenticate and enter student, teacher, or admin workflows; teachers open timetable sessions, students scan rotating QR tokens with location checks, and teachers submit attendance for review and analytics. The map preserves documented biometric, timetable, administrative override, audit, and real-time capabilities. Backend route implementations and most feature pages were not sampled, so unsupported links between those subsystems are omitted; documented capabilities remain represented.

Main entry points: [`client/src/App.jsx`](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/App.jsx) (Role routes), [`client/src/utils/api.js`](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/utils/api.js) (HTTP API client), [`server/index.js`](https://github.com/samruth07/smart-attendance-guard/blob/main/server/index.js) (Express application), [`server/config/database.js`](https://github.com/samruth07/smart-attendance-guard/blob/main/server/config/database.js) (Attendance database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Role-based web app"]
  node_app["Role routes<br/>[App.jsx]"]
  node_login["Login screen<br/>[Login.jsx]"]
  node_protected["Role protection<br/>[ProtectedRoute.jsx]"]
  node_studentdash["Student dashboard<br/>[Dashboard.jsx]"]
  node_myattendance["Attendance history<br/>[MyAttendance.jsx]"]
  node_teacherdash["Teacher dashboard<br/>[Dashboard.jsx]"]
end

subgraph group_identity["Identity and security"]
  node_authstate["Auth state<br/>[AuthContext.jsx]"]
  node_authroutes["Password login API<br/>[auth.js]"]
  node_webauthn["WebAuthn verification<br/>[webauthn.js]"]
  node_middleware["JWT and role checks<br/>[auth.js]"]
end

subgraph group_sessions["Attendance operations"]
  node_scanner["QR attendance scanner<br/>[Scanner.jsx]"]
  node_teachersession["Session management<br/>[Session.jsx]"]
  node_socketserver["QR and scan events<br/>[attendance.js]"]
  node_geo["Geofence checks<br/>[geo.js]"]
end

subgraph group_oversight["Academic oversight"]
  node_studenttimetable["Student timetable"]
  node_teacheranalytics["Teacher analytics<br/>[Analytics.jsx]"]
  node_teacherschedule["Teacher schedule"]
  node_admindash["Admin dashboard<br/>[Dashboard.jsx]"]
  node_branchanalytics["Branch analytics"]
  node_studentdetail["Student audit detail<br/>[StudentDetail.jsx]"]
  node_admincontrol["Schedule overrides<br/>[AdminControl.jsx]"]
  node_dbviewer["Database audit viewer<br/>[DatabaseViewer.jsx]"]
end

subgraph group_backend["API and realtime services"]
  node_api["HTTP API client<br/>[api.js]"]
  node_socketclient["Socket client<br/>[socket.js]"]
  node_server["Express application<br/>[index.js]"]
  node_teacherapi["Teacher API<br/>[teacher.js]"]
  node_studentapi["Student API<br/>[student.js]"]
  node_adminapi["Admin API<br/>[admin.js]"]
end

subgraph group_storage["Persistent records"]
  node_database[("Attendance database<br/>[database.js]")]
  node_userrecords["User records<br/>[User.js]"]
  node_attendancerecords["Attendance records<br/>[Attendance.js]"]
  node_sessionrecords["Session records"]
  node_timetable["Timetable records<br/>[Timetable.js]"]
end

node_user(("Student / teacher / admin"))

node_user -->|"opens"| node_app
node_app -->|"routes to"| node_login
node_app -->|"guards routes"| node_protected
node_app -->|"routes to"| node_studentdash
node_app -->|"routes to"| node_scanner
node_app -->|"routes to"| node_myattendance
node_app -->|"routes to"| node_studenttimetable
node_app -->|"routes to"| node_teacherdash
node_app -->|"routes to"| node_teachersession
node_app -->|"routes to"| node_teacheranalytics
node_app -->|"routes to"| node_teacherschedule
node_app -->|"routes to"| node_admindash
node_app -->|"routes to"| node_branchanalytics
node_app -->|"routes to"| node_studentdetail
node_app -->|"routes to"| node_admincontrol
node_app -->|"routes to"| node_dbviewer
node_login -.->|"signs in via"| node_authstate
node_authstate -->|"requests identity"| node_api
node_studentdash -.->|"loads data"| node_api
node_scanner -->|"submits scan"| node_api
node_scanner -->|"joins session"| node_socketclient
node_myattendance -.->|"loads records"| node_api
node_studenttimetable -.->|"loads schedule"| node_api
node_teacherdash -.->|"loads schedule"| node_api
node_teachersession -->|"starts and submits"| node_api
node_teachersession -->|"receives events"| node_socketclient
node_teacheranalytics -.->|"loads analytics"| node_api
node_teacherschedule -.->|"loads timetable"| node_api
node_admindash -.->|"loads metrics"| node_api
node_branchanalytics -.->|"loads reports"| node_api
node_studentdetail -.->|"loads student data"| node_api
node_admincontrol -.->|"changes schedules"| node_api
node_dbviewer -.->|"loads audit data"| node_api
node_api -.->|"HTTP requests"| node_server
node_socketclient -.->|"Socket events"| node_socketserver
node_server -->|"mounts routes"| node_authroutes
node_server -->|"mounts routes"| node_teacherapi
node_server -->|"mounts routes"| node_studentapi
node_server -->|"mounts routes"| node_adminapi
node_server -->|"mounts routes"| node_webauthn
node_server -->|"initializes sockets"| node_socketserver
node_authroutes -->|"reads users"| node_database
node_authroutes -->|"protects profile"| node_middleware
node_webauthn -->|"stores credentials"| node_database
node_webauthn -->|"authenticates registration"| node_middleware
node_middleware -->|"loads user"| node_database
node_teacherapi -.->|"reads and writes"| node_database
node_studentapi -.->|"reads and writes"| node_database

click node_app "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/App.jsx"
click node_login "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/Login.jsx"
click node_authstate "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/context/AuthContext.jsx"
click node_protected "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/components/ProtectedRoute.jsx"
click node_studentdash "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/student/Dashboard.jsx"
click node_scanner "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/student/Scanner.jsx"
click node_myattendance "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/student/MyAttendance.jsx"
click node_studenttimetable "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/student/WeeklyTimetable.jsx"
click node_teacherdash "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/teacher/Dashboard.jsx"
click node_teachersession "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/teacher/Session.jsx"
click node_teacheranalytics "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/teacher/Analytics.jsx"
click node_teacherschedule "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/teacher/TeacherSchedule.jsx"
click node_admindash "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/admin/Dashboard.jsx"
click node_branchanalytics "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/admin/BranchAnalytics.jsx"
click node_studentdetail "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/admin/StudentDetail.jsx"
click node_admincontrol "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/admin/AdminControl.jsx"
click node_dbviewer "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/admin/DatabaseViewer.jsx"
click node_api "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/utils/api.js"
click node_socketclient "https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/utils/socket.js"
click node_server "https://github.com/samruth07/smart-attendance-guard/blob/main/server/index.js"
click node_authroutes "https://github.com/samruth07/smart-attendance-guard/blob/main/server/routes/auth.js"
click node_webauthn "https://github.com/samruth07/smart-attendance-guard/blob/main/server/routes/webauthn.js"
click node_middleware "https://github.com/samruth07/smart-attendance-guard/blob/main/server/middleware/auth.js"
click node_teacherapi "https://github.com/samruth07/smart-attendance-guard/blob/main/server/routes/teacher.js"
click node_studentapi "https://github.com/samruth07/smart-attendance-guard/blob/main/server/routes/student.js"
click node_adminapi "https://github.com/samruth07/smart-attendance-guard/blob/main/server/routes/admin.js"
click node_socketserver "https://github.com/samruth07/smart-attendance-guard/blob/main/server/socket/attendance.js"
click node_geo "https://github.com/samruth07/smart-attendance-guard/blob/main/server/utils/geo.js"
click node_database "https://github.com/samruth07/smart-attendance-guard/blob/main/server/config/database.js"
click node_userrecords "https://github.com/samruth07/smart-attendance-guard/blob/main/server/models/User.js"
click node_attendancerecords "https://github.com/samruth07/smart-attendance-guard/blob/main/server/models/Attendance.js"
click node_sessionrecords "https://github.com/samruth07/smart-attendance-guard/blob/main/server/models/AttendanceSession.js"
click node_timetable "https://github.com/samruth07/smart-attendance-guard/blob/main/server/models/Timetable.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_app,node_login,node_protected,node_studentdash,node_myattendance,node_teacherdash toneBlue
class node_authstate,node_authroutes,node_webauthn,node_middleware toneAmber
class node_scanner,node_teachersession,node_socketserver,node_geo toneMint
class node_studenttimetable,node_teacheranalytics,node_teacherschedule,node_admindash,node_branchanalytics,node_studentdetail,node_admincontrol,node_dbviewer toneRose
class node_api,node_socketclient,node_server,node_teacherapi,node_studentapi,node_adminapi,node_user toneIndigo
class node_database,node_userrecords,node_attendancerecords,node_sessionrecords,node_timetable toneTeal
```

## Components

### Role-based web app

- [Role routes](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Login screen](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/Login.jsx): `client/src/pages/Login.jsx`
- [Role protection](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/components/ProtectedRoute.jsx): `client/src/components/ProtectedRoute.jsx`
- [Student dashboard](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/student/Dashboard.jsx): `client/src/pages/student/Dashboard.jsx`
- [Attendance history](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/student/MyAttendance.jsx): `client/src/pages/student/MyAttendance.jsx`
- [Teacher dashboard](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/teacher/Dashboard.jsx): `client/src/pages/teacher/Dashboard.jsx`

### Identity and security

- [Auth state](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Password login API](https://github.com/samruth07/smart-attendance-guard/blob/main/server/routes/auth.js): `server/routes/auth.js`
- [WebAuthn verification](https://github.com/samruth07/smart-attendance-guard/blob/main/server/routes/webauthn.js): `server/routes/webauthn.js`
- [JWT and role checks](https://github.com/samruth07/smart-attendance-guard/blob/main/server/middleware/auth.js): `server/middleware/auth.js`

### Attendance operations

- [QR attendance scanner](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/student/Scanner.jsx): `client/src/pages/student/Scanner.jsx`
- [Session management](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/teacher/Session.jsx): `client/src/pages/teacher/Session.jsx`
- [QR and scan events](https://github.com/samruth07/smart-attendance-guard/blob/main/server/socket/attendance.js): `server/socket/attendance.js`
- [Geofence checks](https://github.com/samruth07/smart-attendance-guard/blob/main/server/utils/geo.js): `server/utils/geo.js`

### Academic oversight

- [Student timetable](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/student/WeeklyTimetable.jsx): `client/src/pages/student/WeeklyTimetable.jsx`
- [Teacher analytics](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/teacher/Analytics.jsx): `client/src/pages/teacher/Analytics.jsx`
- [Teacher schedule](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/teacher/TeacherSchedule.jsx): `client/src/pages/teacher/TeacherSchedule.jsx`
- [Admin dashboard](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/admin/Dashboard.jsx): `client/src/pages/admin/Dashboard.jsx`
- [Branch analytics](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/admin/BranchAnalytics.jsx): `client/src/pages/admin/BranchAnalytics.jsx`
- [Student audit detail](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/admin/StudentDetail.jsx): `client/src/pages/admin/StudentDetail.jsx`
- [Schedule overrides](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/admin/AdminControl.jsx): `client/src/pages/admin/AdminControl.jsx`
- [Database audit viewer](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/pages/admin/DatabaseViewer.jsx): `client/src/pages/admin/DatabaseViewer.jsx`

### API and realtime services

- [HTTP API client](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/utils/api.js): `client/src/utils/api.js`
- [Socket client](https://github.com/samruth07/smart-attendance-guard/blob/main/client/src/utils/socket.js): `client/src/utils/socket.js`
- [Express application](https://github.com/samruth07/smart-attendance-guard/blob/main/server/index.js): `server/index.js`
- [Teacher API](https://github.com/samruth07/smart-attendance-guard/blob/main/server/routes/teacher.js): `server/routes/teacher.js`
- [Student API](https://github.com/samruth07/smart-attendance-guard/blob/main/server/routes/student.js): `server/routes/student.js`
- [Admin API](https://github.com/samruth07/smart-attendance-guard/blob/main/server/routes/admin.js): `server/routes/admin.js`

### Persistent records

- [Attendance database](https://github.com/samruth07/smart-attendance-guard/blob/main/server/config/database.js): `server/config/database.js`
- [User records](https://github.com/samruth07/smart-attendance-guard/blob/main/server/models/User.js): `server/models/User.js`
- [Attendance records](https://github.com/samruth07/smart-attendance-guard/blob/main/server/models/Attendance.js): `server/models/Attendance.js`
- [Session records](https://github.com/samruth07/smart-attendance-guard/blob/main/server/models/AttendanceSession.js): `server/models/AttendanceSession.js`
- [Timetable records](https://github.com/samruth07/smart-attendance-guard/blob/main/server/models/Timetable.js): `server/models/Timetable.js`

### Other components

- **Student / teacher / admin**

## Connections

- Student / teacher / admin → Role routes: opens (evidence: `client/src/App.jsx`)
- Role routes → Login screen: routes to (evidence: `client/src/App.jsx`)
- Role routes → Role protection: guards routes (evidence: `client/src/App.jsx`)
- Role routes → Student dashboard: routes to (evidence: `client/src/App.jsx`)
- Role routes → QR attendance scanner: routes to (evidence: `client/src/App.jsx`)
- Role routes → Attendance history: routes to (evidence: `client/src/App.jsx`)
- Role routes → Student timetable: routes to (evidence: `client/src/App.jsx`)
- Role routes → Teacher dashboard: routes to (evidence: `client/src/App.jsx`)
- Role routes → Session management: routes to (evidence: `client/src/App.jsx`)
- Role routes → Teacher analytics: routes to (evidence: `client/src/App.jsx`)
- Role routes → Teacher schedule: routes to (evidence: `client/src/App.jsx`)
- Role routes → Admin dashboard: routes to (evidence: `client/src/App.jsx`)
- Role routes → Branch analytics: routes to (evidence: `client/src/App.jsx`)
- Role routes → Student audit detail: routes to (evidence: `client/src/App.jsx`)
- Role routes → Schedule overrides: routes to (evidence: `client/src/App.jsx`)
- Role routes → Database audit viewer: routes to (evidence: `client/src/App.jsx`)
- Login screen → Auth state: signs in via
- Auth state → HTTP API client: requests identity (evidence: `client/src/context/AuthContext.jsx`)
- Student dashboard → HTTP API client: loads data
- QR attendance scanner → HTTP API client: submits scan (evidence: `client/src/pages/student/Scanner.jsx`)
- QR attendance scanner → Socket client: joins session (evidence: `client/src/pages/student/Scanner.jsx`)
- Attendance history → HTTP API client: loads records
- Student timetable → HTTP API client: loads schedule
- Teacher dashboard → HTTP API client: loads schedule
- Session management → HTTP API client: starts and submits (evidence: `client/src/pages/teacher/Session.jsx`)
- Session management → Socket client: receives events (evidence: `client/src/pages/teacher/Session.jsx`)
- Teacher analytics → HTTP API client: loads analytics
- Teacher schedule → HTTP API client: loads timetable
- Admin dashboard → HTTP API client: loads metrics
- Branch analytics → HTTP API client: loads reports
- Student audit detail → HTTP API client: loads student data
- Schedule overrides → HTTP API client: changes schedules
- Database audit viewer → HTTP API client: loads audit data
- HTTP API client → Express application: HTTP requests
- Socket client → QR and scan events: Socket events
- Express application → Password login API: mounts routes (evidence: `server/index.js`)
- Express application → Teacher API: mounts routes (evidence: `server/index.js`)
- Express application → Student API: mounts routes (evidence: `server/index.js`)
- Express application → Admin API: mounts routes (evidence: `server/index.js`)
- Express application → WebAuthn verification: mounts routes (evidence: `server/index.js`)
- Express application → QR and scan events: initializes sockets (evidence: `server/index.js`)
- Password login API → Attendance database: reads users (evidence: `server/routes/auth.js`)
- Password login API → JWT and role checks: protects profile (evidence: `server/routes/auth.js`)
- WebAuthn verification → Attendance database: stores credentials (evidence: `server/routes/webauthn.js`)
- WebAuthn verification → JWT and role checks: authenticates registration (evidence: `server/routes/webauthn.js`)
- JWT and role checks → Attendance database: loads user (evidence: `server/middleware/auth.js`)
- Teacher API → Attendance database: reads and writes
- Student API → Attendance database: reads and writes
