Skip to content
This repository has been archived by the owner on May 22, 2019. It is now read-only.
Anthony Amanse edited this page May 17, 2018 · 7 revisions

Short Name

Create an Android app with Blockchain Integration

Short Description

Build a Blockchain enabled Health and Fitness app with Android and Kubernetes

Offering Type

Cloud

Introduction

People aware of their health and fitness use mobile applications to track their data and some of those apps reward them for reaching certain goals or tasks. With more people becoming more conscious about what data they give to the application developers, we use Hyperledger Fabric (a blockchain framework implementation) to provide anonymity and security on people's data and transactions. The Android app tracks the users' steps and reward them with "Kubecoins" and exchange them with swags.

Author

By Anthony Amanse

Code

Demo

  • link to demo video

Video

  • link to youtube video

Overview

Modern development requires scalability, resiliency and good management and that's why we chose to use Kubernetes for our Android app's backend. We chose to use Hyperledger Fabric to enable the app with Blockchain capabilities. We used MongoDB for our data storage and RabbitMQ and Redis to optimize Blockchain requests.

This code pattern is for developers who wish to provide data anonymity and security to their users. Their users will be more confident to use their app if it gives them more control over their privacy. The developers can also extend the pattern to use the backend from different platforms.

The Android application was used in KubeCon Europe 2018.

When you have completed this code pattern, you will understand how to:

  • Build a native Android app and use Google Fit for its steps data
  • Deploy a Blockchain Network in Kubernetes
  • Integrate the Android app with the Blockchain network

Flow

  1. The REST API is how the mobile app will interact with the blockchain network. The API will acknowledge the request and the mobile app will receive a unique key (random numbers and letters) which will be used to get the blockchain’s response later.
  2. The API just stores the request in a queue in RabbitMQ. The queue has 2 channels, which are for the user (Fitcoin org) and the seller (Shop org). The requests can either be:
    • User enrollment
    • Query data from the blockchain network (number of kubecoins of a user, products that are for sale, contracts, etc…)
    • Invoke or perform a transaction (send steps to receive kubecoins, claim a product, complete a transaction, etc…)
  3. The execution workers use the Hyperledger Fabric Node.js SDK to perform above requests. They are listening to the requests from RabbitMQ.
  4. The workers send the requests to the Blockchain network and are then processed. The blockchain network uses NFS to persist the ledger and state database.
  5. The workers receive the response and then persists it in the redis database with the unique key from (# 1).
  6. The mobile app will continue to wait for the blockchain’s response results that should be in the redis database. This is where the unique key is used. The mobile app will query the redis database with the unique key.
  7. The Registration microservice is used to create a user or update the user’s steps. When the blockchain network enrolls a user, this service uses the user id assigned by the blockchain network.
  8. When a user is registered, it calls a Cloud Function to generate a random name and avatar for the user.
  9. The data from the microservices are persisted in a MongoDB. This is where the user’s data (steps, name and avatar) and mobile assets (booklet/articles in the first view of mobile app) are persisted.
  10. The mobile assets microservice is used to query the MongoDB to get dynamic data for the mobile app. The booklet in the first view uses the database for its content.
  11. The leaderboard microservice is used to get the standings of the users.

Included components

  • IBM Cloud Container Service: IBM Bluemix Container Service manages highly available apps inside Docker containers and Kubernetes clusters on the IBM Cloud.
  • Hyperledger Fabric v1.0: An implementation of blockchain technology that is intended as a foundation for developing blockchain applications or solutions for business.
  • Compose for MongoDB: MongoDB with its powerful indexing and querying, aggregation and wide driver support, has become the go-to JSON data store for many startups and enterprises.
  • Compose for RabbitMQ: RabbitMQ is a messaging broker that asynchronously communicates between your applications and databases, allowing you to keep seperation between your data and app layers.
  • Compose for Redis: An open-source, in-memory data structure store, used as a database, cache and message broker.
  • Cloud Functions: Execute code on demand in a highly scalable, serverless environment.

Featured technologies

  • Blockchain: Distributed database maintaining a continuously growing list of secured records or blocks.
  • Container Orchestration: Automating the deployment, scaling and management of containerized applications.
  • Serverless: An event-action platform that allows you to execute code in response to an event.
  • Databases: Repository for storing and managing collections of data.

Blog

Blog Title

Blog Author

Blog Content

Links

  • Hyperledger Fabric Node SDK: Node SDK to interact with the Hyperledger Fabric network.
  • Google Fit: Give your app the capability to get and update fitness information.
  • iOS version: A native iOS version of the app ineracting with the Hyperledger Fabric network.