This is a Node.js and MongoDB-based backend for an e-commerce application. It includes key features such as user authentication, product management, order processing, and more.
- i'm totally aware that sharing .env file isn't recommended at all at any cicumstances.
- the provided account is totally isolated and doesn't belong to any other personal account, i made it specifically for this test.
| ID | Feature | Epic | Priority | User Story |
|---|---|---|---|---|
| 1 | Product Management | Product and Categories | High | As an admin, I want to add, edit, and delete products so that I can manage the storeβs inventory effectively. |
| 2 | Category Management | Product and Categories | High | As an admin, I want to create, update, and delete product categories so that users can browse products by category. |
| 3 | User Registration | User Management | High | As a new user, I want to register by providing my email and password so that I can create an account on the platform. |
| 4 | User Login | User Management | High | As a registered user, I want to log in with my email and password so that I can access my account. |
| 5 | Order Management | Orders | High | As a user, I want to place an order, view my order history, and track my order status so that I know when my order will arrive. |
| 6 | Order Item Management | Orders | High | As a user, I want to add items to my order, change the quantity, or remove items before I complete my purchase so that I can adjust my cart easily. |
| 7 | User Role Management | User Management | Medium | As an admin, I want to assign roles (admin, user) so that I can control who can manage the products and orders. |
| 8 | User Authentication with JWT | User Management | Medium | As a user, I want to be authenticated using a secure token (JWT) so that my session remains active after login without re-entering credentials. |
| Field | Type |
|---|---|
| id | String |
| name | String |
| String | |
| password | String |
| phone | String |
| isAdmin | Boolean |
| street | String |
| address | String |
| zip | String |
| city | String |
| country | String |
| Field | Type |
|---|---|
| id | String |
| orderItems | Array of OrderItem IDs |
| shippingAddress | String |
| city | String |
| zip | String |
| country | String |
| phone | String |
| status | String |
| totalPrice | Number |
| user | String (User ID) |
| dateOrdered | Date |
| Field | Type |
|---|---|
| id | String |
| name | String |
| description | String |
| image | String (URL) |
| brand | String |
| price | Number |
| countInStock | Number |
| category | String (Category ID) |
| rating | Number |
| Field | Type |
|---|---|
| id | String |
| name | String |
| Field | Type |
|---|---|
| id | String |
| quantity | Number |
| product | String (Product ID) |
- Node.js: Backend JavaScript runtime environment.
- Express.js: Web application framework for handling API routes.
- MongoDB: NoSQL database for storing data such as users, products, and orders.
- Mongoose: Object Data Modeling (ODM) library for MongoDB, handling database operations and schema definitions.
- JSON Web Tokens (JWT): For user authentication and authorization.
- bcryptjs: For hashing and comparing passwords.
- dotenv: For managing environment variables.
- User registration with hashed passwords.
- Login functionality with JWT-based authentication.
- Admin roles for managing product listings and order statuses.
- CRUD (Create, Read, Update, Delete) operations on products.
- Filter products by category, price range, or availability.
- Manage product stock and availability.
- Users can place orders by adding items to the cart.
- Create, view, and update order details.
- Track order statuses (e.g., Pending, Shipped, Delivered).
- Calculate total prices based on product prices and quantities.
- Create, update, and delete product categories.
- Associate products with categories for easier filtering.
-
Clone the repository:
git clone https://github.com/your-username/ecommerce-backend.git cd ecommerce-backend -
Install dependencies:
npm install
-
Set up environment variables: Create a
.envfile with the following keys (Or use the existing .env file):MONGO_URI=<Your MongoDB Connection String> JWT_SECRET=<Your JWT Secret> PORT=<Server Port>
-
Start the server:
npm start
POST /users/register: Register a new user.POST /users/login: Login and generate JWT.GET /users/:id: Get user details.
GET /products: Fetch all products.GET /products/:id: Fetch product details by ID.POST /products: Add a new product (Admin).PUT /products/:id: Update a product (Admin).DELETE /products/:id: Delete a product (Admin).
GET /orders: Fetch all orders (Admin).GET /orders/:id: Fetch order details by ID.POST /orders: Place a new order.PUT /orders/:id: Update order status (Admin).
GET /categories: Fetch all categories.POST /categories: Add a new category (Admin).PUT /categories/:id: Update a category (Admin).DELETE /categories/:id: Delete a category (Admin).
This project is licensed under the MIT License.
Feel free to reach out if you have any questions or suggestions!
- Email: ihebagrebi810@example.com
- GitHub: Iheb-AG

