Awesome
Digital Applications using a Microservice Architecture
Architecture
This project provides is a Reference Implementation for building a cloud-native OmniChannel Application using a Microservices architecture. The Logical Architecture for this reference implementation is shown in the picture below.
Application Overview
The application is a simple store front shopping application that displays a catalog of antique computing devices, where users can buy and add review comments. It has Web and Mobile interface, both the Mobile App and Web App rely on separate BFF (Backend for Frontend) services to interact with the backend data.
There are several components of this architecture.
- This OmniChannel application contains both a Native iOS Application and an AngularJS based web application. The diagram depicts them as a Device and Browser.
- The iOS application uses the IBM Mobile Analytics Service to collect device analytics for operations and business
- Both Client Applications (or via BFF) make API calls through an API Gateway. The API Gateway is API Connect. API Connect provides an OAuth Provider as well, allowing you to implement API Security.
- The Web and Mobile app invoke their own backend Microservices to fetch data, we call this component BFFs following the Backend for Frontends pattern. In this Layer, front end developers usually write backend logic for their front end. The Web BFF is implemented using the Node.js Express Framework. The Mobile iOS BFF is implemented using Server side Swift. These Microservices run in Bluemix as Cloud Foundry Applications.
- These BFFs invoke another layer of reusable Java Microservices. In a real world project, this is sometimes written by a different team. These reusable microservices are written in Java using SpringBoot. They run inside IBM Containers using Docker.
- The SocialReview microservices is implemented with Serverless technologies on Bluemix OpenWhisk. It exposes itself as consumable REST API via API gateway mentioned above.
- BFFs, OpenWhisk and Java Microservices communicate to each other using the Netflix OSS Framework. In this case, we run several Netflix components in Bluemix.
- Zuul provides a proxy layer for the microservices.
- Eureka provides a Service Registry. The reusable Java Microservices register themselves to Eureka which allows clients to find them.
- Hystrix Provides an implementation of the Circuit Breaker Pattern. This component runs as library inside the Java Applications. This component them forward Service Availability information to the Hystrix Dashboard.
- The Java Microservices retrieve their data from databases. The Catalog service retrieves items from a searchable JSON datasource using ElasticSearch. The Inventory Service using MySQL. In this example, we run MySQL in a Docker Container for Development (In a production environment, it runs on our Infrastructure as a Service layer, Bluemix Infrastructure) The resiliency and DevOps section will explain that. The SocialReview Microservice relies on Cloudant as its Database. The application also relies on Bluemix Object Storage to store unstructured data such as images.
Project repositories:
This project organized itself like a microservice project, as such each component in the architecture has its own Git Repository and tutorial listed below.
- refarch-cloudnative - The root repository (Current repository)
- refarch-cloudnative-bluecompute-mobile - The BlueCompute client iOS and Android applications
- refarch-cloudnative-bluecompute-web - The BlueCompute Web application with BFF services
- refarch-cloudnative-bluecompute-bff-ios - The Swift based BFF application for the iOS application
- refarch-cloudnative-api - The API gateway artifacts
- refarch-cloudnative-auth - The security authentication artifact
- refarch-cloudnative-micro-inventory - The microservices (SpringBoot) app for Catalog (ElasticSearch) and Inventory data service (MySQL)
- refarch-cloudnative-micro-orders - The microservices (IBM Liberty based) app for Order data service (MySQL)
- refarch-cloudnative-micro-customer - The microservices (SpringBoot) app to fetch customer profile from identity store
- refarch-cloudnative-micro-socialreview - The microservices (Serverless OpenWhisk) app for SocialReview data service (Cloudant)
- refarch-cloudnative-netflix-eureka - Contains the Eureka containers for Microservices foundation
- refarch-cloudnative-netflix-zuul - Contains the Zuul proxy containers for Microservices foundation
This project contains tutorials for setting up CI/CD pipeline for the scenarios. The tutorial is shown below.
- refarch-cloudnative-devops - The DevOps assets are managed here
This project contains tutorials for setting up Resiliency such as High Availability, Failover, and Disaster Recovery for the above application.
- refarch-cloudnative-resiliency - The Resiliency Assets will be managed here
- refarch-cloudnative-csmo - The BlueCompute application end-to-end cloud service management
Run the reference applications locally and in IBM Cloud
To run the sample applications you will need to configure your Bluemix enviroment for the API and Microservices runtimes. Additionally you will need to configure your system to run the iOS and Web Application tier as well.
Step 1: Environment Setup
Prerequisites
- Install Java JDK 1.8 and ensure it is available in your PATH
- Install Node.js version 0.12.0 or version 4.x
- Install Docker on Windows or Mac
- Login to your Bluemix account or register for a new account here
Install the Bluemix CLI
In order to complete the rest of this tutorial, many commands will require the Bluemix CLI toolkit to be installed on your local environment. To install it, follow these instructions
This walkthrough uses the cf
tool.
Create a New Space in Bluemix
- Click on the Bluemix account in the top right corner of the web interface.
- Click Create a new space.
- Enter "cloudnative-dev" for the space name and complete the wizard.
Get application source code
-
Clone the base repository:
git clone https://github.com/ibm-cloud-architecture/refarch-cloudnative
-
Clone the peer repositories:
./clonePeers.sh
Building Microservices with Docker Containers
Step 2: Deploy Netflix Eureka/Zuul components to Bluemix Container
We used the Netflix OSS stack to provide some of the Microservices foundation services such as service registry and proxy/load balancer.
Please follow the instruction in refarch-cloudnative-netflix-eureka repository to deploy Eureka to Bluemix.
Please follow the instruction in refarch-cloudnative-netflix-zuul repository to deploy Zuul to Bluemix.
Step 3: Deploy Catalog and Inventory microservices to Bluemix Container
After completing this step, you should have the Catalog and Inventory microservices deployed in Bluemix and interacting with ElasticSearch and MySQL database. You can unit test the microservice as documented in the instruction.
Please follow the instruction in refarch-cloudnative-micro-inventory repository to build and deploy Catalog and Inventory microservices.
Step 4: Deploy Customer and Authentication microservices to Bluemix Container
After completing this step, you should have Customer microservice deployed in Bluemix and interacting with hosted Cloudant database as user identity store. And you should have Authentication service deployed to be used API Connect OAuth flow.
- Please follow the instruction in refarch-cloudnative-micro-customer repository to setup the Cloudant database and build/deploy the Customer microservice to Bluemix.
- Please follow the instruction in refarch-cloudnative-auth repository to build/deploy the Auth microservice to Bluemix.
Step 5: Provision Watson Analytic services and Deploy SocialReview microservice to Bluemix OpenWhisk runtime
After completing this step, you should have SocialReview microservice deployed in Bluemix OpenWhisk and interacting with hosted Cloudant database. You should also have Watson tone analyzer provisioned.
Please follow the instruction in refarch-cloudnative-micro-socialreview repository to build/deploy the microservice to Bluemix.
Step 6: Deploy Order microservice to Bluemix Container
After completing this step, you should have the Order microservice deployed in Bluemix and interacting with MessageHub and MySQL database. You can unit test the microservice as documented in the instruction.
Please follow the instruction in refarch-cloudnative-micro-orders repository to build and deploy Catalog and Inventory microservices.
Publish APIs and setup API Gateway with Bluemix API Connect
Step 7: Setup your API Connect Gateway
Provision the API Connect Service
- Log in to the Bluemix console
- From the Bluemix menu, Select Services -> APIs, then click the API Connect tile in the page.
- In API Connect creation page, specify the Service name anything you like or keep the default. Then select the free Essentials plan for this walkthrough. Click the "Create" button to provision the service.
- After the API Connect service is created, you will be automatically redirected to API Management console.
- In the API Manager page, navigate to the API Connect Dashboard and select "Add Catalog" at the top left. You may notice that a sandbox has automatically been generated for you.
- Name the catalog "BlueCompute" and press "Add".
- Select the catalog and then navigate to the Settings tab and click the Portal sub-tab.
- To setup a Developer Portal that your consumers can use to explore your API, select the IBM Developer Portal radio button. Then click the "Save" button to top right menu section. This will provision a portal for you. You should receive a message like the one below.
- Once the new Developer Portal has been created, you will receive an email.
Installing the IBM API Connect Developer Toolkit
The IBM API Connect Developer Toolkit provides both the API Designer UI and a CLI that developers can use to develop APIs and LoopBack applications, as welll as the tools to publish them to the IBM API Connect runtime.
Before getting started, you will need to install Node.js version 0.12 or version 4.x, follow the link below for more information details. https://www.ibm.com/support/knowledgecenter/en/SSFS6T/com.ibm.apic.toolkit.doc/tapim_cli_install.html
To install the APIC Connect CLI:
$ npm install -g apiconnect
$ apic --version
That should install the tool and print the version number after the last command.
Step 8: Publish application APIs to Bluemix API Connect
Once you have all the backend application (Catalog/Inventory/Customer/Order/SocialReview) deployed, it is time to publish the APIs to the IBM Bluemix API connect and Setup developerPortal to consume the API.
Please follow the instruction in refarch-cloudnative-api repository to publish APIs to Bluemix API Connect runtime.
Building Web and Mobile Applications
Step 9: Deploy the BlueCompute Web app
This step will deploy the Node.js application containing both the Web BFF and the front end AngularJS application.
Please follow the instruction in refarch-cloudnative-bluecompute-web repository to setup and validate your Web application.
Step 10: Integrate the BlueCompute iOS app with IBM Cloud and Mobile Analytics
Time to test the application end-to-end. You can start with running the iOS application to integrate with the APIs as well as monitoring the application using Bluemix Mobile Analytics service.
Please follow the instruction in refarch-cloudnative-bluecompute-mobile repository to setup your iOS application.
DevOps automation, Resiliency and Cloud Management and Monitoring
DevOps
You can setup and enable automated CI/CD for most of the BlueCompute components via the Bluemix DevOps open toolchain. For detail, please check the DevOps project .
Cloud Management and monitoring
For guidance on how to manage and monitor the BlueCompute solution, please check the Management and Monitoring project.
Making Microservices Resilient
Please check this repository on instructions and tools to improve availability and performances of the BlueCompute application.
Secure The Application
Please review this page on how we secure the solution end-to-end.