Skip to content

Iheb-AG/ecommerceBackendAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›’ E-Commerce Backend

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.

Notes :

  • 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.

1. conception

πŸ“ 1.1 Product Backlog

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.

πŸ“ 1.2 General Use-case diagram

codex_test_UseCaseDiagram drawio

πŸ“ 1.3 General Class diagram

ClassDIagram drawio (2)

πŸ“ Data Structures

User

Field Type
id String
name String
email String
password String
phone String
isAdmin Boolean
street String
address String
zip String
city String
country String

Order

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

Product

Field Type
id String
name String
description String
image String (URL)
brand String
price Number
countInStock Number
category String (Category ID)
rating Number

Category

Field Type
id String
name String

OrderItem

Field Type
id String
quantity Number
product String (Product ID)

πŸš€ Technologies Used

  • 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.

πŸ’‘ Functionalities

1. User Authentication & Authorization

  • User registration with hashed passwords.
  • Login functionality with JWT-based authentication.
  • Admin roles for managing product listings and order statuses.

2. Product Management

  • CRUD (Create, Read, Update, Delete) operations on products.
  • Filter products by category, price range, or availability.
  • Manage product stock and availability.

3. Order Management

  • 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.

4. Category Management

  • Create, update, and delete product categories.
  • Associate products with categories for easier filtering.

πŸ›  Installation

  1. Clone the repository:

    git clone https://github.com/your-username/ecommerce-backend.git
    cd ecommerce-backend
  2. Install dependencies:

    npm install
  3. Set up environment variables: Create a .env file with the following keys (Or use the existing .env file):

    MONGO_URI=<Your MongoDB Connection String>
    JWT_SECRET=<Your JWT Secret>
    PORT=<Server Port>
  4. Start the server:

    npm start

πŸ“œ API Endpoints

User

  • POST /users/register: Register a new user.
  • POST /users/login: Login and generate JWT.
  • GET /users/:id: Get user details.

Product

  • 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).

Order

  • 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).

Category

  • 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).

πŸ›‘ License

This project is licensed under the MIT License.


πŸ“§ Contact

Feel free to reach out if you have any questions or suggestions!


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors