This project implements a rate-limited Notification Service using Ruby on Rails, Redis for rate limiting, and PostgreSQL as the database. It ensures that recipients are not overwhelmed with too many email notifications of various types.
- Ruby 3.1.0
- Rails 7.0
- PostgreSQL
- Redis
- Bundler
- Clone the repository:
git clone https://github.com/yourusername/notification_rate_limiter.git
- Install dependencies:
bundle install
- Setup the database:
rails db:create rails db:migrate
- Start the Redis server:
redis-server
- Run the Rails server:
rails server
To run the RSpec tests, use the following command:
rspecThe NotificationService is responsible for sending email notifications. It ensures that the rate limits are respected for each type of notification.
The RateLimiter class handles the logic for enforcing rate limits using Redis.
- Status: Not more than 2 notifications per minute per recipient.
- News: Not more than 1 notification per day per recipient.
- Marketing: Not more than 3 notifications per hour per recipient.
Feel free to open issues or submit pull requests for any improvements or bug fixes.
This project is licensed under the MIT License.