Newsletter Service

A newsletter service to send mails to all the subscribers of a particular topic.

About The Project


While adding the newsletter content we are checking for latestTime key in the redis. If the new content time is lesser than the already stored latestTime key in redis then update all the keys in the redis, which are

  1. latestTime
  2. latestText
  3. latestTopic
  4. latestId – ID of the content document

The scheduler script runs on an interval of 1 minute and checks whether the current time is equal or greater than the latestTime stored in the redis.

If the above condition satisfies then the mail is sent to all the subscribers of the latestTopic. After sending the mail the sent content is deleted and the next latest deadline content is stored in the redis database

Built With

Tools that were used in the process of making this microservice are:

Getting Started

To get a local copy up and running follow these simple steps:


This is an example of how to list things you need to use the software and how to install them.


  1. Clone this project.

    git clone https://github.com/tanay13/newsletter-service.git
  2. Navigate to the cloned directory

    cd newsletter-service
  3. refer the .env-example file and enter all the environment variables there

  4. Enter the following command

    node app.js
  5. Start the scheduler script

    node script.js


  • Post data to the following api to subscribe to a topic


    with body as :

        "email": "[email protected]",
  • Post data to the following api to add the newsletter content


    with body as :

      "contentText": "hey this is a newsletter",
      "topic": "nutrition"


  • Add readme
  • Add scheduler script

See the open issues for a full list of proposed features (and known issues).


  • Their can few minutes delay when dealing with two deadline with very less time intervaL
  • Service not tested with some of the edge cases
  • Server overloading can occur in case of high number of content


Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag “enhancement”. Don’t forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request


Distributed under the MIT License. See LICENSE.txt for more information.


Your Name – Tanay[email protected]

Project Link: https://github.com/tanay13/newsletter-service



View Github