HTTP service to send emails via multiple email service providers.
The architectural design of this application is split into two main components:
- HTTP service with data storage to process incoming web requests.
- Background workers to process outgoing HTTP connections to email services.
This design keeps functionally in modular components which allows for isolated testing of different functionality. The http_mailer gem created specifically for this application is a self contained unit which can be tested, rewritten and replaced should the requirementsof this application change.
This design takes performance into consideration. The high latency task of connecting to email service provider APIs is done asynchronously using background Resque workers. This allows the HTTP service to process incoming web requests quickly. This design is also scalable. More servers or process workers can be added to the HTTP service and the background workers independently to increase the load capacity and system throughput.
- PostgreSQL
- Redis
Setup:
$ bundle install
$ bundle exec rake db:create
$ bundle exec rake db:migrate
Then run using foreman:
$ bundle exec foreman start
$ curl -H "Content-Type: application/json" -d '{"to":"fake@example.com","to_name":"Ms. Fake","from":"noreply@uber.com","from_name":"Uber","subject":"A Message from Uber","body":"\u003ch1\u003eYour Bill\u003c/h1\u003e\u003cp\u003e$10\u003c/p\u003e"}' localhost:5000/email
- Ruby is simple, expresive, and powerful with many useful tools and libraries available.
- Sinatra is lightweight and a good choice for a web service with a small number of end points such as this one.
Make the order in which email service providers are connected to configurable.
The application tracks whether a email was delivered or not using a boolean field in the data record of each message. Add a mechanism to retry sending undelivered emails.
- Fork it ( https://github.com/[my-github-username]/http_mailer/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request