An open API service indexing awesome lists of open source software.

https://github.com/hailex798/fullstack-intern

Welcome to the User Management System, a full-stack web application built using the MERN Stack (MongoDB, Express.js, React.js, Node.js).
https://github.com/hailex798/fullstack-intern

axios bycrypt context-api express mongodb nodejs react reactjs tailwindcss

Last synced: about 2 months ago
JSON representation

Welcome to the User Management System, a full-stack web application built using the MERN Stack (MongoDB, Express.js, React.js, Node.js).

Awesome Lists containing this project

README

          

# ๐ŸŽ‰ **User Management System** - MERN Stack Assignment

[![Live Demo](https://img.shields.io/badge/Live%20Demo-FULLSTACKINTERN.VERCEL.APP-green?style=for-the-badge)](https://fullstackintern.vercel.app/)
[![GitHub Repo](https://img.shields.io/badge/Source%20Code-FullStackIntern-black?style=for-the-badge)](https://github.com/Hailex798/FullStack-Intern)

### **๐ŸŒŸ Overview**
Welcome to the **User Management System**, a full-stack web application built using the **MERN Stack** (MongoDB, Express.js, React.js, Node.js).

This project showcases:
๐Ÿ”’ **Authentication** - Login/Signup functionality with secure JWT-based authentication.
๐ŸŽฏ **Role-Based Access Control** - Specific user privileges for **Admins**, **Agents**, and **Users**.
๐Ÿš€ **Context API** - For managing user data efficiently in local browser storage.

---
## **๐ŸŒŸ Assignment**

The Assignment was provided in a Google Docs file, where the frontend Code was also provided.

![Assignment](./samples/Assignment.png)

---

## โœจ **Features**
### ๐Ÿ”‘ **Authentication**
- **Sign-up** ๐Ÿ“: Users can create accounts with their name, email, and password.
- Default role: **Admin**.
- No duplicate emails allowed!
- **Login** โœ…: Access your account securely with your credentials.
- User role is displayed in the header.

### ๐Ÿ”’ **Role-Based Access Control**
Depending on their role, users have access to different functionalities:
- **๐Ÿ‘‘ Admin**:
- Can create both **Agents** and **Users**.
- Full access to the **User Management** module.

- **๐Ÿ› ๏ธ Agent**:
- Can create **Users** only.
- Limited access to the **User Management** module.

- **๐Ÿ™‹โ€โ™‚๏ธ User**:
- No access to User Management.
- Redirected to a "Restricted Access" page when attempting unauthorized actions.

---

## ๐ŸŽจ **Visual Overview**

Below are visual previews of the applicationโ€™s various pages and features. Click on the dropdown arrows to view the corresponding screenshots.

*Visit the [Live Site](https://fullstackintern.vercel.app/) for a full experience!* ๐ŸŒ

## Login Page
![Login Page](./samples/Login_Page.png)
---
## Login Successful
![Login Successful](./samples/Login_Successfully.png)
---
## MongoDB User Credentials Data
![MongoDB Data](./samples/MongoDB_Login_Credentials.png)

๐Ÿ  Authentication (Click to Expand)

- A SignUp Page for creating User Credentials.

## SignUp Page
![SignUp Page](./samples/SignUp_Page.png)
---
## SignUp Successful Page
![SignUp Successful](./samples/SignUp_Successfully.png)

๐Ÿ‘• Admin (Click to Expand)

- Admin LoggedIn Dashboard + User Management

## Admin Page User Management
![Admin Page User Management](./samples/Admin_UM.png)
---
## Admin Page User Management Agent ID Creation
![Admin Page User Management Agent ID Creation](./samples/Admin_UM_agent.png)
---
## Admin Page User Management User ID Creation
![Admin Page User Management User ID Creation](./samples/Admin_UM_user.png)

๐Ÿ‘• User (Click to Expand)

- User LoggedIn Dashboard + User Management

## User Page
![User Page](./samples/User.png)
---
## User Page User Management
![User Page User Management](./samples/User_UM.png)
---
## User Page User Settings
![User Page User Settings](./samples/User_US.png)

---

## ๐Ÿ—๏ธ **How It Works**

### **Authentication Flow**
1. **Sign-Up**:
- User enters name, email, and password.
- Data is sent to the backend and stored securely in MongoDB.
2. **Login**:
- Credentials are validated, and a JWT is issued.
- The token is stored in the browser (Context API).
3. **Protected Routes**:
- Based on the user's role, access is granted or restricted.

---

## ๐Ÿ› ๏ธ **Tech Stack**

### **Frontend**
- **React.js** โš›๏ธ
- **Tailwind CSS** ๐ŸŽจ
- **React Router** ๐ŸŒ - For navigation and protected routing.
- **Context API** ๐Ÿ“ฆ - For storing user data securely in local browser storage.

### **Backend**
- **Node.js** ๐ŸŒณ
- **Express.js** ๐Ÿ›ค๏ธ
- **MongoDB** ๐Ÿƒ - For database management.
- **JWT (JSON Web Tokens)** ๐Ÿ” - For authentication and role-based authorization.
- **bcrypt.js** ๐Ÿ”‘ - For password hashing.

### **Build & Tools**
- **Vite** โšก - Blazing fast build tool for frontend.
- **Axios** ๐ŸŒ - For seamless API calls.
- **dotenv** ๐Ÿ›ก๏ธ - For managing environment variables.

---

## ๐Ÿ—‚๏ธ **Folder Structure**
Organized for scalability and maintainability:

### Project Structure
![Login Successful](./samples/PROJECT_STRUCTURE.png)

```
User-Management/
โ”œโ”€โ”€ backend/
โ”‚ โ”œโ”€โ”€ config/ # Database connection setup
โ”‚ โ”œโ”€โ”€ controllers/ # Business logic for routes
โ”‚ โ”œโ”€โ”€ middlewares/ # JWT and role-based auth checks
โ”‚ โ”œโ”€โ”€ models/ # MongoDB schemas
โ”‚ โ”œโ”€โ”€ routes/ # API endpoints
โ”‚ โ””โ”€โ”€ server.js # Entry point for the backend
โ”œโ”€โ”€ client/
โ”‚ โ”œโ”€โ”€ public/ # Static assets
โ”‚ โ”œโ”€โ”€ src/
โ”‚ โ”‚ โ”œโ”€โ”€ components/ # Reusable UI components
โ”‚ โ”‚ โ”œโ”€โ”€ pages/ # Page-level components
โ”‚ โ”‚ โ”œโ”€โ”€ App.js # Main app component
โ”‚ โ”‚ โ””โ”€โ”€ index.js # React entry point
โ”œโ”€โ”€ README.md
```

---

## ๐Ÿš€ **Setup Instructions**

1. **Clone the Repository** ๐Ÿ“‚
```bash
git clone https://github.com/your-repo-url.git
cd User-Management
```

2. **Install Dependencies** ๐Ÿ› ๏ธ
- Backend:
```bash
cd backend
npm install
```
- Frontend:
```bash
cd client
npm install
```

3. **Configure Environment Variables** ๐Ÿ”
- In the `backend` directory, create a `.env` file with:
```
MONGO_URI=
JWT_SECRET=
```

4. **Start the Servers** ๐Ÿ–ฅ๏ธ
- Backend:
```bash
cd backend
npm start
```
- Frontend:
```bash
cd client
npm run dev
```

5. **Access the Application** ๐ŸŒ
Open `http://localhost:5173` in your browser.

---

## ๐Ÿ”ฎ **Future Enhancements**
- Add **Forgot Password** and **Reset Password** functionality.
- Improve the UI for better user experience.
- Add analytics for Admins to monitor system usage.

---

## ๐Ÿ‘‹ **Conclusion**
This project is a testament to the power of the MERN stack, demonstrating how to integrate frontend and backend for seamless functionality. With role-based access, it offers a secure and scalable solution for user management.

---

Let me know if you'd like any other tweaks! ๐Ÿš€