Architecting a scalable and high available quotation system

As an architect, you would come across to build a scalable and high available system by using cloud services (mainly AWS). You are assigned to a team whose objective is to create/manage insurance policy quotation in B2C model.

You can use pen & paper or online tools to draw diagrams.

If you prefer video explanation then you can watch on YouTube (in Hindi).

You got to know that a customer or a care agent can be the user of the system. The users can interact with the system via web application or mobile app. So, your diagram has two users and UI (web/mobile). 

Your objective is to create a quotation system. So, you need a quotation service which can accept address changes and create quotes and then store in a database table. Now your diagram has a relation between UI, quotation service and quotation database.

To make it secure, you need to have an authentication service which can verify the user with its credentials and generated token to make requests to other endpoints. Auth service will have users details in a database table mainly to deal with user profile and hash passwords.

Now comes a fun part. Where you will store the address of a user. Is it a user database or quotation database? You would anyway store the address in a quotation database, so we can store it there. But no. You want to display the current address on users’ profile page and you should not query the quotation database for it (that is not the job quotation database).  So, you would need to create an endpoint in auth service to retrieve the address of the user from the user database.

The updateAddress endpoint will store the address details. You would need the same data to post to createQuote endpoint of quotation service. You should know the frequency of request on the UI. It can make you change the decision. If there is heavy load on quotation service then UI can be impacted. 

Let's make UI and auth service to be free after their actions. Quotation service needs to handle the load on its own. So, we need to leverage the auto scaling feature of AWS ECS and AWS SQS to get the work done. AWS ECS will handle the load based on your configuration. The updateAddress endpoint will push a message with id or address to a SQS queue. The quotation service will have to listen to the SQS queue and read the messages to create quotes.

Now, we need to notify users via Email and push notification on the UI after a quotation is generated. You can use socket.io and AWS SNS. 

Create a subscriber in SNS and its work will be to send email. 

You need to create a notification service that will be running on socket.io and pulling data from a queue (quotation service will push the message in that queue to notify the user). UI need to change the code to include socket.io library to listen to the notification service. 

And now you can ask your team to create stories and start coding.

Comments

Popular Posts