Skip to content

cgupta3131/SIH-BlockChain-GAIL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SIH'20 Blockchain GAIL

BUILD INSTRUCTIONS

  • fabric contains code for the Hyperledger Fabric blockchain network and chaincode (smart contracts).
  • nodeserver contains the NodeJS and Express backend server code.
  • GAIL_client contains the GAIL client website code.
  • Contractor_client contains the Contractor client website code.

Setting up dependencies

Make sure all the required folders are removed while doing ./network.sh down. If you are facing permission errors while removing the blockchain network, use sudo chown -R $USER:$USER test-network.

curl -sSL https://bit.ly/2ysbOFE | bash -s

Running the test network

If you see this message: WARNING: Connection pool is full, discarding connection: localhost. That's because the python library requests maintains a pool of HTTP connections that the docker library uses. If we use docker-compose with more than 10 containers, this warning will occur. Solution is to change the DEFAULT_POOLSIZE of requests library in ~/.local/lib/python*.*/site-packages/requests/adapters.py to 1000.

# Install the required dependencies
./install.sh

# Deploy the blockchain network
fabric/test-network/network.sh up -ca

# Create all required channels between the peer nodes (between every pair of gail and contractor and other among all gail nodes)
fabric/test-network/network.sh createChannel

# Deploy chaincode to the channel created
fabric/test-network/network.sh deployCC

# Remove the blockchain network
fabric/test-network/network.sh down

OR

# Install the required dependencies
./install.sh

# Create the blockchain network
./restart.sh

Running NodeJS backend server

# Install all the required dependencies
npm install

# Start the node server
npm start

# Open localhost:3000 in web browser

Running NodeJS GAIL Client server

# Install all the required dependencies
npm install

# Start the node server
PORT=8000 node app.js

# Open localhost:3600 in web browser

Running NodeJS Contractor Client server

# Install all the required dependencies
npm install

# Start the node server
node app.js

# Open localhost:4200 in web browser


GAIL-BK225-Chaincode-Documentation

Gail and Evaluators

  1. Users
Functions Description
Create User Params: Model fields.
  • Username
  • Password
  • Email
  • Address
  • Profile Picture
  • Team Name
  • Designation: Gail User/Evaluator

    Function: Saved as USER_<Username> in blockchain db

    Return: Void

Get User Params: Username, Password

Return: JSON user data model with all fields

Get Num Contractors Params: Void \ Return: Number of Contractor/Shipping Agencies registered.
Update Num Contractors Params: Void \ Function: Increments number of Contractors/Shipping Agencies registered by 1. \ Return: Void
  1. Project
Functions Description
Create Project Params: Model fields
  • Username
  • ProjectID: Automatic unique ID generated equal to number of projects registered by GAIL till now.
  • Title
  • Description
  • Create Time Stamp
  • Deadline: After the deadline is met, GAIL will be able to review all the applied bids and add it’s custom reviews.
  • ContractorID: Initially NULL, later equal to assigned contractor
  • BidID: Initially NULL, later equal to best evaluated bid
  • Status: Floated/In-Progress/In-Shipment/In-Pre-Review/In-Review
  • Progress: Array of descriptive timed logs
  • Brochure: Uploaded in form of PDF

    Function: Saved Model as PROJECT_<ProjectID> in blockchain db

    Return: Void

Get Project Params: ProjectID

Return: JSON project data model with all fields

Get Num Projects Params: Void \ Return: Number of Projects registered by GAIL till now
Update Num Projects Params: Void \ Function: Increments number of Projects by 1 \ Return: Void
Update Project BidID Params: ProjectID, bidID \ Function: Updates field ‘bidID’ for project of <ProjectID> \ Return: Void
Update Project ContractorID Params: ProjectID, contractorID \ Function: Updates field ‘contractorID’ for project of <ProjectID> \ Return: Void
Update Project Progress Params: ProjectID, description, timestamp \ Function: Updates field ‘progress’ for project of <ProjectID> as pushes JSON field having description and timestamp into the progress array. \ Return: Void
Update Project Status Params: ProjectID, status \ Function: Updates field ‘status’ for project of <ProjectID> \ Return: Void
  1. Bid
Functions Description
Apply for Project Params: Model fields.
  • Username
  • ProjectID
  • BidID: AutoGenerated Unique ID generated by currentTimeStamp of application
  • BidDetails: JSON of various params like price, ISO standards, rating, product quality. (more can be added as per requirement)

    Function:

    • Saved as BID_<BidID> in blockchain db
    • Pushed to APPLIED_<ProjectID> array of all applied bids of the given project in the blockchain dc.

      Return: Void

Get Bid Params: BidID

Return: JSON bid data model with all fields

Get ProjectBids Params: ProjectID \ Return: Array of all the applied bids for given projectID.

Contractors and Shipping Agency

  1. Users
Functions Description
Create User Params: Model fields.
  • Username
  • Password
  • Email
  • Address
  • Contact
  • AboutUs
  • ProfilePic
  • ListOfPrevious Projects: Array of JSON of all previous allocated projects to the contractor by GAIL by params like ID, rating, quality, review.
  • ActiveProjectID: NULL if no active project, otherwise equal to the projectID assigned to the contractor
  • ActiveBidID: NULL if no active project, otherwise equal to the BidID that the contractor had applied for the allocated project.
  • OverallRating: Average rating provided to the contractor based on past deals with GAIL
  • OverallProductQuality: Average product/service quality provided to the contractor based on past deals with GAIL

    Function: Saved as CONTRACTOR_<Username> in blockchain db

    Return: Void

Allocate Project Params: ProjectID, BidID \ Function: Changes fields ‘activeProjectID’ from NULL to <ProjectID> and ‘activeBidID’ from NULL to <BidID> \ Return: Void
Dellocate Project Params: Username, Rating, Quality, Review \ Function:
  • Changes fields ‘activeProjectID’ to NULL and ‘activeBidID’ to NULL
  • Added JSON of id, current rating,quality,review in array of list of previous projects.

    Return: Void

Get Num of Previous Projects Params: Void \ Function: Returns length of the array of previous projects in the project data model. \ Return: Void
Get/Update functions Params: Void(GET), <value>(UPDATE)

Function: Query to blockchain db to fetch or put updated state accordingly.

alt_text

Project Lifecycle

alt_text

DOMESTIC USE CASE

alt_text



GAIL - BK225

BLOCKCHAIN POWERED PROCUREMENT SYSTEM

NodeServer API Documentation

Team Name CRYPTO-BUDS
Team Leader Devaishi Tiwari
Other Team Members Vakul Gupta, Chirag Gupta, Lavish Gulati, Utkarsh Jain, Niyati Chaudhary
College Name Indian Institute of Technology, Guwahati

Introduction

For all our core functionalities, we have created REST API endpoints. These REST endpoints provide a means of abstraction between client and blockchain network and also encapsulate business logic. The APIs also have endpoints for payment functionality with third-party services (currently only Paytm is supported).

Broadly we can classify our API endpoints into three groups:

  • Contractor Services
  • GAIL Services
  • Payment Services

Contractor Services

API services under this group cater to the use cases from the Contractor’s perspective.


PATH: /contractors/admin/signup

METHOD: POST

BODY: empty

USAGE: To register an admin for contractor users. Needed for the blockchain network wallet for contractors.

RESPONSE: JSON

Contains following fields:

  • success: boolean. True if successfully created admin. Otherwise false.

PATH: /contractors/users/signup

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique contractor username.
password string. Contractor password.
email string. Contractor email id.
contact string, Contractor contact number.
address string. Contractor address.
aboutUs string. Contains a short description about contractor.
profilePic string. Path of the contractor profile picture stored in the server.
mid string. Paytm Merchant ID of the contractor.
mkey string. Paytm Merchant Key of the contractor.

USAGE: To register a new contractor.

RESPONSE: JSON

Contains following fields:

  • success: boolean. True if successfully created admin.Otherwise false.
  • username: string. Only returned if the user is successfully created. Contains the username of the new user.
  • message: string. Only returned if the user is not created. Contains the error message.

PATH: /contractors/users/login

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique contractor username.
password string. Contractor password.

USAGE: To authenticate a contractor

RESPONSE: JSON

Contains following fields:

  • success: boolean. Only returned if authentication failed.Value is always false.
  • message: string. Only returned if authentication failed. Contains the error message.
  • username: string. Only returned if authentication success. Unique contractor username.
  • password: string. Only returned if authentication success. Contractor password.
  • email: string. Only returned if authentication success. Contractor email ID.
  • contact: string. Only returned if authentication success. Contractor contact number.
  • address: string. Only returned if authentication success. Contractor address.
  • aboutUs: string. Only returned if authentication success. Contains a short description of the contractor.
  • profilePic: string. Only returned if authentication success. Path of the contractor profile picture stored in the server.
  • mid: string. Only returned if authentication success. Paytm Merchant ID of the contractor.
  • mkey: string. Only returned if authentication success. Paytm Merchant Key of the contractor.

PATH: /contractors/users/profile

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique contractor username.
password string. Contractor password.

USAGE: To get the contractor profile

RESPONSE: JSON

Contains following fields:

  • success: boolean.True if successful query.Otherwise false.
  • message: string. Only returned if the query failed. Contains the error message.
  • Object: JSON object. Contains contractor profile which contains the following fields:
  • username: string. Unique contractor username.
  • password: string. Contractor password.
  • email: string.Contractor email id.
  • contact: string.Contractor contact number.
  • address: string.Contractor address.
  • aboutUs: string. Contains a short description of the contractor.
  • profilePic: string. Path of the contractor profile picture stored in the server.
  • mid: string. Paytm Merchant ID of the contractor.
  • mkey: string. Paytm Merchant Key of the contractor.

PATH: /contractors/users/updateProfile

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique contractor username.
password string. Contractor password.
email string. Contractor email id.
contact string, Contractor contact number.
address string. Contractor address.
aboutUs string. Contains a short description of the contractor.
profilePic string. Path of the contractor profile picture stored in the server.
mid string. Paytm Merchant ID of the contractor.
mkey string. Paytm Merchant Key of the contractor.

USAGE: To update contractor profile

RESPONSE: JSON

Contains following fields:

  • success: boolean. Only returned if authentication failed.Value is always false.
  • message: string. Only returned if authentication failed. Contains the error message.
  • username: string. Only returned if update success. Unique contractor username.
  • password: string. Only returned if update success. Contractor password.
  • email: string. Only returned if update success. Contractor email id.
  • contact: string. Only returned if update success. Contractor contact number.
  • address: string. Only returned if update success. Contractor address.
  • aboutUs: string. Only returned if update success. Contains a short description about the contractor.
  • profilePic: string. Only returned if update success. Path of the contractor profile picture stored in the server.
  • mid: string. Only returned if update success. Paytm Merchant ID of the contractor.
  • mkey: string. Only returned if update success. Paytm Merchant Key of the contractor.

PATH: /contractors/users/getCompletedProjects

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique contractor username.
password string. Contractor password.

USAGE: Get all previous projects delivered by the contractor

RESPONSE: JSON

Contains following fields:

  • success: boolean.True if successful query.Otherwise false.
  • message: string. Only returned if the query failed. Contains the error message.
  • allProjects: JSON array. Contains an array of project JSON objects which are completed by the contractor: Each project object contains the following fields :
    • username: string. Username of GAIL client who created the project.
    • id: string. Project ID.
    • title: string. Project Title.
    • description: string. Project description.
    • status: string. Current project status.
    • contractor_id: string. Username of the contractor to whom the project is allocated.
    • bid_id :string. Winning Bid ID of the project
    • progress: JSON array. Contains an array of message updates by the contractor with timestamp.
    • createTimeStamp: string. Project creation timestamp.
    • deadline: string.Project deadline timestamp.
    • brochurePath: string. Project brochure file path on the server.
    • type: string. Project type.

PATH: /contractors/users/{contractor username}

METHOD: POST

BODY: empty

USAGE: Get the contractor profile.

RESPONSE: JSON

Contains following fields:

  • success: boolean.True if successful query.Otherwise false.
  • message: string. Contains query message.
  • Object: JSON object. Contains contractor profile which contains the following fields:
    • username: string. Unique contractor username.
    • password: string. Contractor password.
    • email: string.Contractor email id.
    • contact: string.Contractor contact number.
    • address: string.Contractor address.
    • aboutUs: string. Contains a short description of the contractor.
    • profilePic: string. Path of the contractor profile picture stored in the server.
    • mid: string. Paytm Merchant ID of the contractor.
    • mkey: string. Paytm Merchant Key of the contractor.

PATH: /contractors/bids/applyForProject

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique contractor username.
password string. Contractor password.
projectID string. Project ID of the project to which bid is applied.
bidDetails JSON object: Contains bid details with fields like price, completion time etc.

USAGE: To apply a bid for a particular project.

RESPONSE: JSON

Contains following fields:

  • success: boolean.True if successful query.Otherwise false.
  • message: string. Contains query message.
  • bidID: string. Applied Bid ID.

PATH: /contractors/project/

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique contractor username.
password string. Contractor password.

USAGE: Get current allocated project for a contractor

RESPONSE: JSON

Contains following fields:

  • success: boolean. Only returned if the query failed. Value is always false.

  • message: string. Only returned if the query failed. Contains the error message.

    The project object is returned if the query is successful. It contains the following fields:

  • username: string. Username of GAIL client who created the project.

  • id: string. Project ID.

  • title: string. Project Title.

  • description: string. Project description.

  • status: string.Current project status.

  • contractor_id: string. Username of the contractor to whom the project is allocated.

  • bid_id: string. Winning Bid ID of the project

  • progress: JSON array. Contains an array of message updates by the contractor with timestamp.

  • createTimeStamp: string. Project creation timestamp.

  • deadline: string. Project deadline timestamp.

  • brochurePath: string. Project brochure file path on the server.

  • type: string. Project type.


PATH: /contractors/project/updateProjectStatus

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique contractor username.
password string. Contractor password.
status string. New Project Status.

USAGE: Update status of an allocated project by a contractor

RESPONSE: JSON

Contains following fields:

  • success: boolean.True if successful query.Otherwise false.
  • message: string. Contains query message.

PATH: /contractors/project/updateProjectProgress

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique contractor username.
password string. Contractor password.
status string. New Project progress description

USAGE: Add a progress description to an allocated project by a contractor

RESPONSE: JSON

Contains following fields:

  • success: boolean.True if successful query.Otherwise false.
  • message: string. Contains query message.

GAIL Services

API services under this group cater to the use-cases from GAIL’s perspective.


PATH: /gail/admin/signup

METHOD**: POST

BODY: empty

USAGE: To register an admin for GAIL users. Needed for the blockchain network wallet for GAIL.

RESPONSE: JSON

Contains following fields:

  • success: boolean. True if successfully created admin.Otherwise false.

PATH: /gail/users/signup

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique GAIL client username.
password string. User password.
email string. User email id.
contact string, User contact number.
address string. User address.
designation string. User designation.
profilePic string. Path of the user profile picture stored in the server.
name string. User Name
teamname string. User Team Name.

USAGE: To register a new GAIL user.

RESPONSE: JSON

Contains following fields:

  • success: boolean. True if successfully created admin.Otherwise false.
  • username: string. Only returned if the user is successfully created. Contains the username of the new user.
  • message: string. Only returned if the user is not created. Contains the error message.

PATH: /gail/users/login

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique GAIL client username.
password string. User password.

USAGE: To authenticate a GAIL client

RESPONSE: JSON

Contains following fields:

  • success: boolean.True if successful authentication.Otherwise false.
  • message: string. Contains query message.

PATH: /gail/users/getUserDetails

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique GAIL client username.
password string. User password.

USAGE: To get GAIL user profile

RESPONSE: JSON

Contains following fields:

  • success: boolean.True if successful query.Otherwise false.
  • message: string. Only returned if the query failed. Contains the error message.
  • Object: JSON object. Only returned if query successful. Contains GAIL client profile which contains the following fields:
    • username: string. Unique GAIL client username.
    • password: string. User password.
    • email: string. User email id.
    • contact: string, User contact number.
    • address: string. User address.
    • designation: string. User designation.
    • profilePic: string. Path of the user profile picture stored in the server.
    • name: string. User Name
    • teamname: string. User Team Name.

PATH: /gail/users/editUserDetails

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique GAIL client username.
password string. User password.
email string. User email id.
contact string, User contact number.
address string. User address.
designation string. User designation.
profilePic string. Path of the user profile picture stored in the server.
name string. User Name
teamname string. User Team Name.

USAGE: To update GAIL user profile

RESPONSE: JSON

Contains following fields:

  • success: boolean.True if successful query.Otherwise false.
  • message: string. Only returned if the query failed. Contains the error message.

PATH: /gail/project/createProject

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique GAIL client username.
password string. User password.
id string. Project ID.
title string. Project Title.
description string. Project description.
createTimeStamp string. Project creation timestamp.
deadline string.Project deadline timestamp.
brochurePath string. Project brochure file path on the server.
type string. Project type. (Product/Service)

USAGE:To create a new project.

RESPONSE: JSON

Contains following fields:

  • success: boolean.True if successful query.Otherwise false.
  • message: string. Contains the query message.

PATH: /gail/project/getProject

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique GAIL client username.
password string. User password.
id string. Project ID.

USAGE: To get project details.

RESPONSE: JSON

Contains following fields:

  • success: boolean.True if successful query.Otherwise false.
  • message: string. Contains the query message.
  • Object: JSON object. Contains project object which contains the following fields:
    • username: string. Username of GAIL client who created the project.
    • id: string. Project ID.
    • title: string. Project Title.
    • description: string. Project description.
    • status: string.Current project status.
    • contractor_id: string. Username of the contractor to whom the project is allocated.
    • bid_id: string. Winning Bid ID of the project
    • progress: JSON array. Contains an array of message updates by the contractor with timestamp.
    • createTimeStamp: string. Project creation timestamp.
    • deadline: string.Project deadline timestamp.
    • brochurePath: string. Project brochure file path on the server.
    • type: string. Project type.

PATH: /gail/project/getAllProjects

METHOD: POST

BODY: empty

USAGE: To get all the project details.

RESPONSE: JSON

Contains following fields:

  • success: boolean.True if successful query.Otherwise false.
  • message: string. Only returned on failure. Contains the error message.
  • Object: JSON object. Contains a dictionary of all projects with project id and project object map. Project object contains the following fields:
    • username: string. Username of GAIL client who created the project.
    • id: string. Project ID.
    • title: string. Project Title.
    • description: string. Project description.
    • status: string.Current project status.
    • contractor_id :string. Username of the contractor to whom the project is allocated.
    • bid_id :string. Winning Bid ID of the project
    • progress: JSON array. Contains an array of message updates by a contractor with timestamp.
    • createTimeStamp : string. Project creation timestamp.
    • deadline: string. Project deadline timestamp.
    • brochurePath :string. Project brochure file path on the server.
    • type: string. Project type.

PATH: /gail/project/acceptProject

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique GAIL client username.
password string. User password.
id string. Project ID.

USAGE:To accept project work.

RESPONSE: JSON

Contains following fields:

  • success: boolean.True if successful query.Otherwise false.
  • message: string. Contains the query message.

PATH: /gail/project/rejectProject

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique GAIL client username.
password string. User password.
id string. Project ID.

USAGE: To reject project work.

RESPONSE: JSON

Contains following fields:

  • success: boolean.True if successful query.Otherwise false.
  • message: string. Contains the query message.

PATH: /gail/project/getAllBids

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique GAIL client username.
password string. User password.
id string. Project ID.

USAGE: To get all bids for a particular project.

RESPONSE: JSON

Contains following fields:

  • success: boolean.True if successful query. Otherwise false.
  • message: string. Only returned on failure. Contains the error message.
  • All bids: JSON array. An array of Bid objects which contains bid details with fields like price, completion time etc

PATH: /gail/bideval/

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique GAIL client username.
password string. User password.
id string. Project ID.

USAGE: To get the winning bid for a particular project and allocate that bid to that project.

RESPONSE: JSON

Contains following fields:

  • success: boolean.True if successful query.Otherwise false.
  • message: string. Contains query message.

PATH: /gail/bideval/getSingleBid

METHOD: POST

BODY: JSON

Contains following fields:

username string. Unique GAIL client username.
password string. User password.
bid_id string. Bid ID.

USAGE: To get bid details of a particular bid id.

RESPONSE: JSON

Contains following fields:

  • success: boolean.True if successful query.Otherwise false.
  • message: string. Only returned on failure. Contains error message.
  • Object: JSON object.Only returned on success. Contains bid object which contains bid details with fields like price, completion time etc.

Payment Services

API services under this group cater to the use-case for payments. Currently, we are supporting Paytm as a payment gateway.


PATH: /payment/initiateTransaction

METHOD: POST

BODY: JSON

Contains following fields:

mid string. Paytm Merchant ID of the contractor.
merchantKey string. Paytm Merchant key of the contractor.
orderID string. Unique transaction order ID.
value string. Amount of transaction in INR. Can have up to two decimal places.

USAGE: Initiate transaction on Paytm Payment Gateway and get a Transaction token.

RESPONSE: Returns Paytm Initiate Transaction API response. Details at https://developer.paytm.com/docs/initiate-transaction-api/#response__attributes


PATH: /payment/validateTransaction

METHOD: POST

BODY: JSON

Contains following fields:

mid string. Paytm Merchant ID of the contractor.
merchantKey string. Paytm Merchant key of the contractor.
orderID string. Unique transaction order ID.

USAGE: Get status of a previous transaction based on order ID.

RESPONSE: Returns Paytm Transaction Status API response. Details at https://developer.paytm.com/docs/transaction-status-api/#response__attributes

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published