Skip to content

hoangdieuctu/icommerce

Repository files navigation

iCommerce

An online shopping application which sell the products.
User can search the products they want then add to a shopping cart and proceed to place an order.
To manage and make the users satisfied, all the users' activities are related to the products such as finding, filtering, viewing detail information will be stored.

Table of Contents

Entity Relationship Diagram
System Architecture
System Workflow
Configuration Repository
Service Details
How To Run
Generated Data
CURL Commands

Entity Relationship Diagram

picture

System Architecture

picture

System Workflow

picture

Configuration Repository

To manage and share the configuration between the micro services, configuration repository is required for the entire system.
Repo: icommerce-config

The repository contains the configuration of all services with 'default' profile.

Structure

├── apigateway-default.yml
├── application-default.yml
├── authenticationservice-default.yml
├── eurekaserver-default.yml
├── productservice-default.yml
└── shoppingcartservice-default.yml

Service Details

The project description, structure and dependencies will be in each project folder.

Service folders

apigateway
authenticationservice
configserver
eurekaserver
zipkinserver
productservice
shoppingcartservice
swaggerservice

How To Run

Make sure that the machine installed java 8 (at least) and maven.
The services should be started by the order.

Run Config Server

mvn clean install
java -jar target/configserver-*.jar

Run Eureka Server

mvn clean install
java -jar target/eurekaserver-*.jar

Run Zip Server

The place to trace the requests through all services.
Access: http://localhost:9411

java -jar zipkinserver.jar

Run API Gateway

mvn clean install
java -jar target/apigateway-*.jar

Run Authentication Service

mvn clean install
java -jar target/authenticationservice-*.jar

Run Product Service

mvn clean install
java -jar target/productservice-*.jar

Run Shopping Cart Service

mvn clean install
java -jar target/shoppingcartservice-*.jar

Run Swagger Service

The swagger service is a centralized swagger tool for all services.
Access: http://localhost:8085/swagger-ui.html

mvn clean install
java -jar target/swaggerservice-*.jar

Generated Data

For testing purpose, when starting the services, there are some data are generated (based on the configuration) as the table below.

Products

id name color branch description price qty
1 MacBook Pro 2013 White Apple Apply MacBook Pro 2013 13 Inch 43000000 20
2 MacBook Air 2017 White Apple Apply MacBook Air 2017 13 Inch 30000000 5
3 Dell Vostro 3590 Black Dell Core i7 - 8GB RAM 35000000 7
4 Acer Predator Black Acer Triton 500 - 8GB RAM 79900000 2

CURL Commands

Before testing, make sure all services are up and registered to Eureka Server correctly.

Access Eureka Server: http://localhost:9090/

Login by Facebook

Return the jwt token that use for the requests later.

curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://localhost:8080/api/v1/auth/login/facebook

Search products

Make sure the authorization is replaced by the new token.

curl -d '{"branch":"Apple","price":{"from":10000000,"to":90000000},"sort":{"sortBy":"branch","orderBy":"asc"}}' -H "Content-Type: application/json" -H "Authorization: eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIzIiwiaWF0IjoxNTkxNDI5MjYzLCJpc3MiOiJodHRwOi8vaWNvbW1lcmNlLmNvbSIsImV4cCI6MTU5MTQzMjg2M30.RtuIjc2QgyNw2IzINZn5gcOsG1hPmiLbbnosU7bpFUw" -X POST http://localhost:8080/api/v1/product/search

Get a product

Make sure the authorization is replaced by the new token.

curl -H "Content-Type: application/json" -H "Authorization: eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIzIiwiaWF0IjoxNTkxNDI5MjYzLCJpc3MiOiJodHRwOi8vaWNvbW1lcmNlLmNvbSIsImV4cCI6MTU5MTQzMjg2M30.RtuIjc2QgyNw2IzINZn5gcOsG1hPmiLbbnosU7bpFUw" -X GET http://localhost:8080/api/v1/product/1

Add a product to the shopping cart

Make sure the authorization is replaced by the new token.

curl -d '{"productId":2,"qty":1}' -H "Content-Type: application/json" -H "Authorization: eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIzIiwiaWF0IjoxNTkxNDI5MjYzLCJpc3MiOiJodHRwOi8vaWNvbW1lcmNlLmNvbSIsImV4cCI6MTU5MTQzMjg2M30.RtuIjc2QgyNw2IzINZn5gcOsG1hPmiLbbnosU7bpFUw" -X POST http://localhost:8080/api/v1/shopping-cart

Get current shopping cart

Make sure the authorization is replaced by the new token.

curl -H "Content-Type: application/json" -H "Authorization: eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIzIiwiaWF0IjoxNTkxNDI5MjYzLCJpc3MiOiJodHRwOi8vaWNvbW1lcmNlLmNvbSIsImV4cCI6MTU5MTQzMjg2M30.RtuIjc2QgyNw2IzINZn5gcOsG1hPmiLbbnosU7bpFUw" -X GET http://localhost:8080/api/v1/shopping-cart

About

An online shopping application which sell the products.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published