A simple Full-Stack Authentication Website built using the MERN Stack. This project focuses on implementing secure User Signup and Login functionality with a React frontend and Node.js/Express backend connected to MongoDB.
- ✅ User Registration / Signup
- ✅ User Login
- ✅ User Authentication
- ✅ Password Hashing using bcrypt
- ✅ JWT-based Authentication
- ✅ Protected API Routes
- ✅ MongoDB Database Integration
- ✅ REST API using Express.js
- ✅ React-based Frontend
- ✅ Responsive and clean UI
- ✅ Logout functionality
- React.js
- JavaScript
- HTML5
- CSS3
- Axios
- Vite
- Node.js
- Express.js
- MongoDB
- Mongoose
- JWT
- bcrypt
- Cookie Parser
- CORS
full-stack/
│
├── Backend/
│ ├── controllers/
│ ├── models/
│ ├── routes/
│ ├── middleware/
│ ├── utils/
│ ├── server.js
│ └── package.json
│
├── Frontend/
│ ├── src/
│ │ ├── components/
│ │ ├── pages/
│ │ ├── redux/
│ │ ├── services/
│ │ └── App.jsx
│ ├── package.json
│ └── vite.config.js
│
├── .gitignore
├── Dockerfile
└── README.md
User
│
▼
React Frontend
│
│ Signup / Login
▼
Express.js API
│
▼
Authentication Controller
│
├── bcrypt → Password Hashing
│
▼
MongoDB
│
▼
JWT Token
│
▼
Authenticated User
git clone https://github.com/Princekumarsahu-321/full-stack.gitcd full-stackcd Backend
npm installCreate a .env file inside the Backend folder:
PORT=3000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secretStart the backend:
npm startFor development:
npm run devOpen another terminal:
cd Frontend
npm installCreate a .env file:
VITE_API_URL=http://localhost:3000Start the frontend:
npm run devThe frontend will normally run on:
http://localhost:5173
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/signup |
Register a new user |
| POST | /api/auth/login |
Login user |
| POST | /api/auth/logout |
Logout user |
| GET | /api/auth/user |
Get authenticated user |
| PATCH | /api/auth/updateMe |
Update user profile |
| PATCH | /api/auth/updateMyPassword |
Update password |
| POST | /api/auth/forgotPassword |
Request password reset |
| PATCH | /api/auth/resetPassword/:token |
Reset password |
You can test the backend APIs using:
- Postman
- Thunder Client
- REST Client
- Frontend UI
Example signup request:
{
"username": "Prince",
"email": "prince@example.com",
"password": "password123",
"passwordConfirm": "password123"
}Example login request:
{
"email": "prince@example.com",
"password": "password123"
}The project follows basic authentication security practices:
- Passwords are hashed using bcrypt
- Authentication uses JWT
- Sensitive configuration is stored in
.env - CORS is configured for frontend-backend communication
- Protected routes require authentication
⚠️ Never commit your.envfile or database credentials to GitHub.
The goal of this project is to understand how a MERN-based authentication system works from frontend to backend and database.
It demonstrates the complete flow:
React → Express → MongoDB → Authentication → React
Through this project, I practiced:
- Building REST APIs with Express.js
- Connecting Node.js with MongoDB
- Creating MongoDB schemas using Mongoose
- Implementing JWT authentication
- Password hashing with bcrypt
- Connecting React with Express APIs
- Managing authentication state
- Working with environment variables
- Using Git and GitHub for version control
Planned features:
- User Profile
- Forgot Password UI
- Email Verification
- Role-Based Authentication
- Admin Dashboard
- User Dashboard
- Property Management
- Booking System
- AI Features
Prince Kumar
B.Tech CSE Student Jagannath University, Jaipur
- GitHub: Princekumarsahu-321
If you found this project useful for learning MERN Stack authentication, consider giving the repository a ⭐.