This is a MERN (MongoDB, Express.js, React.js, Node.js) Authentication System that includes:
- User signup & login with OTP verification
- Forgot password functionality
- Secure authentication using JWT tokens
- Role-based access control (Admin/User)
- RESTful API structure
- Fully responsive frontend using React & TailwindCSS
- React.js
- TailwindCSS
- Axios (for API calls)
- Node.js
- Express.js
- MongoDB (Mongoose for schema management)
- JSON Web Tokens (JWT) for authentication
- bcrypt.js for password hashing
- Nodemailer for sending OTP emails
✅ User Registration with OTP verification
✅ Secure Login with JWT
✅ Forgot Password & Reset Password via Email
✅ Role-based Authentication (Admin/User)
✅ Protected Routes (Only authenticated users can access certain pages)
✅ Session Expiry & Token Refresh
✅ Responsive UI with TailwindCSS
✅ RESTful API following best practices
git clone https://github.com/yourusername/mern-auth.git
cd mern-authCreate a .env file in the root directory and add the following:
MONGO_URL=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
NODE_ENV='development'
SMPT_USER=your_email@example.com
SMPT_PASS=your_email_passwordcd server
npm installcd client
npm installcd server
npm startcd client
npm startNow, your authentication system should be running locally! 🎉
| Method | Endpoint | Description |
|---|---|---|
| POST | /register | Register a new user with OTP |
| POST | /verify-otp | Verify OTP for registration |
| POST | /login | Login user and get JWT token |
| POST | /forgot-password | Send reset password link |
| POST | /reset-password | Reset password using token |
| GET | /me | Get logged-in user details |
- Push your code to GitHub.
- Deploy the backend on Render or Vercel.
- Connect your MongoDB database (MongoDB Atlas recommended).
- Push your React code to GitHub.
- Deploy the frontend on Vercel or Netlify.
Feel free to contribute! Open a PR or issue if you have any suggestions.
This project is licensed under the MIT License.
- GitHub: [@Aditya07771]
- Email: [adityanishad753@gmail.com]
- LinkedIn: [https://www.linkedin.com/in/aditya-nishad-59a30b290/]


