A web application to create and read invoices from third party services with fault tolerance and in high performance.
- Develop a distributed application with microservices.
- Implement the microservices to provide better performanceand the ability to scale independently.
- Ensure audit of the user operations.
- Implement the application with SOLID and DRY principles.
- Create reusable components.
- Develop the application following DDD approach.
A single page application to display the invoice listand create a new one. Framework and Libraries: Angular 12, Angular Material, NgRx
Accessible API to transfer read and write requests to desired microservices. Framework and Libraries: ASP .NET 5 Web API, Ocelot
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
Schedule the execution of the processing pending request command periodically. Framework and Libraries: Quartz
Store user requests in the outbox and contain userevents for better audit and debugging.
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
Store the cache of invoice lists for faster delivery.
Used as the way of communication among microservie(s) in an asynchronous way.
Advantages:
- Ensure invoice creation requests would be processed, maybe not now, but for sure at later.
- Full audit of the customer operations.
- As we are storing every customer operation event insideour database. So there is no chance of data loss.
- Caching helps us to deliver faster requests.
- Individual teams can autonomously develop/deploy microservices with minimum/no communication among other teams.
- Scale read and write microservice separately, dependingon demand.
- Because of Gateway, our client application requiresless modification during the internal microservice API changes.
Disadvantages:
- No matter whether third party service is available or not, customers need to wait for a period of time to get their invoices live.
- The logic behind the application gets complex whencompared to a simple CRUD applications.
- Creating deployment infrastructure and CI/CD wouldtake more time than monolithic application.
- Because of caching there are some chances to get outdateddata when anything gets changed from the back office of third party service.
Prerequisite:
- .NET 5 SDK and runtime
- Visual Studio / .NET CLI
- MS SQL Server
- Node
- Angular CLI
Running Microservies:
-
Open Invoice.sln from the root folder.
-
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.
-
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.
-
SetGateway, InvoiceReader and InvoiceProcessorasstartup projects.
-
Run the application by pressing F5 or from the toolbar.
-
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/.
- Open terminal from the ClientApp folder
- Execute
yarn install
command - Run the application by executing
ng serve
command. You can find the application at http://localhost:4200
- Remove hard-coded values from the application(Mostly in the client application).
- Add proper validation in invoice creation.
- Create a circuit breaker, when third party service fails to process requests continuously.
- Better naming and folder structure(mostly in client application).
- Add more unit, integration and E2E test cases.
- Impose better logging.