Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/omkargade04/rate-limiting

This a backend server build using spring boot. It contains API endpoints . Main objective of this project is to implement rate limiting feature on APIs using Redis
https://github.com/omkargade04/rate-limiting

docker java postgresql redis springboot

Last synced: 18 days ago
JSON representation

This a backend server build using spring boot. It contains API endpoints . Main objective of this project is to implement rate limiting feature on APIs using Redis

Awesome Lists containing this project

README

        

# RATE LIMITER WITH REDIS


  • This application is a Spring Boot application demonstrating rate limiting with Redis for user management operations.


  • Explanation:


    • UserController: The API endpoint for managing user information. It includes methods to handle creating, retrieving, updating, and deleting user data. This controller interacts with the UserService to perform these operations.


    • UserService: Contains the business logic for user management. It performs CRUD operations on the User entity and interacts with the RateLimiterService to apply rate limiting rules.


    • RateLimiterService: Utilizes Redis to track and enforce rate limiting rules. It ensures that the number of requests made by a user does not exceed the specified limit within a given time window.


    • UserRepository: Extends Spring Data JPA's JpaRepository, providing methods for performing database operations on user entities. This layer abstracts the data access operations, making it easier to manage user data.


    • Redis Configuration: Redis is configured to support rate limiting functionality. The configuration includes setting up a RedisTemplate for efficient data access and operations. This template handles the interactions with Redis, such as incrementing request counts and setting expiration times for keys, ensuring accurate rate limiting.



### Explore Rest APIs


Method
Url
Description
Request Body


POST
/api/v1/users
Create a new user
create user vody



GET
/api/v1/users
Retrieve all users



GET
/api/v1/users/{userId}
Retrieve a user by ID



PUT
/api/v1/users/{userId}
Update an existing user
update user body



DELETE
/api/v1/users/{userId}
Delete a user by ID

---
Docker
---

### Docker Run
The application can be built and run by the `Docker` engine. The `Dockerfile` has multistage build, so you do not need to build and run separately.

Please follow directions shown below in order to build and run the application with Docker Compose file;

```sh
$ cd rate-limiting
$ docker-compose up -d
```

If you change anything in the project and run it on Docker, you can also use this command shown below

```sh
$ cd rate-limiting
$ docker-compose up --build
```

---