People who aware of their health and fitness often use mobile applications to track their data. 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 rewards them with “Kubecoins” which they can exchange for swag.
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 want 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
- 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.
- 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: enroll a user, query data from the blockchain network, or invoke or perform a transaction.
- The execution workers use the Hyperledger Fabric Node.js SDK to perform the requests. They are listening to the requests from RabbitMQ.
- The execution workers send the requests to the blockchain network, which are then processed. The blockchain network uses NFS to persist the ledger and state database.
- The execution workers receive the response and then persists it in the Redis database with the unique key from #1.
- The mobile app will continue to wait for the blockchain’s response results that should be in the Redis database. The mobile app will query the Redis database with the unique key.
- 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.
- When a user is registered, it calls an IBM Cloud Function to generate a random name and avatar for the user.
- The data from the microservices (the user’s data (steps, name, and avatar) and mobile assets (booklet/articles in the first view of mobile app)) are persisted in MongoDB.
- 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.
- The leaderboard microservice is used to get the standings of the users.
Find the detailed steps for this pattern in the README. The steps show you how to:
- Clone the repo for the pattern
- Create IBM Cloud services
- Configure the blockchain Network
- Deploy the blockchain Network in Kubernetes
- Deploy and configure the microservices in Kubernetes
- Expose the back-end with Kubernetes Ingress
- Configure the Android app
- Test the Android app