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
git clone https://github.com/CS253-Mess-Management/Final-codes.git
cd Final-codes/Make sure you are in the root directory of the project.
pip install fastapi uvicorn opencv-contrib-python numpy python-multipart pydanticuvicorn main:app --port 8000 --reloadMake sure you are in the root directory of the project.
cd "Mess automation login page"npm installnpm run devMake sure you are in the root directory of the project.
cd Mess_Management_Backend/npm installPORT=5000
DB_URL=...
JWT_SECRET=...
EMAIL_USER=...
EMAIL_PASS=...
node src/seed.js Manadatory to get approve by manager after new regesteration of new students as this will add a default Manager
email : manager@mess.com
password : abcd1234
NOTE :
- Newly registered students cannot log in immediately.
- A Manager must approve each student before they are allowed access to the system.
npm run dev-
Ensure Python and Node.js are installed.
-
Run all services in separate terminals.
-
Default ports:
- FastAPI:
8000 - Frontend:
5173 - Backend:
5000
- FastAPI:
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