This is the code of the demos for the "Baking a Microservice Pie" talk given by @radcortez and @agoncal.
The idea of the talk and the code, is to slowly build an entire microservice architecture (and deploy it on a cluster of Raspberry Pi). It is based on a DVD/CD/Book store where you can search for items, buy them (using a shopping cart) and see the inventory stock. But the code here has less functionalities.
Its genesis comes from the Tomitribe talk: Microprofile JCache
To get the slides of this presentation, just generate them by doing a mvn clean process-resources
under the slides
directory. The slides will then be generated under setup/target/generated-docs/slides.html
.
Anybody can browse the catalog of CDs, Books and DVDs.
Once logged-in, an anonymous user becomes a customer. A customer can add, remove, browse and check-out the items of his/her shopping cart. The customer can also change his/her profile. Each time items are sold, the inventory is updated.
Administrators can create, update, delete items (CDs, DVDs, Books). A new item needs a number (ISBN, UPC, EAN or GS1). Each time an items is created of deleted, the inventory is updated.
This talk has several demos. Each one builds on top of the other. For example, Demo02
is built on Demo01
but brings the solution to a problem (eg. How do we register microservices ?). The last Demo
folder (.i.e Demo99
) is the final application, up and running.
Demo01
: We build a single very simple microservices (number-api
) that generates a book number. It has a user interface.Demo02
: We build several microservices (DVD, CD, Book, ShoppingCart, NumberGenerator and Inventory). Each service depends on another one. Problem: The URLs are hard coded.Demo02
: We add a registry service so that each microservice car register itself and discover the others. Problem: How can we scale.Demo03
: We need a client load-balancer so each microservice can choose from several instances of another service. Problem: Now we have services everywhere, how do we monitor them.Demo05
: We need centralized monitoring. Problem: we need to secure these services with JWT in a centralize way.Demo06
: We need a centralized gateway dealing with authentication. Problem: under load, some services do not answer and block the other.Demo07
: We need to implement the circuit breaker pattern. Problem: Debugging is hard, we are lost between all services calls.Demo08
: We need a tracking systemDemo99
: Final application
+-- services
| +-- book-api
| | +-- src
| | +-- main
| | +-- test
| +-- number-api
| | +-- src
| | +-- main
| | +-- test
+-- clients
| +-- angular application
| +-- jax rs client to test services
| +-- curl commands
+-- deployment
| +-- ansible scripts
| +-- docker config
+-- infra
| +-- consul
| +-- elk
Several tools are needed to make this code work
-
Yarn :
yarn global add @angular/cli@next
-
When testing on Chrome, use this plugin to disable CORS (otherwise, it's painful)