A comprehensive Face Attendance System featuring an Admin Dashboard, Face Recognition API, and Student Identification/Attendance Tracking.
- Admin Dashboard (React + Vite): Manage teachers, students, classes, and view attendance records with a premium UI.
- Face Recognition API (Python + DeepFace): Handles face enrollment, synchronization, and real-time recognition using VGG-Face models.
- Backend API (Node.js + Express): Manages authentication, database operations, and syncs between the dashboard and database.
- Database (Supabase): Stores user profiles, classes, timetables, attendance logs, and face images.
- Frontend: React, Tailwind CSS, Vite
- Backend: Node.js, Express
- AI/ML: Python 3.10+, DeepFace, OpenCV
- Database: Supabase (PostgreSQL)
Before running the project, ensure you have the following installed:
- Node.js (v18 or higher)
- Python (v3.10 or higher)
- Supabase Account (for database and storage)
- Create a new project in Supabase.
- Go to the SQL Editor in your Supabase dashboard.
- Open the file
supabase/database_setup.sqlfrom this repository. - Copy the content and run it in the Supabase SQL Editor. This will:
- Create all necessary tables (profiles, classes, attendance, etc.).
- Set up Row Level Security (RLS) policies.
- Create the
face-imagesstorage bucket.
- Go to Project Settings > API and copy:
- Project URL (
SUPABASE_URL) - anon public key (
SUPABASE_ANON_KEY) - service_role secret (
SUPABASE_SERVICE_ROLE_KEY)
- Project URL (
You need to create .env files in three locations.
Create a file named .env in the facefrontend directory:
VITE_SUPABASE_URL=your_supabase_project_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
VITE_API_URL=http://localhost:5001
VITE_PYTHON_API_URL=http://localhost:5006Create a file named .env in the server.../server directory:
SUPABASE_URL=your_supabase_project_url
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
PORT=5001Create a file named .env in the python-face-api.../python-face-api directory:
SUPABASE_URL=your_supabase_project_url
SUPABASE_ANON_KEY=your_supabase_anon_keyFrontend:
cd facefrontend
npm installAdmin Backend:
cd server-20251120T131707Z-1-001/server
npm installPython API:
cd python-face-api-20251120T131704Z-1-001/python-face-api
pip install -r requirements.txt(If requirements.txt is missing, install: pip install flask flask-cors opencv-python numpy deepface supabase python-dotenv tf-keras)
To start all services (Frontend, Backend, and AI API) simultaneously:
- Double-click
start_all.batin the root directory. - This will verify your setup and launch three separate terminal windows.
- React Frontend: Opens on
http://localhost:5173 - Admin API: Runs on
http://localhost:5001 - Face Recognition API: Runs on
http://localhost:5006
- React Frontend: Opens on
To stop all running services:
- Go to the Face Attendance Launcher window (the first one that opened).
- Press ANY KEY.
- The script will automatically terminate all associated terminals and processes.
- Database Errors: Ensure you ran the
database_setup.sqlscript completely. - Face Recognition: The first run might take time as
DeepFacedownloads model weights. - Port Conflicts: Ensure ports 5173, 5001, and 5006 are free.
The system operates as a distributed application with three distinct services communicating to provide face-based attendance.
graph TD
User[User / Student] -->|Access| F[Frontend (React)]
Admin[Admin / Teacher] -->|Access| F
subgraph "Frontend Layer"
F -->|Auth & Data| S[Supabase (Auth/DB)]
F -->|Admin Actions| B[Admin Backend (Node.js)]
F -->|Face Rec| P[Face Recognition API (Python)]
end
subgraph "Data Layer"
S -->|Users/Attendance| DB[(PostgreSQL)]
S -->|Images| ST[(Storage Bucket)]
end
subgraph "Service Layer"
B -->|Manage Users| S
P -->|Sync Faces| ST
P -->|Match Faces| DeepFace[DeepFace Model]
end
- Supabase Auth is the primary identity provider.
- Admins (Teachers) are created via the Admin Backend (
/api/admin/create-teacher), which wraps Supabase methods to ensureprofilestable consistency. - Students are similarly created via the Backend to generate standardized credentials (USN/Password).
- Capture: Frontend captures an image via the webcam.
- Upload: Image is uploaded directly to Supabase Storage (
face-imagesbucket) with a filename formatUSN-TIMESTAMP.jpg. - Sync: Python API periodically (or on trigger) scans the storage bucket.
- Embedding:
DeepFacegenerates a vector embedding for the face and caches it locally infaces/.pkl.
- Recognition: Frontend sends a webcam frame to Python API (
/recognize). - Matching: Python API compares the frame against the local cache using VGG-Face.
- Verification: If a match is found (Distance < Threshold), the USN is returned.
- Logging: Frontend sends the recognized USN + Timestamp to the Admin Backend.
- Record: Admin Backend inserts a record into the
attendancetable in Supabase.
Node.js Backend:
- Open
server-2025.../server/server.js. - Add a new route:
app.get('/api/new-endpoint', async (req, res) => { // Your logic here });
- Restart the server (if not using nodemon).
Python Face API:
- Open
python-face-api.../python-face-api/recognize_api.py. - Add a new route:
@app.route("/new-action", methods=["POST"]) def new_action(): return jsonify({"status": "done"})
- Logs: Check the Python terminal window for
Distancevalues.Distance < 0.4usually implies a match.- If valid faces are not matching, check lighting or try
Syncagain.
- Cache: If strange errors occur, delete the
.pklfiles in thefaces/directory and restart the Python API to rebuild the cache.
expert-guacamole/
├── facefrontend/ # [React + Vite] User Interface
│ ├── src/
│ │ ├── pages/ # Dashboard, Login, Student Portal
│ │ ├── components/ # Reusable UI elements
│ │ └── supabaseClient.js # Supabase Connection
│ └── .env # Frontend Config
│
├── server-2025.../server/ # [Node.js + Express] Admin Logic
│ ├── server.js # Main Application Logic
│ └── .env # Backend Config (Service Role)
│
├── python-face-api.../ # [Flask + DeepFace] AI Engine
│ ├── recognize_api.py # API Entry Point
│ ├── faces/ # Local Face Cache (GitIgnored)
│ └── .env # AI Service Config
│
├── supabase/ # Database Schema
│ └── database_setup.sql # Run this to init DB
│
└── start_all.bat # Master startup script
- Base URL:
http://localhost:5001 GET /- Health Check.POST /api/admin/create-student- Register a new student User+Profile.POST /api/admin/create-teacher- Register a new teacher User+Profile.GET /api/teacher/dashboard-stats- Get aggregate attendance stats.GET /api/reports/custom- Generate CSV reports (Summary/Detailed).
- Base URL:
http://localhost:5006 POST /recognize- Input:{ image: "base64..." }| Output:[{ usn, confidence }]POST /sync- Triggers download of new face images from Supabase.GET /health- Service status check.