This is a MERN (MongoDB, Express.js, React, Node.js) authentication system, built for practice purposes. It includes user authentication with secure login and registration functionality.
- User Registration & Login with JWT authentication
- Password Hashing using bcrypt
- Protected Routes for authenticated users
- Session Persistence using local storage
- Frontend Validation for user input
- Role-Based Access Control (RBAC) (optional enhancement)
- Email Verification (optional enhancement)
- React.js
- React Router
- Axios
- Tailwind CSS (for styling)
- Node.js
- Express.js
- MongoDB (Mongoose ODM)
- JWT (JSON Web Token) for authentication
- Bcrypt.js for password hashing
- CORS for handling cross-origin requests
- Node.js installed
- MongoDB running (locally or via cloud service like MongoDB Atlas)
- Git installed
-
Clone the repository
git clone https://github.com/MananHere576/MERN-Auth.git cd MERN-Auth -
Backend Setup
cd backend npm install npm startEnsure MongoDB is running and configure the
.envfile with your database URL and JWT secret. -
Frontend Setup
cd ../frontend npm install npm start -
Access the Application Open your browser and navigate to:
http://localhost:3000
Create a .env file in the backend directory and add:
PORT=8080
MONGO_CONN="your_mongodb_connection_string"
JWT_SECRET="your_jwt_secret"In the frontend, create a .env file and add:
REACT_APP_API_URL=http://localhost:5000MERN-Auth/
│-- backend/
│ │-- Controllers/
│ │-- Middlewares/
│ │-- Models/
│ │-- Routes/
│ │-- index.js
│ │-- package.json
│ │-- .env (to be configured)
│-- frontend/
│ │-- src/
│ │-- public/
│ │-- package.json
│-- README.md
| Endpoint | Method | Description |
|---|---|---|
/api/auth/signup |
POST | Register a new user |
/api/auth/login |
POST | Authenticate user and return JWT |
/api/auth/me |
GET | Get user details (protected) |
/api/auth/logout |
POST | Logout user and clear session |
- OAuth-based login (Google, GitHub, etc.)
- Email verification during signup
- Multi-factor authentication (MFA)
- Password reset functionality
- Admin dashboard for user management
Created by Manan for learning and practice purposes. 🚀
Feel free to contribute or provide feedback!