Skip to content
XGNoir95Public

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ Sentry

AI-Powered Face Recognition Attendance System

Node.js React MongoDB Vite TailwindCSS

Sentry is a full-stack web application that automates classroom attendance using YOLO object detection and ArcFace facial recognition. Teachers upload a single photograph of their classroom, and the system identifies every student present β€” no manual roll calls required.

Features Β· Architecture Β· Quick Start Β· API Reference Β· Project Structure


✨ Features

🎯 Core

Feature Description
AI Attendance Upload a classroom photo β†’ YOLO detects faces β†’ ArcFace identifies students β†’ attendance is auto-recorded
Real-Time Updates Socket.IO pushes live notifications so dashboards refresh instantly
Role-Based Access Separate dashboards and permissions for students and teachers
Appeal System Students can appeal incorrect attendance marks; teachers approve or reject with notes

πŸ‘¨β€πŸ« Teacher Portal

  • Class Management β€” Create, delete, and manage courses with schedules and semesters
  • Student Roster β€” Add or remove students from classes by student ID
  • Attendance Analytics β€” Per-class and per-student attendance statistics with at-risk detection (< 75%)
  • Session History β€” View every attendance session with recognized faces and confidence scores
  • Announcements β€” Post and manage class announcements
  • Appeal Resolution β€” Review, approve, or reject student attendance appeals

πŸŽ“ Student Portal

  • Dashboard β€” Overview of enrollment, attendance rates, and upcoming classes
  • Course View β€” Browse enrolled courses in grid or list layout
  • Attendance Summary β€” Detailed attendance history per course with status breakdowns
  • Join/Leave Classes β€” Self-enroll into classes using class codes
  • Submit Appeals β€” Contest absent marks with a reason (one appeal per record)

πŸ— Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Frontend                              β”‚
β”‚              React 19 Β· Vite 8 Β· Tailwind CSS 4              β”‚
β”‚         Axios Β· React Router Β· Socket.IO Client              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                     REST API + WebSocket                     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                        Backend                               β”‚
β”‚           Express.js Β· Mongoose Β· JWT Β· Socket.IO            β”‚
β”‚             Helmet Β· Multer Β· express-validator              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                      Data Layer                              β”‚
β”‚                    MongoDB Atlas                             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                  AI Recognition Service                      β”‚
β”‚            YOLO (Detection) + ArcFace (Recognition)          β”‚
β”‚                  External FastAPI / Modal                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

How Attendance Works

Teacher uploads photo
        β”‚
        β–Ό
  Image saved to /uploads
        β”‚
        β–Ό
  Sent to YOLO + ArcFace API ──► Detects & identifies faces
        β”‚
        β–Ό
  Identity suffixes matched to enrolled students
        β”‚
        β–Ό
  Present / Absent records created
        β”‚
        β–Ό
  Socket.IO emits "refresh-data" ──► All dashboards update live

πŸš€ Quick Start

Prerequisites

Tool Version
Node.js 18 or higher
npm 9+
MongoDB Atlas cluster (or local instance)
Face Recognition API YOLO + ArcFace service running (e.g., via FastAPI)

1. Clone the Repository

git clone https://github.com/XGNoir95/Sentry.git
cd Sentry

2. Backend Setup

cd Backend
npm install

Create a .env file from the example:

cp .env.example .env

Configure the environment variables:

PORT=5000
MONGODB_URI=mongodb+srv://<username>:<password>@cluster0.xxxxx.mongodb.net/sentry?retryWrites=true&w=majority
JWT_SECRET=change_this_to_a_long_random_secret_string_42
JWT_EXPIRES_IN=7d
FACE_RECOGNITION_API_URL=http://localhost:8000/face-recognition
UPLOAD_DIR=uploads

Start the backend server:

# Development (with auto-reload)
npm run dev

# Production
npm start

The API will be available at http://localhost:5000

3. Frontend Setup

cd Frontend
npm install

Optionally create a .env file to override the API URL:

VITE_API_URL=http://localhost:5000/api

Note: In development, the Vite dev server proxies /api requests to localhost:5000 automatically, so this is only needed for production builds or non-default setups.

Start the frontend dev server:

npm run dev

The app will be available at http://localhost:5173

4. Seed Sample Data (Optional)

cd Backend
npm run seed

πŸ” API Reference

All endpoints are prefixed with /api. Protected routes require a Bearer token in the Authorization header.

Authentication

Method Endpoint Description Auth
POST /api/auth/signup Register a new user βœ—
POST /api/auth/login Login and receive JWT βœ—
POST /api/auth/logout Logout (client-side) βœ“
GET /api/auth/me Get current user profile βœ“

Student Routes

Method Endpoint Description Auth
GET /api/student/dashboard Dashboard overview βœ“
GET /api/student/courses List enrolled courses βœ“
GET /api/student/attendance All attendance records βœ“
GET /api/student/attendance/:classId Attendance for a class βœ“
POST /api/student/join-class Join a class by code βœ“
POST /api/student/leave-class Leave a class βœ“
POST /api/student/appeal Submit an attendance appeal βœ“
GET /api/student/appeals List submitted appeals βœ“

Teacher Routes

Method Endpoint Description Auth
GET /api/teacher/stats Dashboard statistics βœ“
GET /api/teacher/classes List owned classes βœ“
POST /api/teacher/classes Create a new class βœ“
DELETE /api/teacher/classes/:classId Delete a class βœ“
POST /api/teacher/classes/:classId/students Add students to class βœ“
DELETE /api/teacher/classes/:classId/students/:studentId Remove a student βœ“
GET /api/teacher/attendance/:classId Class attendance records βœ“
GET /api/teacher/session/:sessionId Session detail & results βœ“
GET /api/teacher/appeals List all pending appeals βœ“
PATCH /api/teacher/appeals/:appealId Approve/reject an appeal βœ“
POST /api/teacher/classes/:classId/announcements Post announcement βœ“
DELETE /api/teacher/classes/:classId/announcements/:id Delete announcement βœ“

Attendance

Method Endpoint Description Auth
POST /api/attendance/upload Upload classroom image (multipart/form-data) βœ“

Health Check

Method Endpoint Description Auth
GET /api/health API health status βœ—

πŸ“ Project Structure

Sentry/
β”œβ”€β”€ Backend/
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── db.js                    # MongoDB connection
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ authController.js        # Signup, login, profile
β”‚   β”‚   β”œβ”€β”€ attendanceController.js  # Image upload & processing
β”‚   β”‚   β”œβ”€β”€ studentController.js     # Student dashboard & actions
β”‚   β”‚   └── teacherController.js     # Teacher dashboard & management
β”‚   β”œβ”€β”€ middlewares/
β”‚   β”‚   β”œβ”€β”€ auth.js                  # JWT verification & role guard
β”‚   β”‚   β”œβ”€β”€ upload.js                # Multer file upload config
β”‚   β”‚   └── validate.js              # express-validator runner
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ Appeal.js                # Attendance appeal schema
β”‚   β”‚   β”œβ”€β”€ AttendanceRecord.js      # Per-student attendance entry
β”‚   β”‚   β”œβ”€β”€ AttendanceSession.js     # Photo session metadata
β”‚   β”‚   β”œβ”€β”€ Class.js                 # Course/class schema
β”‚   β”‚   β”œβ”€β”€ Student.js               # Student profile schema
β”‚   β”‚   β”œβ”€β”€ Teacher.js               # Teacher profile schema
β”‚   β”‚   └── User.js                  # Base user (auth) schema
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ auth.js                  # Auth endpoints
β”‚   β”‚   β”œβ”€β”€ attendance.js            # Upload endpoints
β”‚   β”‚   β”œβ”€β”€ student.js               # Student endpoints
β”‚   β”‚   └── teacher.js               # Teacher endpoints
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ attendanceService.js     # Attendance processing logic
β”‚   β”‚   └── faceRecognitionService.js# YOLO + ArcFace API client
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ ApiError.js              # Custom error class
β”‚   β”‚   β”œβ”€β”€ apiResponse.js           # Standardized JSON responses
β”‚   β”‚   β”œβ”€β”€ catchAsync.js            # Async error wrapper
β”‚   β”‚   β”œβ”€β”€ seed.js                  # Database seeder
β”‚   β”‚   └── socket.js                # Socket.IO initialization
β”‚   β”œβ”€β”€ .env.example                 # Environment template
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ run_task.js                  # Data migration script
β”‚   └── server.js                    # App entry point
β”‚
β”œβ”€β”€ Frontend/
β”‚   β”œβ”€β”€ public/                      # Static assets
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ AuthLeftPanel.jsx     # Login/register branding panel
β”‚   β”‚   β”‚   β”œβ”€β”€ Footer.jsx            # App footer
β”‚   β”‚   β”‚   β”œβ”€β”€ MobileAuthBrand.jsx   # Mobile auth branding
β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.jsx            # Student navigation bar
β”‚   β”‚   β”‚   β”œβ”€β”€ ProtectedRoute.jsx    # Route guard by role
β”‚   β”‚   β”‚   └── TeacherNavbar.jsx     # Teacher navigation bar
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”‚   β”œβ”€β”€ AuthContext.jsx       # Auth state provider
β”‚   β”‚   β”‚   β”œβ”€β”€ NavContext.jsx        # Student nav state
β”‚   β”‚   β”‚   └── TeacherNavContext.jsx  # Teacher nav state
β”‚   β”‚   β”œβ”€β”€ Layouts/
β”‚   β”‚   β”‚   β”œβ”€β”€ DashboardLayout.jsx   # Student layout shell
β”‚   β”‚   β”‚   └── TeacherDashboardLayout.jsx # Teacher layout shell
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ LoginPage.jsx         # Login form
β”‚   β”‚   β”‚   β”œβ”€β”€ RegisterPage.jsx      # Registration form
β”‚   β”‚   β”‚   β”œβ”€β”€ student/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ StudentDashboard.jsx  # Student overview
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ StudentCourses.jsx    # Course listings
β”‚   β”‚   β”‚   β”‚   └── StudentSummary.jsx    # Attendance summary
β”‚   β”‚   β”‚   └── teacher/
β”‚   β”‚   β”‚       β”œβ”€β”€ TeacherPage.jsx           # Teacher shell
β”‚   β”‚   β”‚       β”œβ”€β”€ TeacherDashboard.jsx      # Stats & overview
β”‚   β”‚   β”‚       β”œβ”€β”€ TeacherCourses.jsx        # Course management
β”‚   β”‚   β”‚       β”œβ”€β”€ TeacherCourseDetails.jsx  # Detailed class view
β”‚   β”‚   β”‚       └── TeacherAppeals.jsx        # Appeal management
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   β”œβ”€β”€ api.js                # Axios instance & API methods
β”‚   β”‚   β”‚   └── socket.js             # Socket.IO client
β”‚   β”‚   β”œβ”€β”€ App.jsx                   # Root component & routing
β”‚   β”‚   β”œβ”€β”€ main.jsx                  # App entry point
β”‚   β”‚   └── index.css                 # Global styles
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ vite.config.js                # Vite + Tailwind + proxy config
β”‚   β”œβ”€β”€ vercel.json                   # Vercel SPA routing
β”‚   └── package.json
β”‚
└── README.md

πŸ›  Tech Stack

Frontend

Technology Purpose
React 19 UI component library
Vite 8 Build tool & dev server
Tailwind CSS 4 Utility-first styling
React Router 7 Client-side routing
Axios HTTP client
Socket.IO Client Real-time WebSocket communication
Lucide React Icon library

Backend

Technology Purpose
Express.js 4 REST API framework
Mongoose 8 MongoDB ODM
JSON Web Tokens Stateless authentication
Socket.IO 4 Real-time event broadcasting
Multer File upload handling
Helmet HTTP security headers
bcryptjs Password hashing (12 salt rounds)
express-validator Request validation

AI / ML Pipeline

Technology Purpose
YOLOv8 Face detection in classroom images
ArcFace Face embedding & identity matching
FastAPI Model serving (external microservice)

Infrastructure

Service Purpose
MongoDB Atlas Cloud database
Vercel Frontend deployment
Modal AI model hosting (optional)

πŸ”§ Environment Variables

Backend (Backend/.env)

Variable Description Default
PORT Server port 5000
MONGODB_URI MongoDB connection string β€”
JWT_SECRET Secret key for signing JWTs β€”
JWT_EXPIRES_IN Token expiration duration 7d
FACE_RECOGNITION_API_URL URL to the YOLO + ArcFace API β€”
UPLOAD_DIR Directory for uploaded images uploads

Frontend (Frontend/.env)

Variable Description Default
VITE_API_URL Backend API base URL /api (proxied)

🧩 Data Models

User ──┬── Student ──── AttendanceRecord ──── Appeal
       β”‚                      β”‚
       └── Teacher             β”‚
              β”‚                β”‚
           Class ─────── AttendanceSession
              β”‚
         Announcements
Model Key Fields
User name, email, password, role (student/teacher/admin), student_id, department
Student student_id, name, linked User
Teacher teacher_id, name, department, linked User
Class class_name, class_code, teacher, students[], schedule, scheduleDays[], announcements[]
AttendanceSession class, teacher, image_uploaded, recognized_students[], status
AttendanceRecord student, class, session, date, status (present/absent), confidence_score
Appeal student, class, attendanceRecord, date, reason, status (pending/approved/rejected), teacherNote

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -m "feat: add my feature"
  4. Push to the branch: git push origin feature/my-feature
  5. Open a Pull Request

πŸ“„ License

This project is open source and available under the MIT License.


Built with ❀️ by XGNoir95

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages