This project is a full-stack authentication system built with Node.js, Express, MongoDB, and React (Vite). It provides a secure and scalable authentication workflow with features like JWT + cookie-based login, OTP-based email verification, password reset, and protected routes.
- User Registration & Login
- JWT-based Authentication (with Cookies)
- Email Verification via OTP
- Password Reset with OTP
- Protected Routes for Authenticated Users
- Modular Backend with Express Routes & Middleware
- Backend: Node.js, Express.js, MongoDB, JWT, Cookie-Parser, CORS
- Frontend: React (Vite), Axios, Tailwind CSS
root/
│── server/ # Backend (Node.js + Express + MongoDB)
│── client/ # Frontend (React + Vite)
│── .gitignore
│── README.md
git clone https://github.com/Shreya11G/Authentication_App.git
cd Authentication_Appcd server
npm installCreate a .env file in the server/ folder with the following variables:
PORT=4000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secretRun the backend:
npm startcd ../client
npm installCreate a .env file in the client/ folder with:
VITE_BACKEND_URL=http://localhost:4000Run the frontend:
npm run devPOST /api/auth/register→ Register a new userPOST /api/auth/login→ Login userPOST /api/auth/logout→ Logout userPOST /api/auth/send-verify-otp→ Send OTP for email verificationPOST /api/auth/verify-account→ Verify email with OTPPOST /api/auth/send-reset-otp→ Send OTP for password resetPOST /api/auth/reset-password→ Reset password
- Use Postman or the frontend client to test authentication flows.
- Make sure MongoDB is running and
.envvariables are correctly set.