Skip to content

RustamSheoran/live-attendance-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Live Attendance System - Backend

Backend system for live attendance tracking with WebSocket support.

Tech Stack

  • Node.js, Express
  • MongoDB, Mongoose
  • JWT, bcrypt
  • Zod (validation)
  • ws (WebSocket)

Installation

npm install

Environment Variables

Create a .env file:

MONGODB_URI=mongodb://localhost:27017/live-attendance
JWT_SECRET=your_jwt_secret_key_here
PORT=3000

Running the Server

npm start
# or for development with watch mode
npm run dev

API Endpoints

Authentication

  • POST /auth/signup - Create user account
  • POST /auth/login - Login and get JWT token
  • GET /auth/me - Get current user info (requires auth)

Classes

  • POST /class - Create class (teacher only)
  • POST /class/:id/add-student - Add student to class (teacher only)
  • GET /class/:id - Get class details with students

Students & Attendance

  • GET /students - Get all students (teacher only)
  • GET /class/:id/my-attendance - Get student's attendance status (student only)

Attendance Session

  • POST /attendance/start - Start attendance session (teacher only)

WebSocket

Connection

ws://localhost:3000/ws?token=<JWT_TOKEN>

Events

ATTENDANCE_MARKED (Teacher)

{
  "event": "ATTENDANCE_MARKED",
  "data": {
    "studentId": "s100",
    "status": "present"
  }
}

TODAY_SUMMARY (Teacher)

{
  "event": "TODAY_SUMMARY"
}

MY_ATTENDANCE (Student)

{
  "event": "MY_ATTENDANCE"
}

DONE (Teacher)

{
  "event": "DONE"
}

Response Format

Success:

{
  "success": true,
  "data": { ... }
}

Error:

{
  "success": false,
  "error": "Error message"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors