GithubHelp home page GithubHelp logo

web3abhi / customer-loyalty-program Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ibm/customer-loyalty-program

0.0 1.0 0.0 2.71 MB

A customer loyalty program with blockchain using Hyperledger Composer API

License: Apache License 2.0

Shell 24.05% JavaScript 42.29% HTML 31.33% CSS 2.33%

customer-loyalty-program's Introduction

Customer Loyalty Program with blockchain

A customer loyalty program allows companies to reward customers who frequently make purchases. Program members are able to earn points on purchases, which can translate into some type of reward such as discount, freebie or special customer treatment. The members work toward a certain amount of points to redeem their reward. These programs can have multiple companies as partners on the program, to cater to a customer base. However, current loyalty program systems are restraint on relations between partners, and with visibility to members. These restraints can be removed by creating the customer loyalty program on a blockchain network.

This blockchain model for a customer loyalty program enhances the value of points to loyalty program members and brings in new value to the partners by creating trusted transactions. Participants in this network have a more level relation among each other and points are in the centric position to connect all participants.

In this code pattern, we will create a customer loyalty program as a blockchain web application using Hyperledger Composer API and Node.js. The application will allow members to register on the network where they will create their account. They will be identified on the network with their account number and will create a access key which they will use to sign in. This access key is used as the card id for the member to make transactions and query records. The member once signed in, can make transactions to earn points and redeem points from the partners on the network. They can view their transactions as part of the blockchain ledger. This code pattern illustrates the use of permissions as part of the network where a member can only view their transactions.

Similarly for the partner, they will register by creating an identity on the network and an access key which will be used to view their records. Partners are allowed to view only transactions they were part of, and thus can keep track of all their transactions where they allocated or redeemed points. The web application shows a basic dashboard for the partner displaying the total points that they have allocated and redeemed to members. As transactions get complex, the partner can perform analysis on their transactions to create informative dashboards.

This code pattern is for developers looking to start building blockchain applications with Hyperledger Composer. When the reader has completed this code pattern, they will understand how to:

  • Create basic business network using Hyperledger Composer framework
  • Deploy the network to an instance of Hyperledger Fabric locally or on IBM Blockchain Starter Plan
  • Build a Node.js web application to interact with the blockchain network using Composer API

Architecture Flow

Note The blockchain network will have multiple members and partners

  1. Member is registered on the network
  2. Member can sign-in to make transactions to earn points, redeem points and view their transactions
  3. Partner is registered on the network
  4. Partner can sign-in to view their transactions and display dashboard

Included Components

  • Hyperledger Composer v0.19.4 Hyperledger Composer is an extensive, open development toolset and framework to make developing blockchain applications easier
  • Hyperledger Fabric v1.1 Hyperledger Fabric is a platform for distributed ledger solutions, underpinned by a modular architecture delivering high degrees of confidentiality, resiliency, flexibility and scalability.
  • IBM Blockchain Starter Plan The IBM Blockchain Platform Starter Plan allows to build and try out blockchain network in an environment designed for development and testing

Featured technology

  • Nodejs Node.js is an open-source, cross-platform JavaScript run-time environment that executes JavaScript code server-side
  • Bootstrap Bootstrap is an open source toolkit for developing with HTML, CSS, and JS

Running the Application

Follow these steps to setup and run this code pattern. The steps are described in detail below.

Prerequisite

  • npm (v5.x)
  • Node (version 8.9 or higher - note version 9 is not supported)
  • to install specific Node version you can use nvm

    Example:

      1. nvm install 8.9.4
      1. nvm use v8.9.4
      1. Output Now using node v8.9.4 (npm v6.1.0)

Steps

  1. Clone the repo
  2. Generate the Business Network Archive
  3. Deploy Network
  4. Run Application

1. Clone the repo

Clone the Customer Loyalty Program with Blockchain repo locally. In a terminal, run:

git clone https://github.com/IBM/customer-loyalty-program

2. Generate the Business Network Archive

Next we will generate the Business Network Archive (BNA) file from the root directory.
This file will contain your network including:

  • the model defined in the org.clp.biznet.cto file in the models folder
  • the logic behind transactions in the logic.js file in the lib folder
  • permissions defined in the permissions.acl file
  • queries defined in the queries.qry file

Run the following the command to create the bna file:

cd customer-loyalty-program/
npm install

The composer archive create command in package.json has created a file called [email protected].

3. Deploy Network

The bna can be deployed to a local instance of Fabric or can use IBM Blockchain Starter Plan.

4. Run Application

Go into the web-app folder and install the dependency:

cd web-app/
npm install

Start the application:

npm start

The application should now be running at: http://localhost:8000


Deploy application to IBM Cloud

If your hosting the network on IBM Blockchain Starter Plan, then you can deploy the app to IBM Cloud.

Links

License

Apache 2.0

customer-loyalty-program's People

Contributors

raheelzubairy avatar

Watchers

web3abhi 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.