https://github.com/vermaharsha/user-management-api
A backend service providing secure authentication, role-based access, and RESTful APIs for managing users, products, and a dashboard.
https://github.com/vermaharsha/user-management-api
bycrpt ejs express-js jwt mongodb mongoose node-js restful-api
Last synced: 3 months ago
JSON representation
A backend service providing secure authentication, role-based access, and RESTful APIs for managing users, products, and a dashboard.
- Host: GitHub
- URL: https://github.com/vermaharsha/user-management-api
- Owner: vermaharsha
- Created: 2025-03-05T11:06:45.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-30T13:43:22.000Z (11 months ago)
- Last Synced: 2026-04-08T20:43:26.492Z (3 months ago)
- Topics: bycrpt, ejs, express-js, jwt, mongodb, mongoose, node-js, restful-api
- Language: JavaScript
- Homepage:
- Size: 1.73 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# User Management API
## Project Summary
A backend service built with Node.js, Express, and MongoDB (using Mongoose). The service provides a robust RESTful API for managing users and products while ensuring secure authentication and role-based access control. A simple dashboard is also included to help manage data visually.
## Features
- **User & Product Management:**
- Full CRUD operations for users and products.
- **Secure Authentication:**
- Uses JSON Web Tokens (JWT) for authentication.
- Passwords are securely hashed with bcrypt.
- **Role-Based Access Control:**
- Enforces different access levels (Admin, Seller, Customer) for various endpoints.
- **Clean and Modular Architecture:**
- Easy to extend and maintain.
## Tech Stack
- **Backend:** Node.js, Express.js
- **Frontend:** Ejs
- **Database:** MongoDB with Mongoose
- **Authentication:** JWT, bcrypt.js
- **Utilities:** dotenv, nodemon, morgan, cors
## Installation & Setup
1. **Clone the Repository:**
```bash
git clone https://github.com/yourusername/BlueMedix.git
cd BlueMedix
```
2. **Install Dependencies:**
```bash
npm install
```
3. **Configure Environment Variables:**
Create a `.env` file in the root directory with the following:
```dotenv
PORT=3000
MONGO_URI=mongodb://localhost:27017/bluemedix
JWT_SECRET=your_jwt_secret
```
4. **Run the Application:**
```bash
npm run dev
```
The server should now run on `http://localhost:3000` and connect to your MongoDB instance.
## API Endpoints
### Authentication
- **Register User:**
- **Method:** POST
- **URL:** `/api/auth/register`
- **Description:** Creates a new user.
- **Login User:**
- **Method:** POST
- **URL:** `/api/auth/login`
- **Description:** Authenticates a user and returns a JWT token.
### User Management (Admin & Authenticated Users)
- **Get All Users:**
- **Method:** GET
- **URL:** `/api/users`
- **Description:** Retrieves a list of all users (admin-only).
- **Get Single User:**
- **Method:** GET
- **URL:** `/api/users/:id`
- **Description:** Retrieves details of a specific user.
- **Update User:**
- **Method:** PUT
- **URL:** `/api/users/:id`
- **Description:** Updates user information.
- **Delete User:**
- **Method:** DELETE
- **URL:** `/api/users/:id`
- **Description:** Deletes a user (admin-only).
### Product Management
- **Get All Products:**
- **Method:** GET
- **URL:** `/api/products`
- **Description:** Retrieves all products.
- **Create Product:**
- **Method:** POST
- **URL:** `/api/products`
- **Description:** Creates a new product (accessible to sellers/admins).
- **Update Product:**
- **Method:** PUT
- **URL:** `/api/products/:id`
- **Description:** Updates product details.
- **Delete Product:**
- **Method:** DELETE
- **URL:** `/api/products/:id`
- **Description:** Deletes a product.
> **Note:** For protected routes, include the following header:
> ```
> Authorization: Bearer
> ```
## Visual Overview
### User Register

### User Login

### MongoDB

## Future Enhancements
- **Implement Caching:** Add Redis for caching frequent queries.
- **Automated Testing:** Integrate unit and integration tests.
- **Enhanced Error Handling:** Improve logging and error responses.
---
## Author 💻
Made with love by [Harsha Verma](https://github.com/vermaharsha)