The backend provides a RESTful API for common operations, supplemented by Socket.io for real-time events.
POST /api/auth/register
- Body:
{ name, email, password, role, className, rollNo } - Description: Creates a new user profile. Roles are
teacherorstudent.
POST /api/auth/login
- Body:
{ email, password } - Returns:
{ token, user: { id, name, role, ... } }
POST /api/attendance/session
- Header:
Authorization: Bearer <token> - Body:
{ targetClass, coords: { lat, lng }, radius, expiresAt } - Description: Generates a new unique
joinCodeand starts a session.
POST /api/attendance/mark
- Header:
Authorization: Bearer <token> - Body:
{ joinCode, coords: { lat, lng }, faceImage (FormData) } - Description: Validates GPS distance and registers attendance for the student.
connection: Triggered on socket initialization.
attendance-update: Emitted to the teacher whenever a student successfully marks attendance.session-ended: Emitted to students when the teacher terminates the session.