apayment-backend

command module
v0.0.0-...-a50b575 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

README

aPayment Backend

Build Status

aPayment is a prototypical implementation of a blockchain-based system to demonstrate how such a system can increase transparency and automate interactions. In this, Farmers will be able to generate requests for Direktzahlungen; Cantonal authorities will subsequently be able to assign an inspector to the request, which can then conduct inspections.

The backend of aPayment is implemented in Go. To build and develop the backend, an open source framework Beego has been used

Prerequisites

In order to run the aPayment backend following prerequisites are required:

  • Go - Go programming language (v 1.8) has to be installed to build and run the backend.
  • Beego - This project uses the Beego framework.
  • An Ethereum node - An Ethereum client is required that is able to run a JSON RPC server accepting request over IPC.
  • An Ethereum account - In order to deploy contracts and interact with them, an Ethereum account installed on the Ethereum node with a positive Ether balance (min. 4 Ethers) is required.
  • PostgreSQL - This project uses a PostgreSQL database. A database user has to be set up. The schema creation and seeding is done automatically.

Local Development

Run following commands to download the current master from GitHub. The go get command directly downloads all the required dependencies.

# Install bee
go get github.com/beego/bee
# Downloads the project including dependencies
go get -v github.com/scmo/apayment-backend
# Navigate to project folder
cd $GOPATH /src/github.com/scmo/apayment
# Run project
bee run
Testing

To run tests, three environment variables have to be set:

  • AGATE_USERNAME = <agate username>
  • AGATE_PASSWORD = <agate password>
  • TVD_MANUFACTURER_KEY = <manufacturer key>

Configuration

The configuration of the backend consists of three files.

  • conf/app.conf - This is the main configuration file. It specifies various general parameters like application name, port and run mode. The credentials for accessing the TVD is also specified in this file.
  • conf/app.dev.conf - As the name suggests, this file contains the configurations for the development run mode. It specifies the database connection parameter, JWT secret and expiry time, and Ethereum parameters like inter-process communication (IPC), system account and addresses of the RBAC and aPayment Token smart contracts.
  • conf/app.prod.conf - The file is structured equivalent to the conf/app.dev.conf file with only different parameter values.

Deployment

Since Go application can be compiled to a binary file, the deployment of the backend is very straightforward.

# Navigate to project folder
cd $GOPATH/src/github.com/scmo/apayment-backend
# Compile packages and dependencies
go build github.com/scmo/apayment-backend
# Transfer binary to server
scp apayment-backend <user@host>:/usr/local/bin
# Transfer conf files to server
scp -r conf <user@host>:/usr/local/etc

The binary file can then be executed on the server and the aPayment backend is running.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
@APIVersion 1.0.0 @Title APayment API @Description Autogenerated API Documentation of the apayment backend @Contact moritz.schneider3@uzh.ch @TermsOfServiceUrl https://apayment.ch @License Apache 2.0 @LicenseUrl http://www.apache.org/licenses/LICENSE-2.0.html
@APIVersion 1.0.0 @Title APayment API @Description Autogenerated API Documentation of the apayment backend @Contact moritz.schneider3@uzh.ch @TermsOfServiceUrl https://apayment.ch @License Apache 2.0 @LicenseUrl http://www.apache.org/licenses/LICENSE-2.0.html
tvd
smart-contracts
tests
db_test
+build !test
+build !test

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL