A Case Study in microservice APIs
Logical Diagram for the Microservices
There are two approaches to building scalable technical stack:
- Microservices
- Serverless Architecture
Serverless Architecture provides certain advantages in simplifying the deployment as well as it is inherently built on event-driven stack while it needs to be architected as part of solution for microservices architecture.
The technology stack is as follows:
- Frontend built as progressive web app using vue.js / vuex
- Microservices built on Phoenix or Connexion
- ElasticSearch for search
- EventStore implemnetation on top of Kafka with PostgreSQL and Cassandra supported by Redis for fast cache.
- Bi Analytics stack built on Flink.
- Supporting libraries and services like zipkin.
Serverless can be implemented on top of AWS Lambda, API Gateway and AWS Step Functions on AWS Cloud or using Azure Functions on Azure Cloud
- Due to limited time, the first point was to prioritize and set what can be achieved in given time.
- The logical services for Microservices architeture has been provided.
- For generating the APIs, swagger was used. The project gave an opportunity to gain more learning about what the framework had to offer. It provides API framework providing specification and tools across Design, Build and Document. IT leverages the OpenAPI initiative.
- As outlined incase study requirement, the focus was given on a couple of microservices around catalog and pricing and separate API sepcification were created for these in json format.
- Boilerplate code has been provided to compare implementation across various languages, which wre contenders.
- Some of the implicit requirements like presence across geographies were designed across in API, like provide linking a product to different website.
- Deployment considerations, such as use of docker/ kubernetes have been considered but have not been explicitly outlined as that was not the primary focus here.
What can be improved: There is still some extraneous classes / code in different services like category in Pricing microservices which need to be cleaned out.
Swagger Editor was used to generate the API. The code boilerplate is provided for following languages -
- Python / Flask, using Connexion
- Ruby / Sinatra
- Go
- Erlang
- ASPNetCore (so that can be used on Ubuntu)
The API follows the OpenAPI 2.0 standard. The documentation can be viewed in two ways:
- Go to the Swagger UI tool.
- Enter the following urls -
- for catalog API - https://rawgit.com/jethar/shoppers/api-docs/api-docs/catalog/index.html
- for pricing API - https://rawgit.com/jethar/shoppers/api-docs/api-docs/pricing/index.html