Skip to content

Latest commit

 

History

History
64 lines (46 loc) · 1.8 KB

File metadata and controls

64 lines (46 loc) · 1.8 KB

Rate Limit Update Summary

Changes Made

Updated the rate limiting system to provide 10 chats per day for all users by default.

Modified Files

  1. backend/rate_limiter.py

    • Updated FREE tier: 5 → 10 prompts/day
    • Updated STANDARD tier: 10 → 25 prompts/day (to maintain tier value)
    • Updated module docstring to reflect new limits
  2. RATE_LIMITING_COMPLETE.md

    • Updated documentation with new tier limits
  3. tests/test_rate_limiter.py (NEW)

    • Created test suite to verify rate limiter functionality
    • Tests pass ✅

Current Rate Limits

Tier Daily Limit Price
FREE 10 prompts $0
STANDARD 25 prompts $5/month
PRO 100 prompts $20/month
PREMIUM 1000 prompts $200/month
CUSTOM Unlimited $20 per 100 requests

How It Works

  1. New users automatically get the FREE tier with 10 chats per day

  2. Limits reset at midnight UTC each day

  3. Rate limit enforcement happens in the /api/chat endpoint:

    • Check limit before processing request
    • Return 429 error if exceeded
    • Log usage after successful request
  4. Frontend displays:

    • Usage badge showing remaining prompts
    • Rate limit notification when limit is reached
    • Upgrade modal to view pricing plans

Testing

Run the test suite:

.venv\Scripts\python.exe tests\test_rate_limiter.py

All tests passing ✅

Database

The system uses SQLite database (backend/math_mentor.db) with:

  • subscriptions table: Tracks user tier and subscription status
  • usage_logs table: Logs each API call with timestamp and user_id

No Breaking Changes

  • Frontend components automatically read limits from API responses
  • No frontend code changes needed
  • Existing users will see updated limits immediately