Skip to content

Fix screenshot functionality and add API key based ratelimiting - #16

Merged
connorakey merged 2 commits into
mainfrom
rust-rewrite
Oct 28, 2025
Merged

Fix screenshot functionality and add API key based ratelimiting#16
connorakey merged 2 commits into
mainfrom
rust-rewrite

Conversation

@connorakey

Copy link
Copy Markdown
Owner

This pull request introduces rate limiting for API requests in the backend, improves image handling for OpenAI endpoints, and adds several new dependencies to support these features. The most significant changes are the addition of per-API-key rate limiting to prevent abuse and the enhancement of image input support. Below are the top changes grouped by theme:

Rate Limiting Implementation:

  • Added a new ratelimit module (backend/src/ratelimit.rs) that uses the governor, dashmap, and once_cell crates to enforce a limit of 3 requests per minute per API key. The check_rate_limit function is now called in the OpenAI endpoint to reject requests exceeding the limit. [1] [2] [3] [4]
  • Updated Cargo.toml to include new dependencies: dashmap, governor, and once_cell for thread-safe rate limiting.

OpenAI Image Handling Improvements:

  • Improved image input handling in both get_step_by_step_guidance and get_final_answer functions to accept either raw base64 strings or full data URLs, making the API more robust to different input formats. [1] [2]

Frontend Configuration:

  • Updated the product name in the Tauri configuration file to "Maths Online App" for improved branding consistency.

@connorakey
connorakey merged commit d6a2b93 into main Oct 28, 2025
1 check passed
@connorakey
connorakey deleted the rust-rewrite branch October 28, 2025 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant