To run everything needed for the application, run this in the root of the repository
docker-compose up -d
This builds the API service, the notifications service and runs Postgres and Kafka. To be able to send emails edit docker-compose and set these environment variables with eg. Mailtrap plain credentials
SMTP_HOST: enterHost
SMTP_PORT: 587
SMTP_USERNAME: smtppw
SMTP_PASSWORD: smtpu
API service provides the following endpoints:
POST /register
{
email: string,
password: string
}
GET /verify/:email/:code
POST /login
{
email: string,
password: string
}
GET /protected
- Email verification using notification service with notification sent over Kafka. After registration another email notification is sent- Welcome email
- Auth using JWT and a test endpoint /protected that is protected route and checks JWT provided in the header
Notification service accepts messages over a Kafka topic (any MQ or Pubsub can be implemented) and in a consumer group processes these notifications. Currently Email notification is implemented and SMS notifications mocked. Any new notification type processor can be implemented.
- Simple SMTP u/p based auth email service
- Compilation of HTML templates that are sent in the mail
- Horizontally scalable with the Kafka consumer group
- Unit tests are not written at this time, but the code is written with tests in mind and everything should be easily testable.
- Notifications are currently written as one notification type per Kafka message. Ability to send the same notification over multiple processors can be added. For instance: -> User preferences set to receive notifications over both Email and SMS. -> Produce a notification (eg. Welcome message with additional metadata in the message being First name and Last name) -> Notification is sent as only one Kafka message alongside user preferences -> Both SMS and email is sent
- While notifications being in another service brings operational complexity and need for orchestration of the services. On the other hand it brings us the ability to separately scale/deploy the service and persist the notification messages with using Kafka