{"id":21076332,"url":"https://github.com/rapter1990/ratelimiter","last_synced_at":"2025-05-16T06:32:18.015Z","repository":{"id":246587730,"uuid":"821557639","full_name":"Rapter1990/ratelimiter","owner":"Rapter1990","description":"Spring Boot Rate Limiter with Redis (Spring Boot, Java 21, JUnit, Integration Test, Github Actions, Test Container, Docker, Redis)","archived":false,"fork":false,"pushed_at":"2024-07-02T19:37:07.000Z","size":4449,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-07-04T14:54:30.736Z","etag":null,"topics":["cicd","docker","docker-compose","github-actions","integration-test","java","java21","junit","lombok","maven","postman","redis","spring-boot","testcontainer"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rapter1990.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-28T20:22:04.000Z","updated_at":"2024-07-04T08:10:06.000Z","dependencies_parsed_at":"2024-06-28T21:53:11.445Z","dependency_job_id":"7004a00b-aa13-4480-98dc-1f7320a9d0a7","html_url":"https://github.com/Rapter1990/ratelimiter","commit_stats":null,"previous_names":["rapter1990/ratelimiter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rapter1990%2Fratelimiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rapter1990%2Fratelimiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rapter1990%2Fratelimiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rapter1990%2Fratelimiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rapter1990","download_url":"https://codeload.github.com/Rapter1990/ratelimiter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225413211,"owners_count":17470535,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cicd","docker","docker-compose","github-actions","integration-test","java","java21","junit","lombok","maven","postman","redis","spring-boot","testcontainer"],"created_at":"2024-11-19T19:27:52.185Z","updated_at":"2024-11-19T19:27:52.843Z","avatar_url":"https://github.com/Rapter1990.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RATE LIMITER WITH REDIS\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"screenshots/spring_boot_rate_limiter_redis.png\" alt=\"Main Information\" width=\"850\" height=\"600\"\u003e\n\u003c/p\u003e\n\n### 📖 Information\n\n\u003cul style=\"list-style-type:disc\"\u003e\n  \u003cli\u003eThis application is a \u003cb\u003eSpring Boot application\u003c/b\u003e demonstrating rate limiting with Redis for user management operations.\u003c/li\u003e\n  \u003cli\u003e\n    \u003cb\u003eExplanation:\u003c/b\u003e\n    \u003cul\u003e\n      \u003cli\u003e\u003cb\u003eUserController:\u003c/b\u003e 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.\u003c/li\u003e\n      \u003cli\u003e\u003cb\u003eUserService:\u003c/b\u003e 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.\u003c/li\u003e\n      \u003cli\u003e\u003cb\u003eRateLimiterService:\u003c/b\u003e 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.\u003c/li\u003e\n      \u003cli\u003e\u003cb\u003eUserRepository:\u003c/b\u003e 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.\u003c/li\u003e\n      \u003cli\u003e\u003cb\u003eRedis Configuration:\u003c/b\u003e 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.\u003c/li\u003e\n      \u003cli\u003e\u003cb\u003eValidation:\u003c/b\u003e The application uses Hibernate Validator for validating user input. This ensures that the data passed to the API endpoints is in the correct format and adheres to the defined constraints.\u003c/li\u003e\n      \u003cli\u003e\u003cb\u003eException Handling:\u003c/b\u003e Custom exception handling mechanisms are implemented to manage various error scenarios, such as user not found, email already exists, and rate limit exceeded.\u003c/li\u003e\n    \u003c/ul\u003e\n  \u003c/li\u003e\n\u003c/ul\u003e\n\n### Explore Rest APIs\n\n\u003ctable style=\"width:100%\"\u003e\n  \u003ctr\u003e\n      \u003cth\u003eMethod\u003c/th\u003e\n      \u003cth\u003eUrl\u003c/th\u003e\n      \u003cth\u003eDescription\u003c/th\u003e\n      \u003cth\u003eRequest Body\u003c/th\u003e\n      \u003cth\u003eHeader\u003c/th\u003e\n      \u003cth\u003eValid Path Variable\u003c/th\u003e\n      \u003cth\u003eRequest Param\u003c/th\u003e\n      \u003cth\u003eNo Path Variable\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003ePOST\u003c/td\u003e\n      \u003ctd\u003e/api/v1/users/save\u003c/td\u003e\n      \u003ctd\u003eCreate a new user\u003c/td\u003e\n      \u003ctd\u003eCreateUserRequest\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003eGET\u003c/td\u003e\n      \u003ctd\u003e/api/v1/users/{id}\u003c/td\u003e\n      \u003ctd\u003eRetrieve a user by ID\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e{id} - Valid UUID\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003ePUT\u003c/td\u003e\n      \u003ctd\u003e/api/v1/users/{id}\u003c/td\u003e\n      \u003ctd\u003eUpdate an existing user\u003c/td\u003e\n      \u003ctd\u003eUpdateUserRequest\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e{id} - Valid UUID\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003eDELETE\u003c/td\u003e\n      \u003ctd\u003e/api/v1/users/{id}\u003c/td\u003e\n      \u003ctd\u003eDelete a user by ID\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e{id} - Valid UUID\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003eGET\u003c/td\u003e\n      \u003ctd\u003e/api/v1/users\u003c/td\u003e\n      \u003ctd\u003eRetrieve a paginated list of users\u003c/td\u003e\n      \u003ctd\u003eUserPagingRequest\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\n---\n### Technologies\n\n\n- Java 21\n- Spring Boot 3.0\n- Restful API\n- Lombok\n- Maven\n- Junit5\n- Mockito\n- Integration Tests\n- Docker\n- Docker Compose\n- CI/CD (Github Actions)\n- Postman\n- Spring Bean Validation\n\n---\n### Postman\n\n```\nImport postman collection under postman_collection folder\n```\n\n---\n### Prerequisites\n\n#### Define Variable in .env file\n\n```\nDATABASE_USERNAME={DATABASE_USERNAME}\nDATABASE_PASSWORD={DATABASE_PASSWORD}\n```\n\n---\n- Maven or Docker\n---\n\n\n### Docker Run\nThe 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.\n\nPlease follow directions shown below in order to build and run the application with Docker Compose file;\n\n```sh\n$ cd ratelimiter\n$ docker-compose up -d\n```\n\nIf you change anything in the project and run it on Docker, you can also use this command shown below\n\n```sh\n$ cd ratelimiter\n$ docker-compose up --build\n```\n\n---\n### Maven Run\nTo build and run the application with `Maven`, please follow the directions shown below;\n\n```sh\n$ cd ratelimiter\n$ docker run --name redis -p 6379:6379 -d redis\n$ mvn clean install\n$ mvn spring-boot:run\n```\n\n---\n### Docker Image Location\n\n```\nhttps://hub.docker.com/repository/docker/noyandocker/ratelimiter/general\n```\n\n---\n### Screenshots\n\n\u003cdetails\u003e\n\u003csummary\u003eClick here to show the screenshots of project\u003c/summary\u003e\n    \u003cp\u003e Figure 1 \u003c/p\u003e\n    \u003cimg src =\"screenshots/docker1.PNG\"\u003e\n    \u003cp\u003e Figure 2 \u003c/p\u003e\n    \u003cimg src =\"screenshots/1.PNG\"\u003e\n    \u003cp\u003e Figure 3 \u003c/p\u003e\n    \u003cimg src =\"screenshots/2.PNG\"\u003e\n    \u003cp\u003e Figure 4 \u003c/p\u003e\n    \u003cimg src =\"screenshots/3.PNG\"\u003e\n    \u003cp\u003e Figure 5 \u003c/p\u003e\n    \u003cimg src =\"screenshots/4.PNG\"\u003e\n    \u003cp\u003e Figure 6 \u003c/p\u003e\n    \u003cimg src =\"screenshots/5.PNG\"\u003e\n    \u003cp\u003e Figure 7 \u003c/p\u003e\n    \u003cimg src =\"screenshots/6.PNG\"\u003e\n    \u003cp\u003e Figure 8 \u003c/p\u003e\n    \u003cimg src =\"screenshots/docker2.PNG\"\u003e\n\u003c/details\u003e\n\n### Contributors\n\n- [Sercan Noyan Germiyanoğlu](https://github.com/Rapter1990)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapter1990%2Fratelimiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frapter1990%2Fratelimiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapter1990%2Fratelimiter/lists"}