A full-stack authentication system that uses OpenCV (LBPH) for face recognition and PostgreSQL for user data management.
React.js, Vite, React-Webcam
Node.js, Express, PG (PostgreSQL driver)
Python, FastAPI, OpenCV
PostgreSQL
Create a database named facereco and run the following SQL command to create the user table:
CREATE TABLE students ( id SERIAL PRIMARY KEY, face_id INTEGER UNIQUE NOT NULL, name VARCHAR(100), email VARCHAR(100), last_login TIMESTAMP DEFAULT CURRENT_TIMESTAMP );
Download Requirments , create a virtual environment , start servers
Run the commands inside project folder
- python -venv venv
- python\scipts\activate
- pip install fastapi uvicorn opencv-contrib-python numpy Pilow
- start python server: uvicorn main:app --reload --port 8000
Open a new terminal in parallel
Run the commands inside project folder:
- npm install express cors axios pg
- start backend server:node server.js
Navigate to the frontend folder(cd frontend) inside the project folder, then run in a new parallel terminal
- npm install react-webcam react-router-dom
- Start fontend server: npm run dev
React captures a base64 image and sends it to Node.js (Port 5000).
Node.js forwards the image to Python (Port 8000).
If the AI recognizes you (e.g., ID 1), Node looks for you in PostgreSQL. If found, it logs you in. If not found in the DB (but known by AI), it auto-appends a record to sync them.
If the AI doesn't recognize you, Node triggers train_my_face.py locally to start a new training session and adds a new record to the Database.
Camera Lock: The React webcam must be turned off when train_my_face.py starts, otherwise the Python script will crash (only one app can use the camera at a time).
Ports:
- React: 5173
Node.js: 5000
Python AI: 8000