abuzaforfagun / Invoice.Microservices.ThirdPartyAPIIntegration

Scaleable fault tolerance microservices to communicate third party API
9 stars 3 forks source link
asp-net-core coreography microservices microservices-architecture outbox-pattern

Invoice Client - Scaleable Microservice

A web application to create and read invoices from third party services with fault tolerance and in high performance.

Motivation

Components and their communication

Components and their communication

Client Application

A single page application to display the invoice listand create a new one. Framework and Libraries: Angular 12, Angular Material, NgRx

Gateway

Accessible API to transfer read and write requests to desired microservices. Framework and Libraries: ASP .NET 5 Web API, Ocelot

Invoice Processor

Microservice to store user requests to Outbox, sendthe invoice request to Likvdo and, update the outbox. Sending an invoice will run inside a transaction. When third party service is unreachable, insisting on changing the outbox status, it will reschedule the queue. Framework and Libraries: ASP .NET 5 Web API, AzureService Bus, EF Core, MediatR, Automapper

Scheduler

Schedule the execution of the processing pending request command periodically. Framework and Libraries: Quartz

Database

Store user requests in the outbox and contain userevents for better audit and debugging.

Invoice Reader

Microservice to get data from third party service, store and invalidatethem inside Redis Cache for faster delivery. Framework and Libraries: ASP .NET 5 Web API, RedisCache, Azure Service Bus, MediatR, Automapper

Redis Cache

Store the cache of invoice lists for faster delivery.

Service Bus

Used as the way of communication among microservie(s) in an asynchronous way.

Stack holder and application communication

Stack holder and application communication

Processing pending requests

Processing pending requests

Send request to third party service

Send request to third party service

When third party service is unreachable

When third party service is unreachable

Process failed request

Process failed request

Cache Invalidation

Cache Invalidation

Behind the scenes of retrieving Invoice

Behind the scenes of retrieving Invoice

Tradeoffs of the Architecture

Advantages:

Disadvantages:

Installation and running locally

Prerequisite:

Running Microservies:

  1. Open Invoice.sln from the root folder.

  2. Navigate to the appsetting.json of the InvoiceProcessorproject and insert the following data. FYI, in the appsettings.development json file, I have added my test service bus connection string, Likvido API key, and Quartzcron expression. You can generate your corn expression fromhere. Invoice Processor App Settings

  3. Open the appsettings.json of the InvoiceReader project.And provide necessary settings as mentioned below. FYI, you can use the test servicebus and Redis connection string that is included inside appsettings.development.json.

Invoice Reader App Settings

  1. SetGateway, InvoiceReader and InvoiceProcessorasstartup projects.

  2. Run the application by pressing F5 or from the toolbar.

  3. Make sure Invoice Reader is running on 5002 port byvisiting http://localhost:5002/swagger/, Invoice Processor running on 5001 port by browsing http://localhost:5001/swagger/ And, finally Gateway is running on 44300 by visiting https://localhost:44300/swagger/.

Running Front End

  1. Open terminal from the ClientApp folder
  2. Execute yarn install command
  3. Run the application by executing ng serve command. You can find the application at http://localhost:4200

Possible Improvements