A Flask-based attendance system built for schools with face recognition, 100m geofencing, offline-first syncing, and real-time alerts. Includes teacher and student dashboards with a polished Tailwind UI and dark mode.
static/.attendence-app/
├─ main.py # Flask app + routes (APIs, guards, helpers)
├─ modules/
│ ├─ database.py # MySQL connection + small helper migrations
│ └─ register.py # Face encoding utilities
├─ templates/
│ ├─ index.html # Landing page
│ ├─ auth.html # Login / Register
│ ├─ dashboard.html # Teacher dashboard
│ └─ student_dashboard.html# Student dashboard
├─ static/
│ ├─ student.js # Student interactions + offline sync
│ ├─ indexedDB.js # IndexedDB helpers
│ ├─ service-worker.js # Offline + background sync
│ └─ manifest.json # PWA manifest
├─ ca.pem # MySQL CA cert (SSL)
├─ requirements.txt # Python deps (see below for full list)
└─ README.md
face_recognition may require prebuilt wheels for dlib and opencv-python. If pip fails to build, search for precompiled wheels matching your Python version.python -m venv .venv
.\.venv\Scripts\Activate.ps1
python3 -m venv .venv
source .venv/bin/activate
requirements.txt or install packages directly:pip install flask flask-socketio eventlet mysql-connector-python face-recognition opencv-python numpy
If installation of face-recognition fails, try:pip install face-recognition-models
modules/database.py and references ca.pem.os.getenv). Example variables:CREATE TABLE IF NOT EXISTS teachers (
id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(100) NOT NULL,
last_name VARCHAR(100) NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
school_name VARCHAR(255),
latitude DECIMAL(10,8) NULL,
longitude DECIMAL(11,8) NULL
);
CREATE TABLE IF NOT EXISTS students (
id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(100) NOT NULL,
last_name VARCHAR(100) NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
student_id VARCHAR(100) UNIQUE NOT NULL,
face_data LONGBLOB NULL,
face_encoding LONGBLOB NULL
);
CREATE TABLE IF NOT EXISTS attendance (
id INT AUTO_INCREMENT PRIMARY KEY,
student_id INT NOT NULL,
enrollment_no VARCHAR(100) NOT NULL,
name VARCHAR(255) NOT NULL,
status ENUM('Present','Absent') NOT NULL,
marked_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (student_id) REFERENCES students(id)
);
CREATE TABLE IF NOT EXISTS manual_attendance_requests (
id INT AUTO_INCREMENT PRIMARY KEY,
student_id INT NOT NULL,
requested_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (student_id) REFERENCES students(id)
);
$env:FLASK_APP = "main.py"
$env:FLASK_ENV = "development"
flask run
export FLASK_APP=main.py
export FLASK_ENV=development
flask run
Notes:
eventlet:python -c "from main import app, socketio; socketio.run(app, host='0.0.0.0', port=5000)"
POST /login/student (form) — loginPOST /register/student (form + face image) — registrationPOST /api/verify-face — verifies face from webcam capturePOST /api/sync-attendance — offline sync with server-side re-verification and optional geofencingPOST /api/request-manual-attendance — asks teacher to mark presentGET /api/student-monthly-stats — monthly statsPOST /login/teacher, POST /register/teacherGET /api/summary — counts for dashboardGET /api/get-present-students — listPOST /api/mark-attendance — manual mark by enrollment noPOST /api/mark-all-present / POST /api/mark-all-absentGET /api/manual-attendance-requests — pending manual requestsPOST /api/handle-manual-attendance-request — approve/ignorePOST /api/set-teacher-location — saves teacher latitude/longitudestatic/indexedDB.js.static/service-worker.js) registers a background sync task sync-attendance./api/sync-attendance. The server:localStorage.ca.pem.dlib/face_recognition:opencv-python installed. For headless servers, opencv-python-headless may be preferable.eventlet or a production server that supports websockets.Specify your project’s license here.# EduConnect