Updated the rate limiting system to provide 10 chats per day for all users by default.
-
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
-
RATE_LIMITING_COMPLETE.md
- Updated documentation with new tier limits
-
tests/test_rate_limiter.py (NEW)
- Created test suite to verify rate limiter functionality
- Tests pass ✅
| 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 |
-
New users automatically get the FREE tier with 10 chats per day
-
Limits reset at midnight UTC each day
-
Rate limit enforcement happens in the
/api/chatendpoint:- Check limit before processing request
- Return 429 error if exceeded
- Log usage after successful request
-
Frontend displays:
- Usage badge showing remaining prompts
- Rate limit notification when limit is reached
- Upgrade modal to view pricing plans
Run the test suite:
.venv\Scripts\python.exe tests\test_rate_limiter.pyAll tests passing ✅
The system uses SQLite database (backend/math_mentor.db) with:
subscriptionstable: Tracks user tier and subscription statususage_logstable: Logs each API call with timestamp and user_id
- Frontend components automatically read limits from API responses
- No frontend code changes needed
- Existing users will see updated limits immediately