A secure and scalable authentication system built with MongoDB, Express.js, React, and Node.js (MERN).
This application provides user registration, login, JWT authentication, and protected routes, serving as a foundation for any full-stack web app.
- User Registration & Login with JWT
- Password Hashing using bcrypt
- Email Verification workflow
- Password Reset with secure tokens
- Persistent Sessions with refresh tokens
- Protected Routes with JWT middleware
- Token Expiry & Refresh Mechanism
- CORS-enabled API for secure frontend-backend communication
- Environment Variables for sensitive configuration
- Modern UI built with React & TailwindCSS
- Form Validation with helpful error messages
- Responsive Design (Desktop, Tablet, Mobile)
- Toast Notifications for feedback
- React.js - UI Framework
- TailwindCSS - Styling framework
- React Router DOM - Client-side routing
- Axios - API requests
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - Database
- Mongoose - ODM for MongoDB
- JWT - Authentication
- bcrypt.js - Password hashing
- dotenv - Environment configuration
- CORS - Cross-origin resource sharing
- Node.js (v16 or higher)
- MongoDB (local or cloud instance, e.g. MongoDB Atlas)
- npm package manager
- Clone the repository
git clone https://github.com/ChandrakantaMandal/Authentication.git cd Authentication - Install Backend Dependencies
cd backend npm install - Install Frontend Dependencies
cd backend npm install
4.Setup Environment Variables -In the backend folder, .env.example as the .env file
1.Start the Backend Server
cd backend
npm run devRuns on http://localhost:8080
1.Start the Frontend Development Server*
cd frontend
npm run devRuns on http://localhost:5173
1.User registers or logs in → receives a JWT token
2.Token stored in localStorage (frontend)
3.Requests to protected routes include the token in Authorization headers
4.Server verifies token via middleware → grants access
- Set environment variables in deployment platform
- Connect MongoDB Atlas
- Update CORS configuration
- Run npm run build in frontend
- Deploy dist folder to hosting service
- Update API URL in Axios config
-
Fork the project
-
Create a new branch (git checkout -b feature/myFeature)
-
Update API URL in Axios config
-
Commit your changes (git commit -m "Added new feature")
-
Push to branch (git push origin feature/myFeature)
-
Open a Pull Request
-
This project is licensed under the MIT License – see the LICENSE file for details.
- GitHub:ChandrakantaMandal