• Stars
    star
    1,893
  • Rank 24,505 (Top 0.5 %)
  • Language
    CSS
  • License
    Apache License 2.0
  • Created about 6 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Very simplified insurance sales system made in a microservices architecture using .NET Core

ASCLAB .NET Core PoC - LAB Insurance Sales Portal

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

  • .NET 7
  • Entity Framework Core
  • MediatR
  • Marten
  • Eureka
  • Ocelot
  • JWT Tokens
  • RestEase
  • RawRabbit
  • NHibernate
  • Polly
  • NEST (ElasticSearch client)
  • Dapper
  • DynamicExpresso
  • SignalR

Comprehensive guide describing the architecture, applied design patterns and technologies can be found on our blog:

Other articles around microservices that could be interesting:

Business Case

We are going to build very simplified system for insurance agents to sell various kind of insurance products. Insurance agents will have to log in and system will present them with list of products they can sell. Agents will be able to view products and find a product appropriate for their customers. Then they can create an offer and system will calculate a price based on provided parameters.
Finally agent will be able to confirm the sale by converting offer to policy and printing pdf certificate.
Portal will also give them ability to search and view offer and policies.
Portal will also have some basic social network features like chat for agents.
Latest feature is a business dashboard that displays sales stats using ElasticSearch Aggregations and ChartJS.

Architecture overview

NET Microservices Architecture

  • Web - a VueJS Single Page Application that provides insurance agents ability to select appropriate product for their customers, calculate price, create an offer and conclude the sales process by converting offer to policy. This application also provides search and view functions for policies and offers. Frontend talks to backend services via agent-portal-gateway.

  • Agent Portal API Gateway - is a special microservice whose main purpose it to hide complexity of the underlying back office services structure from client application. Usually we create a dedicated API gateway for each client app. In case in the future we add a Xamarin mobile app to our system, we will need to build a dedicated API gateway for it. API gateway provides also security barrier and does not allow unauthenticated request to be passed to backend services. Another popular usage of API gateways is content aggregation from multiple services.

  • Auth Service - a service responsible for users authentication. Our security system will be based on JWT tokens. Once user identifies himself correctly, auth service issues a token that is further use to check user permission and available products.

  • Chat Service - a service that uses SignalR to give agents ability to chat with each other.

  • Payment Service - main responsibilities: create Policy Account, show Policy Account list, register in payments from bank statement file.
    This module is taking care of a managing policy accounts. Once the policy is created, an account is created in this service with expected money income. PaymentService also has an implementation of a scheduled process where CSV file with payments is imported and payments are assigned to policy accounts. This component shows asynchronous communication between services using RabbitMQ and ability to create background jobs. It also features accessing database using Dapper.

  • Policy Service - creates offers, converts offers to insurance policies.
    In this service we demonstrated usage of CQRS pattern for better read/write operation isolation. This service demonstrates two ways of communication between services: synchronous REST based calls to PricingService through HTTP Client to get the price, and asynchronous event based using RabbitMQ to publish information about newly created policies. In this service we also access RDBMS using NHibernate.

  • Policy Search Service - provides insurance policy search.
    This module listens for events from RabbitMQ, converts received DTOs to “read model” and indexes given model in ElasticSearch to provide advanced search capabilities.

  • Pricing Service - a service responsible for calculation of price for given insurance product based on its parametrization.
    For each product a tariff should be defined. The tariff is a set of rules on the basis of which the price is calculated. DynamicExpresso was used to parse the rules. During the policy purchase process, the PolicyService connects with this service to calculate a price. Price is calculated based on user’s answers for defined questions.

  • Product Service - simple insurance product catalog.
    It provides basic information about each insurance product and its parameters that can be customized while creating an offer for a customer.

  • Document Service - this service uses JS Report to generate pdf certificates.

  • Dashboard Service - Dashboard that presents sales statistics.
    Business dashboards that presents our agents sales results. Dashboard service subscribes to events of selling policies and index sales data in ElasticSearch. Then ElasticSearch aggregation framework is used to calculate sales stats like: total sales and number of policies per product per time period, sales per agent in given time period and sales timeline. Sales stats are nicely visualized using ChartJS.

Each business microservice has also .Api project (PaymentService.Api, PolicyService.Api etc.), where we defined commands, events, queries and operations and .Test project (PaymentService.Test, PolicyService.Test) with unit and integration tests.

Running with Docker

You must install Docker & Docker Compose before.
Scripts have been divided into two parts:

  • infra.yml runs the necessary infrastructure.
  • app.yml is used to run the application.

You can use scripts to build/run/stop/down all containers.

To run the whole solution:

./infra-run.sh
./app-run.sh

If ElasticSearch fails to start, try running sudo sysctl -w vm.max_map_count=262144 first

Once the application and infrastructure are started you can open http://localhost:8080 in your browser and see our welcome page. Once there you can use Account menu item to log into the system. Valid users and passwords can be found [here] (https://github.com/asc-lab/dotnetcore-microservices-poc/blob/master/AuthService/DataAccess/InsuranceAgentsInMemoryDb.cs). You can for example login as admin with password admin.

Manual running

Prerequisites

Install PostgreSQL version >= 10.0.

Install RabbitMQ.

Install Elasticsearch version >= 6.

Init databases

Windows

cd postgres
"PATH_TO_PSQL.EXE" --host "localhost" --port EXAMPLE_PORT --username "EXAMPLE_USER" --file "createdatabases.sql"

In my case this command looks like:

cd postgres
"C:\Program Files\PostgreSQL\9.6\bin\psql.exe" --host "localhost" --port 5432 --username "postgres" --file "createdatabases.sql"

Linux

sudo -i -u postgres
psql --host "localhost" --port 5432 --username "postgres" --file "PATH_TO_FILE/createdatabases.sql"

This script should create lab_user user and the following databases: lab_netmicro_payments, lab_netmicro_jobs, lab_netmicro_policy and lab_netmicro_pricing.

Run Eureka

Service registry and discovery tool for our project is Eureka. It is included in the project. In order to start it open terminal / command prompt.

cd eureka-server
./gradlew.[bat] bootRun

This should start Eureka and you should be able to go to http://localhost:8761/ and see Eureka management panel.

Build

Build all projects from command line without test:

Windows

cd scripts
build-without-tests.bat

Linux

cd scripts
./build-without-tests.sh

Build all projects from command with test:

Windows

cd scripts
build.bat

Linux

cd scripts
./build.sh

Run specific service

Go to folder with specific service (PolicyService, ProductService etc) and use dotnet run command.

More Repositories

1

micronaut-microservices-poc

Very simplified insurance sales system made in a microservices architecture using Micronaut
Java
487
star
2

better-code-with-ddd

This repository contains code that accompanies presentation ASC LAB team gave at meetup about “Creating better code with Domain Driven Design”.
C#
304
star
3

java-cqrs-intro

Examples of implementation CQRS with Event Sourcing - evolutionary approach
Java
200
star
4

dotnet-cqrs-intro

Examples of implementation CQRS with Event Sourcing - evolutionary approach
C#
140
star
5

camunda-dotnetcore-poc

Proof of Concept project that shows how we can use Camunda BPMN Platform in .NET Core applications.
C#
67
star
6

azure-functions-billing

Azure Functions v2 with .NET Core - billing in serverless architecture.
C#
61
star
7

claim-reporter-pwa-poc

Example PWA application with Angular 6 and backend with Node
TypeScript
38
star
8

aws-lambda-billing

AWS Lambda with Micronaut and without any framework - billing in serverless architecture.
Kotlin
31
star
9

micronaut-spring-performance-tests

Micronaut vs Spring - build time, startup time, heap size, used heap size comparision and Gatling load tests.
Java
19
star
10

blockchain-multichain

Application for proposals using blockchain with MultiChain.
Java
19
star
11

ddd-aggregates-example

This is example of modelling DDD aggregates based on PPPDDD book.
Java
18
star
12

ngx-formly-playground

Project with list of Angular Formly exercises. Every next exercise add new feature to the previous one.
TypeScript
17
star
13

personal-insurance-flutter-poc

Flutter project example covering concerns commonly encountered in business apps.
Dart
16
star
14

city-information-bot

Chatbot that can answer the question: "What time is it and what is the weather like in Chicago (or any other city)"?
TypeScript
9
star
15

web-components-poc

Web Components Demos/Examples with Angular/Vue.
TypeScript
7
star
16

microsoft-bot-framework-poc

Our experiments with a Microsoft Bot Framework and LUIS cognitive service.
JavaScript
6
star
17

medical-claims-ddd-example

Java
5
star
18

mlpclassifier-notebook

[ASC Meetup #2] Przykład użycia sieci neuronowych do klasyfikowania branży towaru w procesie kredytu ratalnego
Jupyter Notebook
5
star
19

camunda-modeler-plugin-documentation-generator

This plugin facilitates to generate process diagram docx documentation for Camunda 8 BPMN diagrams.
TypeScript
3
star
20

xamarin-insurance-sales-client

Simple insurance sales mobile client made in a Xamarin.Forms
C#
3
star
21

ddd-workshop-tpa

C#
3
star
22

dotnetcore-graphql-demo

Demo project showing how to quickly build GraphQL API with HotChocolate and Entity Framework
C#
2
star
23

angular-semantic-rwd-menu

RWD Menu with Angular and Semantic UI
TypeScript
2
star
24

coffee-society-accrual

Kotlin
1
star