Giter VIP home page Giter VIP logo

analyze_ecommerce_websites_and_recommend_optimal_price's Introduction

Analyze e-commerce websites and recommend optimal pricing

Any e-commerce vendor who is selling a competitive product online, would want their sales to be maximum. One of the important factor that users see in buying a competitive product is the selling price that the vendor is offering. In order to sell maximum products a vendor would need to give the product at best selling price in the market, without compromising on the desired profits.

In this code pattern, we will develop an interactive UI integrated with custom backend that will help the e-commerce vendors decide on an optimal selling price such that their chances of sales will increase and at the same time maintain their desired profits.

Flow

  1. User launches the application.
  2. Product details are retrieved from MongoDB.
  3. List of products being sold are displayed.
  4. User enters Profit Margin and Minimum Requied Profit for the product being sold.
  5. This information is sent to the backend cloud functions.
  6. Cloud Functions scrapes the competitors product details from their websites.
  7. Custom algorithm computes the optimal price and sends itback to the application.
  8. An interacive tool is displayed to the user on the UI.
  9. User uses the tool and information on the UI to set a competitive price.

Pre-requisites

Steps

Please follow the below to setup and run this code pattern.

  1. Clone the repo
  2. Setup MongoDB on IBM Cloud
  3. Host competitors webpage on cloud
  4. Setup IBM Cloud Function
  5. Run the application
  6. Analyze the results

1. Clone the repo

Clone this git repo. Else, in a terminal, run:

$ git clone https://github.com/IBM/analyze_ecommerce_websites_and_recommend_optimal_price

2. Setup MongoDB on IBM Cloud

  • Create a MongoDB service on IBM Cloud. MongoDB-Instance

  • Set the Admin Password for your deployment.

  • From the resources open Databases for MongoDB instance, and select Overview in the left panel as shown. MongoDB-landingpage

  • Scroll down to the Endpoints section and click on MongoDB, copy the Endpoint in a notepad and replace the $USERNAME and $PASSWORD with admin and password that you created previously.

  • Scroll further down and download the ssl certificate and rename the file as ssl4mongodb as shown.

Note: this Endpoint and ssl certificate will be used in step 5.

3. Host competitors webpage on cloud

  • Before you proceed, make sure you have installed IBM Cloud CLI in your deployment machine.

  • From the cloned repo, goto competitors-websites directory in terminal, and run the following commands to deploy the Application to IBM Cloud Foundry.

$ cd competitors-websites/
  • Log in to your IBM Cloud account, and select an API endpoint.
$ ibmcloud login

NOTE: If you have a federated user ID, instead use the following command to log in with your single sign-on ID.

$ ibmcloud login --sso
  • Target a Cloud Foundry org and space:
$ ibmcloud target --cf
  • From within the competitors-websites directory push your app to IBM Cloud.
$ ibmcloud cf push competitors-websites
  • The manifest.yml file will be used here to deploy the application to IBM Cloud Foundry.

  • On Successful deployment of the application you will see something similar on your terminal as shown.

Invoking 'cf push'...

Pushing from manifest to org [email protected] / space dev as [email protected]...

...

Waiting for app to start...

name:              competitors-websites
requested state:   started
routes:            competitors-websites.xx-xx.mybluemix.net 
last uploaded:     Sat 16 May 18:05:16 IST 2020
stack:             cflinuxfs3
buildpacks:        python

type:            web
instances:       1/1
memory usage:    256M
start command:   python app.py
     state     since                  cpu     memory           disk           details
#0   running   2020-05-16T12:36:15Z   25.6%   116.5M of 256M   796.2M of 1
  • Once the app is deployed you can visit the routes to launch the application.

Example:

Note: Since this is an open source project it is restricted to extract information from private ecommerce websites. Hence we are showcasing the pattern with custom websites.

  • Copy the URL in this step, eg: http://competitors-websites.xx-xx.mybluemix.net/ .This will be used in the next step.

4. Setup IBM Cloud Function

IBM Cloud Function is a Serverless Architecture where in a user can write a snippet of code and run it as API's without worrying about deploying it. A code snippet can easily be attached to an already existing deployment to add more Functionality.

  • Goto IBM Cloud Resources, and click on the hamburger menu and select Functions > Actions as shown.

cloud-functions

  • In Cloud Actions page, click on Create to get started.

  • A Single entities list with Actions, Triger, Sequence, Quickstart Templates and Installable Packages will be presented. Select the Action to proceed.

  • Enter a name for the action, you can either create a custom package or leave it as default package and lastly select the Runtime as Python 3.7 and click on Create.

  • An IDE with Hello World code written in python will be presented, replace everything from the IDE with the code present in the file pricing-tool.py.

  • After adding the code, update the URL from 3rd step as shown below. Click on the Save button to save the cloud function.

  • Once the Cloud Function is code ready, you need to expose an API so that the Backend server can interact with the written code. Click on Endpoints and Enable as Web Action and finally click on Save button as shown.

  • After you have enabled as Web Action you will see a URL, copy the URL as it will be used in the next step.

  • At this point, you have successfully setup a serverless cloud function.

5. Run the application

var url = "Enter the cloud functions url here";
  • Replace the ENDPOINT-URL on line number 18 in app.py with the endpoint copied in step 2.

  • Place the ssl4mongodb file downloaded in step 2 inside static/ssl/ directory.

  • Now you can run the code in your local machine in one of the two ways mentioned below.

With Docker Installed
  • change directory to repo parent folder :
$ cd analyze_ecommerce_websites_and_recommend_optimal_price/
  • Build the Dockerfile as follows :
$ docker image build -t recommend_optimal_price .
  • once the dockerfile is built run the dockerfile as follows :
$ docker run -p 8080:8080 recommend_optimal_price
Without Docker
  • Install the python libraries as follows:

    • change directory to repo parent folder
    $ cd analyze_ecommerce_websites_and_recommend_optimal_price
    • use python pip to install the libraries
    $ pip install -r requirements.txt
  • Finally run the application as follows:

$ python app.py

6. Analyze the results

  • After you launch the application, you will see a list of products the user/vendor is selling.

  • Enter details as shown below and click on Update Price.

NOTE: Since the vendor gets the product directly from the manufacturer, he/she would be getting the product for a very low price compared to retail price.This difference in retail price and the price that the vendor bought is profit margin. Enter profit margin field takes in the total profit margin the user/vendor has on the product. Enter minimum required profit field takes in the minimum profit the user/vendor is planning to make the product.

  • Application gets the prices of the competitors who are selling this product online. Based on the data given, the application compares the prices of the competitors and returns an optimal selling price which could improve user's chances of selling the product and at the same time maintain the desired profits.

ℹī¸ Refer to the below information to understand the terminology used on the UI tool.
  • Minimum Selling Price : The minumum price at which the vendor needs to sell the product inorder to get his/her Minimum Required Profit.
  • Optimal Selling Price : A price given by the application algorithm that could improve vendor's chances of selling the product and at the same time maintain the desired profits.
  • Total Profit : Profit that vendor would get if the he/she sells at the Optimal Selling Price.
  • Profit Range : A dynamic slider that allows the user/vendor to see where his/her selling price stands in the market.
  • Optimal Price Range : A dynamic slider that allows the user/vendor to see where his/her selling price stands in the market.
  • Final Selling Price (Custom) : In this field the user/vendor can enter a price manually that he/she would want the product to be sold.
  • Final Profit: Final profit that the user/vendor would get after he/she sets the selling price.
  • Update Price: Updates the price online on your e-commerce website.
  • After you set your price click on the Update Price button. This updates the price online on your e-commerce website.

License

This code pattern is licensed under the Apache License, Version 2. Separate third-party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 and the Apache License, Version 2.

Apache License FAQ

analyze_ecommerce_websites_and_recommend_optimal_price's People

Contributors

rahulreddyravipally avatar manojjahgirdar avatar srikanthibm avatar imgbotapp avatar stevemar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.