Shopmate- A Sample Ecommerce App that allows users to create an account, add items to cart and make payment.
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
- Ensure Node JS is installed.
- Ensure Mysql is installed.
- Clone the repository here
- Navigate to the project directory
cd turing-ecommerce-project
- Run
npm install
on the terminal to install dependecies - 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. - Create Mysql database and run migrations:
npm run migrations
POST /api/users/login
Example request body:
{
"user":{
"email": "sjuliet@juliet.com",
"password": "password"
}
}
No authentication required, returns a User
Required fields: email
, password
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
, email
, password
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 /api/items/<itemId>
No authentication required, returns a single item object
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 /api/cart
Authentication required, returns the the shopping cart object
PUT /api/cart/<cartItemId>
Example request body
{
"cart":{
"quantity": 3
}
}
Authentication required, returns the shopping cart updated object
Accepted fields: quantity
DELETE /api/cart/<cartItemId>
Authentication required, deletes an item from the shopping cart
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 /api/users
Authentication required, returns a user object
GET /api/department
No authentication required, returns the the department object
- Run the command
npm test
to run the test