asc-lab / micronaut-microservices-poc

Very simplified insurance sales system made in a microservices architecture using Micronaut
https://altkomsoftware.pl/en/blog/microservices-micronaut/
Apache License 2.0
486 stars 170 forks source link
consul h2-database insurance jwt jwt-auth kafka micronaut microservices microservices-architecture mongodb postgresql zipkin

ASCLAB Micronaut PoC - LAB Insurance Sales Portal

Build Status

This is an example of a very simplified insurance sales system made in a microservice architecture using Micronaut.

Comprehensive guide describing exactly the architecture, applied design patterns and technologies can be found on our blog in article Building Microservices with Micronaut.

We have recently upgraded to Java 14 (you must have JDK14 in order to build and run the project).

We encourage you to read, because in this README there is only a substitute for all information.

Other articles around microservices that could be interesting:

Architecture overview

Micronaut Microservices Architecture

Each business microservice has also -api module (payment-service-api, policy-service-api etc.), where we defined commands, events, queries and operations.

In the picture you can also see the component internal-command-bus. This component is used internally by microservices if we want to use a CQRS pattern inside (simple example in OfferController in policy-service).

Building

This step requires Java 14 (JDK), Maven and Yarn.

For demo purposes build process is automated by a shell script. For Unix-based systems:

build-without-tests.sh

For Windows:

build-without-tests.bat

If you already run the necessary infrastructure (Kafka, Consul etc.), you should run build with all tests: For Unix-based systems:

build.sh

For Windows:

build.bat

Running for development

Prerequisites

Windows users: make sure to set core.autocrlf false in git configuration before cloning this repository.

For Windows users, append below line C:\Windows\System32\drivers\etc\hosts:

127.0.0.1 kafkaserver

For frontend app running, you must add file .env.local based on .env-example .

Env

Automated deployment

To run the whole system on local machine just type:

docker-run.sh

Make sure you've first built the microservices! Check this. This script will provision required infrastructure and start all services. Setup is powered by docker-compose and configured via docker-compose.yml file.

Afterwards you need to add kafka cluster - either via web UI (Kafka Manager -> Cluster -> Add Cluster) or using provided script:

kafka-create-cluster.sh

At this point system is ready to use: http://localhost

Manual deployment

If you want to run services manually (eg. from IDE), you have to provision infrastructure with script from scripts folder:

infra-run.sh

Afterwards you need to add kafka cluster - either via web UI (Kafka Manager -> Cluster -> Add Cluster) or using provided script:

kafka-create-cluster.sh

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

Check this;

Add POLICY template to JsReport

Zipkin

  1. Click "+".
  2. Type name "POLICY" and content from file policy.template.
  3. Commit changes.

Consul without our script

docker run -p 8500:8500 consul

Zipkin without our script

docker run -d -p 9411:9411 openzipkin/zipkin

Kafka without our script

Setup Kafka on Windows with this instruction.

JSReport without our script

docker run -p 5488:5488 jsreport/jsreport

OpenAPI/Swagger docs

agent-portal-gateway provides the API description.

You can go to URL: [http://localhost:8081/swagger/lab-insurance-sales-portal-api-1.0.yml][http://localhost:8081/swagger/lab-insurance-sales-portal-api-1.0.yml]

Add new microservice

Create new microservice with Micronaut CLI:

mn create-app pl.altkom.asc.lab.[SERVICE-NAME]-service -b maven

This command generate project in Java and Maven as build tool.

Examples

Sample users

Chat

Chat

Sales Dashboard

Sales Dashboard

Tracing requests with Zipkin

Zipkin

Show topics on Kafka

Kafka

Show registered services in Consul

Consul

Show document templates in JS Report

JSReport

References