Skip to content

kmilodenisglez/github.template-fabric.dapp-go

Repository files navigation

🛰 GitHub Template DApp for Hyperledger Fabric

DApp to communicate with Hyperledger Fabric Blockchain Network

NOTE: This DApp has been tested on Ubuntu 18.04 and on Windows 10 with WSL and Golang 1.18 was used.

👉🏾 Read this doc to start DApp in dev mode.

Table of Contents

🛠️️ Configuration file (conf.yaml)

👉🏾 The config file

Param Description default value
APIDocIP IP to expose the api (unused) 127.0.0.1
DappPort app PORT 7001
CronEnabled active the cron job true
EveryTime time interval (in seconds) that the cron task is executed 300 seconds (every 5 minutes)

⚡ Get Started

Download the github.template-fabric.dapp-go project and move to root of project:

git clone https://github.com/kmilodenisglez/github.template-fabric.dapp-go.git && cd github.template-fabric.dapp-go 

🚀 Deployment ways (2 ways)

You can start the server in 2 ways, the first is using docker and docker-compose and the second is manually

📦 Docker way

You will need docker and docker-compose in your system.

To builds Docker image from Dockerfile, run:

docker build --no-cache --force-rm --tag app_restapi .

Use docker-compose to start the container:

docker-compose up

🔧 Manual way

Run:

go mod download
go mod vendor

If you make changes to the Endpoint you must generate Swagger API Spec:

swagger doc

Build:

go build

🌍 Environment variables

The environment variable is exported with the location of the server configuration file.

If you have 🐧Linux or 🍎Dash, run:

export SERVER_CONFIG=$PWD/conf/conf.yaml

but if it's the windows cmd, run:

set SERVER_CONFIG=%cd%/conf/conf.yaml

🏃🏽‍♂️ Start the server

Before it is recommended that you read more about the server configuration file in the section 👉🏾 .

Run the server:

./github.template-fabric.dapp-go

and visit the swagger docs:

http://localhost:7001/swagger/index.html

swagger ui

You can then authenticate and test the remaining endpoints.

🧪 Unit or End-To-End Testing

Run:

go test -v

🔨 Tech and packages

📐 Architecture

This project has 3 layer :

  • Controller Layer (Presentation)
  • Service Layer (Business)
  • Repository Layer (Persistence)
Tag Path Layer
Auth end_auth.go Controller
Dapp end_dapp.go Controller
Auth svc_authentication.go Service
Dapp svc_dapp.go Service
Dapp repo_dapp.go Repository

📐 Swagger

Read swagger doc

About

GitHub Template DApp for Hyperledger Fabric

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages