A secure and modern full-stack authentication system built using the MERN Stack (MongoDB, Express.js, React.js, Node.js). This project provides robust authentication with JWT, protected routes, and security best practices for real-world production apps.
- 🔐 JWT (JSON Web Token) Authentication
- 🔄 User Login & Registration with hashed passwords (bcrypt)
- ✅ Protected Routes for authenticated users only
- 💾 MongoDB with Mongoose for flexible data models
- ⚙️ Express.js API with proper middlewares
- 🌐 React.js Frontend using Context API or Redux
- 📦 Node.js Backend with modular route handling
- 📬 Error Handling with user-friendly messages
- 🧠 Token Storage via HTTP-only cookies or localStorage
- 🔄 Auto Login on page refresh (token-based auth)
- 🚫 Logout Functionality
- 🔐 Secure headers & CORS enabled
Frontend:
- React.js
- Axios
- Tailwind CSS
- React Router DOM
Backend:
- Node.js
- Express.js
- MongoDB (with Mongoose)
- JSON Web Token (JWT)
- HTTP-Only cookies
- Bcrypt for password hashing
- dotenv for environment variables
- CORS middleware
Install all packages in both client/ and server/ folders:
- cd client
- npm i
- cd server
- npm i
read the .env.example file and create .env file based on the .env.example file