Ai-Face-recognition-Attendance-system: The Face Scan That Becomes a Web App

A FastAPI attendance system that turns webcam frames into check-ins and check-outs, stores facial embeddings in MySQL, and keeps the stack simpler than you would expect.

8 min read • View on GitHub • More from sudip17x

A wide editorial scene shows a webcam, a compact processing box, and a stamped attendance ledger arranged left to right on a clean white field. The image explains how a browser capture becomes a database-backed attendance event, with check-in and check-out as the two visible outcomes.
The core move is simple: a face scan becomes a web request, then a state change.
Key Takeaways

Face recognition usually gets sold as spectacle. This repo uses it as plumbing. A browser webcam frame becomes a JSON payload, a matching routine finds the employee, and the database decides whether this is a check-in or a check-out.

That is the interesting move. The system does not ask you to adopt a heavy biometric platform or a custom client app. It behaves like a normal FastAPI service with a single intelligent step in the middle.

The punch-card, reborn as a web request

The workflow is straightforward enough to fit in one breath: capture a frame in the browser, send it as Base64, decode it on the server, compare the face embedding, then write an attendance row. That makes the app feel less like a lab demo and more like a thin operational layer over a familiar business process.

Face recognition-based attendance system using Python and OpenCV.

Sudip Mandal, Author/Maintainer · sudip17x/Ai-Face-recognition-Attendance-system

Why this stack is the point

The repo uses the kind of stack a small team can actually run: FastAPI, SQLAlchemy, Pydantic, JWT, bcrypt, Docker, and MySQL. Nothing exotic is hiding behind the curtain.

ApproachHardware requiredSetup complexityUser frictionScale fitBest fit
Manual logsNoneVery lowHighAny size, but error-proneTiny teams and low stakes
RFID or card systemReader and cardsLow to mediumMediumGood for standard officesAccess control with simple identity
This repoWebcam and browserMediumLowSmall to mid-size deploymentsAttendance with low operational overhead
Heavy commercial biometricsDedicated devices and licensingHighLowLarge enterpriseCentralized, vendor-managed security

The app is really a pipeline that converts a browser frame into a state change, then persists the result in relational form.

The recognition engine is intentionally simple

In app/recognition.py, the project uses the familiar 128-dimensional face embedding pattern from face_recognition, then compares known and unknown faces with Euclidean distance. The result is a nearest-match decision wrapped in a confidence score that is easier for a human to read.

A close-up editorial illustration shows a face image being compressed into a string of 128 small nodes, then compared against a shelf of stored embeddings. One matching path lights up and drops into a daily attendance slot. The image explains how the system identifies a person without a dedicated vector database.
The cleverness is not the model. It is the decision to make the matching step compact enough to fit inside a normal web app.

That simplicity matters because the project is trying to operationalize recognition, not invent a new model. It is a production-shaped wrapper around an established technique.

MySQL is doing more than storage

The data model is where the repo stops looking like a demo. Employee encodings are stored as serialized text, attendance rows use a unique constraint on employee and date, and inactive employees are soft-deleted with an is_active flag.

That is a sensible set of tradeoffs. It preserves history, avoids recomputing embeddings on every request, and keeps same-day attendance behavior explicit instead of magical.

What the database is really tracking


Why the startup path matters

The FastAPI lifespan pattern gives the app a real service boundary. On startup, it verifies the database, creates tables, and seeds a default admin, which makes the first run feel intentional instead of improvised.

That matters more than it sounds. A lot of open-source biometric projects stop at the prototype. This one does at least enough bootstrapping to suggest how it would behave in deployment.

Security is basic, but disciplined

The auth layer is not trying to be an identity platform. It uses JWT, protected dependencies, and a superadmin boundary for sensitive actions, which is the right size for a small attendance service.

ControlWhat it protectsWhat it does wellWhat it does not solve
JWT authSession accessKeeps endpoints authenticatedDoes not replace enterprise identity
Admin dependenciesAdministrative routesSeparates everyday use from managementDoes not add fine-grained policy by itself
Superadmin boundaryHigh-risk actionsPrevents casual privilege escalationStill needs operational discipline
Soft deletesEmployee lifecyclePreserves records after deactivationDoes not handle broader compliance needs

Where this sits in the market

Compared with manual logs and RFID cards, the repo removes a repeated human task. Compared with heavy commercial biometrics, it removes a lot of vendor dependence. That is its niche: ordinary software discipline applied to a biometric workflow.

OptionWhy teams choose itWhy teams outgrow it
Manual attendanceNo hardware and almost no setupSlow, lossy, and easy to falsify
RFID cardsCheap and familiarCards are shareable and still require hardware
This repoLow-friction webcam workflow with simple web opsMatching and storage choices will not scale forever
Commercial biometricsManaged infrastructure and supportCost, lock-in, and less control over the data model

The limitation is also clear. In-memory matching and serialized encodings are pragmatic for small deployments, but they are not a long-term answer for very large populations. The repo accepts that constraint instead of pretending it does not exist.

The tradeoffs are the story

This project is compelling because it makes the right compromises for its target use case. It gives you a biometric attendance system that feels like a web app, behaves like a state machine, and avoids unnecessary infrastructure while still looking production-minded.