Skip to content

A high-performance attendance system using Next.js with and ML-server using Flask, RetinaFace for face detection and ArcFace for recognition, achieving 95%+ accuracy. Deployed on Azure with Prometheus and Grafana for monitoring and alerting.

Notifications You must be signed in to change notification settings

hsanirudh/FaceMark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Facemark – Group Attendance Monitoring System

A full-stack web application for group attendance tracking using facial recognition technology.

πŸš€ Features

  • Facial Recognition: Advanced AI-powered face detection using RetinaFace and ArcFace
  • Authentication: Secure login with NextAuth.js and Google OAuth
  • Real-time Analytics: Comprehensive dashboards with Recharts visualization
  • Monitoring: Prometheus metrics integration with Grafana dashboards
  • Data Export: CSV/Excel export functionality for attendance records
  • Responsive Design: Modern UI with shadcn/ui components and Framer Motion animations

πŸŽ₯ Demo

overview.mp4

Main demo showing facial recognition, dataset management, and real-time analytics

Watch the video above for a walkthrough of the Facemark system, including facial recognition, dataset management, and real-time analytics in action.

πŸ—οΈ Architecture

Monorepo Structure (Turborepo)

facemark/
β”œβ”€β”€ apps/
|   β”œβ”€β”€ web/           # Next.js web application
|   └── ml-service/    # Flask microservice for face recognition
β”œβ”€β”€ infra/
    β”œβ”€β”€ grafana/       # Grafana Dashboards for visualisation 
    └── prometheus/    # Prometheus for logging and monitoring

Tech Stack

Frontend & Server:

  • Next.js 14 (App Router)
  • TypeScript
  • TailwindCSS
  • shadcn/ui components
  • Framer Motion animations
  • Recharts for analytics

Backend ML Service:

  • Python Flask
  • RetinaFace (face detection)
  • ArcFace (face recognition)
  • OpenCV
  • scikit-learn

Database & Auth:

  • PostgreSQL with Prisma ORM
  • NextAuth.js with Google OAuth

Monitoring:

  • Prometheus metrics
  • Grafana dashboards
Grafana.mp4

Grafana dashboard overview and monitoring features

πŸ“¦ Installation

Prerequisites

  • Node.js 22
  • Python 3.12
  • PostgreSQL
  • pnpm

Setup

  1. Clone the repository
git clone https://github.com/hsanirudh/facemark.git 
`cd facemark
  1. Install dependencies
pnpm install
  1. Environment Configuration Copy apps/web/env.example to apps/web/.env and configure:
DATABASE_URL="postgresql://username:password@localhost:5432/facemark"
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-secret-key"
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"
FLASK_SERVICE_URL="http://localhost:5000"
PROMETHEUS_URL="http://localhost:9090"
  1. Database Setup
cd apps/web
npx prisma migrate dev
npx prisma generate
  1. ML Service Setup
cd apps/ml-service
pip install -r requirements.txt

πŸš€ Running the Application

Development Mode

  1. Start all services
pnpm dev

This starts:

Individual Services

Web Application:

cd apps/web
pnpm dev

ML Service:

cd apps/ml-service
python app.py

πŸ“Š Dataset Setup

Create the face recognition dataset in the following structure:

apps/ml-service/dataset/
β”œβ”€β”€ Alex/
β”‚   β”œβ”€β”€ img1.jpg
β”‚   β”œβ”€β”€ img2.jpg
β”‚   └── img3.jpg
β”œβ”€β”€ Nat/
β”‚   β”œβ”€β”€ img1.jpg
β”‚   └── img2.jpg
└── ...

Each person should have multiple high-quality face images for better recognition accuracy.

πŸ”§ API Endpoints

Web Application APIs

  • POST /api/attendance - Process attendance with image upload
  • GET /api/attendance - Fetch attendance records
  • GET /api/metrics - Prometheus metrics export
  • GET /api/auth/[...nextauth] - NextAuth endpoints

ML Service APIs

  • POST /recognize_faces - Face recognition from image
  • POST /detect_faces - Face detection only
  • POST /dataset/add - Add images to dataset
  • GET /dataset/list - List dataset entries
  • GET /metrics - ML service metrics
  • GET /health - Health check

πŸ“ˆ Monitoring

Prometheus Metrics

The application tracks:

  • Authentication events
  • Attendance processing events
  • API request durations
  • Face detection/recognition metrics

Access metrics at:

Grafana Dashboard

Import the provided Grafana dashboard configuration to visualize:

  • System performance
  • Recognition accuracy
  • Usage patterns

🎨 UI Components

Built with shadcn/ui components:

  • Responsive cards and layouts
  • Animated buttons and interactions
  • Modern typography and spacing

πŸ” Security Features

  • Secure session management
  • Input validation and sanitization

πŸš€ Deployment

Docker Deployment

# Build and run with Docker Compose
docker-compose up -d

Production Build

# Build all applications
pnpm build

# Start production server
pnpm start

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

πŸ™‹β€β™‚οΈ Support

For support and questions:

  • Create an issue on GitHub
  • Check the documentation
  • Contact the development team

About

A high-performance attendance system using Next.js with and ML-server using Flask, RetinaFace for face detection and ArcFace for recognition, achieving 95%+ accuracy. Deployed on Azure with Prometheus and Grafana for monitoring and alerting.

Topics

Resources

Stars

Watchers

Forks