Challenge Overview
In this challenge series we will be building an email service that will manage and send emails acros many Topcoder services. The overall architecture is based on a message bus (Kafka). Each of the Topcoder services (ex project & challenge services, message service,..) will post events to the message bus (ex a review phase is over, user has joined a project, etc). Our email service will be a consumer of the Kafka queues and will forward the messages fo Sendgrid API that will finally send the email messages. We will use Sendgrid email templates that use <%%> placeholders and we will need to validate the event payload contains all the data for the placeholders.
We have already built a simple REST service that will serve as a proxy to Kafka (refer to it as tc-bus-api). It was built with notification events in mind (a previous challenge series), so we will need to update it in this challenge with the following
-
It is curently adding a 'notifications' prefix to all event types. We need to remove it and require the API users to include the prefix in the event type (right now, clients send connect.project.created and we need to require they send notifications.connect.project.created. email events will be prefixed with 'email')
-
Add validation for event payload. Event payload will contain the values for email placeholders and we need to verify they are all filled before pushing the event to Kafka. To get a list of required placeholders, call the /templates/eventType endpoint of the tc-email service (see bellow, it is developed in this challenge). The api calls to the email service should be cached for a configurable time interval (default to 60 minutes), so there will be only one API call to get the placeholders for each event type.
-
Add a protected endpoint that would clear the placeholders cache, effectively requiring a reload (a new call to the email service)
-
The message body has to contain: placeholder values and recipients list - email addresses.
The email service will consume messages from the Kafka topics and forward the messages to Sendgrid (api docs) and will support the following features:
-
Each event type will have a different mapping so we need to add a configuration that maps event type to Sendgrid templateId. It should be done in a config file that is different for development and production environments.
-
Message will be sent to the sengrid api. In case of failure, just log the error for now. We will add a more robust error handling later on.
-
Create a REST endpoint that fetches the configured templates from sendgrid, parses the subject and htmlbody fields and returns the list of required placeholders.
The email service should follow the architecture of tc-notifications-service - See src/app.js and connect/connectNotificationServer.js (essentially kafka message handling and email processing (send to sendgrid) should be clearly separated.
Make sure all configuration parameters can be set via config files and env variables where appropriate. Create a swagger docs for the email service and update swagger and postman collections for the bus api.
Final Submission Guidelines
Submit updated bus api code
Submit the email service
Submit deployment/verification guide
Submit a short demo video (unlisted Youtube link)