React-based web application for managing student attendance. It includes features for logging in, marking attendance, adding students, and retrieving attendance records, all features using a face-recognition by python with flask backend
-- By this_is_mjk Manas Jain Kuniya
Ensure you have python and npm installed properly. run the following commands after clonning the repository
cd Attendance-App-Task
cd backend
pip install -r requirements.txt
python3 app.py
open a new terminal and reach Attendance-App-Task
npm install
npm start
- python3
- npm
- React
- Axios
- Material-UI
- js-cookie
- MongoDB compass
-
Home.js main component, handles the application's logic and renders the appropriate UI elements based on the user's state (logged in, admin, etc.).
-
alert.js Displays alert messages to the user based on the response recieved form server.
-
attendenceTable.js Renders a table with attendance data recieved
-
camera.js Handles the webcam functionality for showing the webcam image on the page
-
inputID.js Input field component for entering the roll number.
-
request.js Contains functions for sending HTTP requests to the backend server with fixed parameters
-
createFormData.js function to create FormData object from the roll number and webcam image, to send in the request
-
requestCameraPermission.js Requests camera access permissions if the browser do not provide the permission
-
infoToggle.js toggling additional information on the UI, just for looks and info 😀
-
loadScreen.js Loading screen component displayed during data fetching.
- User Authentication: JWT-based authentication, workes with postman, issues with the react frontend
- Face Detection and verification
- Attendance Management
- Admin Power of Adding students, getting attendence and mark absent all
- Backend: Flask
- Database: MongoDB
- Facial Recognition: OpenCV, DeepFace
- Token Management: JWT
- POST /login - Login using roll number and webcam image.
- POST /mark-attendence - Mark attendance using roll number and webcam image.
- POST /add-student - Add a new student using roll number and webcam image.
- POST /get-attendence - Get attendance data for a specific roll number.
- GET /mark-absent-all - Mark all other students as absent for the day.
URL: /login
Method: POST
Description: Logs in the user and returns a JWT token.
Request:
Form Data:
user_id: User ID
image: User image file
Response:
Success: { "status": "Login successful", "isAdmin": boolean, "attendence": [] }
Error: { "status": "Error message" }
URL: /mark-attendance
Method: POST
Description: Marks the user's attendance.
Request:
Form Data:
user_id: User ID
image: User image file
Response:
Success: { "status": "attendance marked" }
Error: { "status": "Error message" }
URL: /add-student
Method: POST
Description: Adds a new student to the system (Admin only).
Request:
Form Data:
user_id: User ID
image: User image file
Response:
Success: { "status": "student added" }
Error: { "status": "Error message" }
URL: /get-attendance
Method: POST
Description: Gets the attendance records for the user or another user (Admin only).
Request:
Form Data:
user_id: User ID (of the user whose attendance is requested)
Response:
Success: { "status": "Got Attendance", "attendance": [] }
Error: { "status": "Error message" }
URL: /mark-absent-all
Method: GET
Description: Marks all users as absent who have not marked their attendance for the day (Admin only).
Response:
Success: { "status": "All other marked absent, count: n" }
Error: { "status": "Error message" }
Custom exceptions are used to handle errors and return appropriate responses:
- missing_form_data
- face_not_detected
- user_not_found
- something_went_wrong
- not_admin
- extract_id_and_image: Extracts user ID and image from the request.
- check_face: Compares two images to check if they have the same face.
- extrat_face: Extracts the face from an image.
- mark_present: Marks a user as present.
- check_and_get_use: Checks if a user exists and returns the user.
- check_admin: Checks if a user is an admin.
- mark_absent: Marks all users as absent who have not marked their attendance for the day.
- got my weekness of react, like cookies and a bit of await, known and will now work on it
- got to know i can ignore the CORS issue of localhost by using localh.st
- came to know about Flask and DeepFace technologies
- helped me to brush me up with a few mongo db resources and python
- came to know about pip freeze > requirements.txt to list all requirements easily.
- http://localh.st:5000 for CORS issue solution.
- to make the code more readable by using file organising for different function
- JWT implementation intergration with the frontend.
- front end is very messy with a lot of code repetation, would like to organise the same and learn new concept to use multiple useStae variables across the react app without passing every where,
- React code can get full of errors in no time, i want to make it organised and compact so that it is esay to use at multiple places, modularity is my focus.
- increase the readablity
- organise the files and fucntions in a better way.
- understand the concepts of useEffect, hooks, ects in deep, currently i face a bit issue in this topic
- Reduce copy pasting, increase typing you myself even when i just following the tutorial online, or only online resource.