Giter Club home page Giter Club logo

logistics-wizard-recommendation's Introduction

Logistics Wizard / Architecture / logistics-wizard-recommendation

Logistics Wizard - Weather Recommendation

This service monitors the weather conditions around retail stores and makes recommendations on additional shipments of goods.

It is built with IBM Cloud Functions highlighting how Functions can be used to implement a backend API. The Functions actions are:

  • Recommend - given weather conditions, it evaluates the impact of the weather on shipments and stocks and makes recommendations for additional shipments, rerouting, etc.

  • Retrieve - returns the recommendations to be considered by a retail store manager.

  • Acknowledge - marks the recommendations as processed (approved or rejected) by a retail store manager.

  • Observations - returns weather conditions at a given location.

  • Notify - formats recommendations for notification messages.

Simulating weather events

For demo purpose, the Recommend action can be called interactively to inject a weather event into the system.

Architecture

custom_mark10 digraph G { node [fontname = "helvetica"]; rankdir=TB; weather -> recommend; recommend -> database; database -> notify; ui -> retrieve; ui -> observations; retrieve -> database; ui -> acknowledge; acknowledge -> database; recommend -> erp; ui -> erp; {rank=same; recommend -> notify -> retrieve -> retrieve [style=invis] }; {rank=source; weather -> erp -> ui [style=invis]}; weather [shape=rect label="Weather Company Data service" style=filled color="%234E96DB" fontcolor=white]; recommend [label="Recommend" color="%232e8c70" style=filled fontcolor=white]; notify [label="Notify" color="%232e8c70" style=filled fontcolor=white]; retrieve [label="Retrieve" color="%232e8c70" style=filled fontcolor=white]; acknowledge [label="Acknowledge" color="%232e8c70" style=filled fontcolor=white]; observations [label="Observations" color="%232e8c70" style=filled fontcolor=white]; erp [shape=rect label="ERP service" color="%238ec843" style=filled]; ui [label="Dashboard" color="%23e8c228" style=filled]; database [shape=circle width=1 fixedsize=true style=filled color="%234E96DB" fontcolor=white label="Database"]; custom_mark10

Running the app on IBM Cloud

  1. If you do not already have a IBM Cloud account, sign up here.

  2. The Recommendation service depends on the Controller and ERP microservices. Deploy them first.

  3. In IBM Cloud, create an instance of the Weather Company Data service.

ibmcloud service create weatherinsights Free-v2 logistics-wizard-weatherinsights
  1. Create a set of credentials for this service.
ibmcloud service key-create logistics-wizard-weatherinsights for-openwhisk
  1. View the credentials and take note of the url value.
ibmcloud service key-show logistics-wizard-weatherinsights for-openwhisk
  1. Create an instance of Cloudant to store the recommendations.
ibmcloud service create cloudantNoSQLDB Lite logistics-wizard-recommendation-db
  1. Create a set of credentials for this service.
ibmcloud service key-create logistics-wizard-recommendation-db for-openwhisk
  1. View the credentials and take note of the url value.
ibmcloud service key-show logistics-wizard-recommendation-db for-openwhisk
  1. Clone the app to your local environment from your terminal using the following command.
git clone https://github.com/IBM-Cloud/logistics-wizard-recommendation.git
  1. Change directory using cd logistics-wizard-recommendation.

  2. Copy the file named template-local.env into local.env.

cp template-local.env local.env
  1. In local.env, update the location of the CONTROLLER_SERVICE, the url of the Weather Company Data service, and the url of the Cloudant database.

  2. Get the dependencies, and use webpack module bundler to create our final .js actions in the dist folder.

npm install
npm run build
  1. Ensure your IBM Cloud Functions command line interface is property configured with:
ibmcloud cloud-functions list

This shows the packages, actions, triggers and rules currently deployed in your Functions namespace.

  1. Deploy the Functions artifacts
./deploy.sh --install

Note: the script can also be used to --uninstall the Functions artifacts to --update the artifacts if you change the action code, or simply with --env to show the environment variables set in local.env.

Code Structure

File Description
deploy.sh Helper script to create the recommendations database, install, uninstall, update the Functions trigger, actions, rules.
template-local.env Contains environment variables used by the deployment script. Duplicate this file into local.env to customize it for your environment.
package.json List dependencies used by the actions and the build process.
webpack.config.js Webpack configuration used to build Functions actions. This allows the actions to use modules (module versions) not packaged natively by Functions. Make sure to add explicit dependencies in the package.json for specific module versions used by the actions. The webpack build will look at the "dependencies" and webpack them. If a module is not listen in "dependencies" it is assumed to be provided by Functions.
recommend.js Entry point for the Recommend action.
prepare-for-slack.js Entry point for the Notify action. It formats newly added recommendations into a text suitable for a Slack post message.
retrieve.js Entry point for the Retrieve action.
acknowledge.js Entry point for the Acknowledge action.
observations.js Entry point for the Observations action.
test Unit test for the actions to be executed outside of Functions.

Troubleshooting

Polling activations is good start to debug the Functions action execution. Run

ibmcloud cloud-functions activation poll

and invoke actions.

License

See License.txt for license information.

Status

master Build Status Coverage Status
dev Build Status Coverage Status

logistics-wizard-recommendation's People

Contributors

l2fprod avatar rvennam avatar rvennam987 avatar van-ibm avatar

Watchers

 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.