{"id":26706536,"url":"https://github.com/rahul07bagul/design-rate-limiter","last_synced_at":"2026-05-09T04:33:55.689Z","repository":{"id":284634270,"uuid":"946752941","full_name":"rahul07bagul/Design-Rate-Limiter","owner":"rahul07bagul","description":"Rate Limiter","archived":false,"fork":false,"pushed_at":"2025-03-26T21:27:05.000Z","size":804,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T22:28:27.022Z","etag":null,"topics":["algorithms","design","hld","java","lld","rate-limiter","redis","spring-boot","system"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rahul07bagul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2025-03-11T16:11:53.000Z","updated_at":"2025-03-26T21:27:16.000Z","dependencies_parsed_at":"2025-03-26T22:39:44.783Z","dependency_job_id":null,"html_url":"https://github.com/rahul07bagul/Design-Rate-Limiter","commit_stats":null,"previous_names":["rahul07bagul/rate-limiter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahul07bagul%2FDesign-Rate-Limiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahul07bagul%2FDesign-Rate-Limiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahul07bagul%2FDesign-Rate-Limiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahul07bagul%2FDesign-Rate-Limiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rahul07bagul","download_url":"https://codeload.github.com/rahul07bagul/Design-Rate-Limiter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245791956,"owners_count":20672671,"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":["algorithms","design","hld","java","lld","rate-limiter","redis","spring-boot","system"],"created_at":"2025-03-27T06:18:13.115Z","updated_at":"2026-05-09T04:33:55.680Z","avatar_url":"https://github.com/rahul07bagul.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Design Rate Limiter\n\nA standalone rate limiter service for Java Spring Boot applications that supports multiple rate limiting algorithms and can be used as a separate service to control API request rates.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/java-%23ED8B00.svg?style=for-the-badge\u0026logo=openjdk\u0026logoColor=white\" alt=\"Java\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Spring_Boot-F2F4F9?style=for-the-badge\u0026logo=spring-boot\" alt=\"Spring Boot\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/MySQL-4479A1?style=for-the-badge\u0026logo=mysql\u0026logoColor=white\" alt=\"MySQL\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/redis-%23DD0031.svg?style=for-the-badge\u0026logo=redis\u0026logoColor=white\" alt=\"Redis\"\u003e\n\u003c/p\u003e\n\n## Demo\n![Demo](https://github.com/rahul07bagul/Rate-limiter/blob/main/assets/Rate_Limiter.gif)\n\n## High Level Design\n![HLD](https://github.com/rahul07bagul/Rate-limiter/blob/main/assets/design.png)\n\n## Class Diagram\n![LLD](https://github.com/rahul07bagul/Rate-limiter/blob/main/assets/uml_diagram.png)\n\n## Features\n- Multiple rate limiting algorithms supported:\n  - Token Bucket\n  - Leaking Bucket\n  - Fixed Window Counter\n- Redis-based storage.\n- Dynamic rule loading from DOC files.\n- Scheduled rule reloading (every 1 hour).\n- REST API for rate limit checking and rule management.\n- Standalone service architecture.\n\n## Integration with Application\n```sh\n@Service\npublic class ApiGatewayService {\n    \n    @Autowired\n    private RestTemplate restTemplate;\n    \n    @Value(\"${rate.limiter.url}\")\n    private String rateLimiterUrl;\n    \n    public boolean isRequestAllowed(String apiPath, String method, String clientId) {\n        String resourceId = apiPath + \":\" + method;\n        \n        RateLimitRequest request = new RateLimitRequest(resourceId, clientId);\n        \n        try {\n            ResponseEntity\u003cRateLimitResponse\u003e response = restTemplate.postForEntity(\n                rateLimiterUrl + \"/check\", request, RateLimitResponse.class);\n                \n            return response.getBody().isAllowed();\n        } catch (HttpClientErrorException.TooManyRequests ex) {\n            return false;\n        }\n    }\n}\n```\n\n## Rate Limit Rules Format\n```sh\nAPI: /api/users\nMETHOD: GET\nALGORITHM: TOKEN_BUCKET\nLIMIT: 100\nPERIOD: 60\nTIME_UNIT: SECONDS\n\nAPI: /api/orders\nMETHOD: POST\nALGORITHM: LEAKING_BUCKET\nLIMIT: 30\nPERIOD: 60\nTIME_UNIT: SECONDS\n```\n\n## API Usage\n- Check Rate Limit\n  ```sh\n  POST /rate-limiter/api/v1/rate-limit/check\n\n  //Request Body:\n  {\n  \"resourceId\": \"/api/users:GET\",\n  \"clientId\": \"user123\"\n  }\n\n  //Response:\n  {\n  \"allowed\": true,\n  \"limit\": 100,\n  \"remaining\": 99,\n  \"resetTime\": 1646324568\n  }\n  ```\n- Get All Rules\n  ```sh\n  GET /rate-limiter/api/v1/rate-limit/rules\n  ```\n- Reload Rules\n  ```sh\n  POST /rate-limiter/api/v1/rate-limit/rules/reload\n  ```\n  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahul07bagul%2Fdesign-rate-limiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frahul07bagul%2Fdesign-rate-limiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahul07bagul%2Fdesign-rate-limiter/lists"}