iamuchejude / turing-shop

An e-commerce web application that allows registered users to place an order and make payment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status Maintainability

Shopmate

Shopmate- A Sample Ecommerce App that allows users to create an account, add items to cart and make payment.

Development

The development is broken down into two parts, the server side and the client side. The server side (API/backend) is developed using Express, NodeJs, MySQL and Sequelize ORM for persisting data, and Json Web token for authentication. React framework is used for the frontend

Installation

  1. Ensure Node JS is installed.
  2. Ensure Mysql is installed.
  3. Clone the repository here
  4. Navigate to the project directory cd turing-ecommerce-project
  5. Run npm install on the terminal to install dependecies
  6. Create a .env file in your root directory and copy content from .env.sample file to .env file and set environment variables with the appropriate values.
  7. Create Mysql database and run migrations: npm run migrations

Endpoints:

Authentication:

POST /api/users/login

Example request body:

{
  "user":{
    "email": "sjuliet@juliet.com",
	"password": "password"
  }
}

No authentication required, returns a User

Required fields: emailpassword

Registration:

POST /api/users

Example request body:

{
  "user":{
    "firstname": "Sjuliet",
	"lastname": "Juliet",
	"email": "sjuliet@juliet.com",
	"password": "juliet1",
	"password_confirmation": "juliet1"
  }
}

No authentication required, returns a User

Required fields: fullname, emailpassword

Get All Items

GET /api/items

Query Parameters:

Filter by Department:

?department=Nature

Filter by Department and Category:

?department=Regional&category=french

Filter by page and limit(default page=1 and limit=10):

?page=1&limit=5

Search by name of item or item description:

?search=Arc

No authentication required, returns a default of ten items per page

Get a single item

GET /api/items/<itemId>

No authentication required, returns a single item object

Add Item to Shopping Cart

POST /api/cart

Example request body:

{
  "cart":{
    "productId": "3",
	"attributes": ["XXL", "White"],
	"quantity": 3
  }
}

Authentication required, returns the shopping cart object

Accepted fields: productId, attributes, quantity

Get Customers items in the Shopping Cart

GET /api/cart

Authentication required, returns the the shopping cart object

Update the quantity of an item in the shopping cart

PUT /api/cart/<cartItemId>

Example request body

{
  "cart":{
	"quantity": 3
  }
}

Authentication required, returns the shopping cart updated object

Accepted fields: quantity

Delete an item in the cart

DELETE /api/cart/<cartItemId>

Authentication required, deletes an item from the shopping cart

Update User Profile

PUT /api/users Example request body

{
  "user":{
    "address1": "Address",
    "city": "city",
    "region": "region",
    "country": "country"
  }
}

Accepted fields: address1, address2, city, region, postalCode, country, dayPhone, evePhone mobPhone, shippingRegionId

Authentication required, returns an updated user object

Get User Profile

GET /api/users

Authentication required, returns a user object

Get all departments and categories

GET /api/department

No authentication required, returns the the department object

Running Test

  • Run the command npm test to run the test

About

An e-commerce web application that allows registered users to place an order and make payment


Languages

Language:JavaScript 100.0%