A web-based attendance management system using face recognition technology built with FastAPI and React.
- JWT-based authentication
- User registration and login
- Role-based access control (Admin and User roles)
- Password hashing with bcrypt
- User profile management
- Face registration with multiple image captures
- Face recognition for attendance marking
- Uses face_recognition library (dlib-based)
- Stores face encodings locally using pickle format
- Face recognition-based attendance marking
- Manual attendance management (Admin)
- Attendance history tracking
- Daily attendance status (Present/Absent)
- Time-in recording
- Admin Dashboard: User management, attendance overview, manual attendance updates
- Employee Dashboard: Personal attendance history and statistics
- Analytics Dashboard: Attendance trends, department performance, export functionality
- Export attendance data to PDF, Excel, CSV, JSON formats
- Attendance statistics and analytics
- Department-wise analytics
- FastAPI - Python web framework
- SQLite - Database with SQLAlchemy ORM
- face_recognition - Face recognition library (dlib-based)
- OpenCV - Image processing
- JWT - Authentication tokens
- Bcrypt - Password hashing
- React 18 - UI framework
- Material-UI (MUI) - Component library
- React Router - Routing
- Recharts - Data visualization
- React Webcam - Camera access
- Python 3.8 or higher
- Node.js 16 or higher
- Webcam for face recognition
# Navigate to backend directory
cd backend
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Run the server
uvicorn main:app --reload --host 0.0.0.0 --port 8000The backend API will be available at http://localhost:8000
API documentation available at http://localhost:8000/docs
# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# Start development server
npm startThe frontend will be available at http://localhost:3000
- Start both backend and frontend servers
- Register a new user account
- For the first user, run the migration script to assign admin role:
cd backend python migrate_add_role.py
- Register with email and password
- Login to your account
- Navigate to Face Registration
- Capture 5-6 face images for enrollment
- Once registered, you can mark attendance using face recognition
- Navigate to "Mark Attendance" page
- Click "Mark Attendance" button
- Position your face in front of the camera
- System will recognize your face and mark attendance
- View all users and their attendance records
- Manually mark attendance for users
- View analytics and export reports
- Update user information
Smart_Attendance_System/
├── backend/
│ ├── main.py # FastAPI application
│ ├── models.py # Database models
│ ├── schemas.py # Pydantic schemas
│ ├── database.py # Database configuration
│ ├── auth.py # Authentication utilities
│ ├── face_recognition_service.py # Face recognition logic
│ ├── migrate_add_role.py # Role migration script
│ ├── requirements.txt # Python dependencies
│ ├── dataset/ # Face encoding storage (gitignored)
│ └── uploads/ # Temporary uploads (gitignored)
│
├── frontend/
│ ├── public/
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── services/ # API services
│ │ ├── App.js # Main app component
│ │ └── index.js # Entry point
│ └── package.json
│
├── requirements.txt # Root requirements (for scripts)
├── README.md
└── .gitignore
POST /auth/register- User registrationPOST /auth/login- User login
POST /face/register- Register face dataPOST /attendance/mark- Mark attendance via face recognition
GET /user/profile- Get user profilePUT /user/profile- Update user profilePUT /user/password- Change passwordGET /user/attendance- Get attendance historyGET /user/attendance/stats- Get attendance statistics
GET /admin/users- Get all usersGET /admin/attendance- Get all attendance recordsPUT /admin/attendance/{id}- Update attendance recordPOST /admin/mark-absent- Mark users as absentPOST /admin/attendance/bulk-update- Bulk update attendance
GET /analytics/dashboard- Get dashboard analyticsGET /analytics/anomalies- Get anomaly detection dataGET /analytics/report- Get report data
Full API documentation available at /docs when backend is running.
Create a .env file in the backend directory (optional):
SECRET_KEY=your-secret-key-here
ACCESS_TOKEN_EXPIRE_MINUTES=30Create a .env file in the frontend directory (optional):
REACT_APP_API_URL=http://localhost:8000The system uses SQLite database which is automatically created on first run. Database file: backend/attendance_system.db
To reset the database, delete the .db file and restart the backend server.
- Ensure good lighting conditions
- Clear camera lens
- Register with 5-6 clear face images
- Face should be clearly visible in frame
- Allow camera permissions in browser
- Use HTTPS in production (required for camera access)
- Ensure no other application is using the camera
- Ensure Python 3.8+ and Node.js 16+ are installed
- Use virtual environment for Python dependencies
- If face_recognition installation fails, install cmake and dlib dependencies first
This project is licensed under the MIT License.