Skip to content
bossfight
.dev
learn
problems
guides
bosses
roadmap
practice
Interview mode
Live coding rounds with a clock
Gauntlet
Tiny problems back to back: spot it, code it
Quiz
Quick checks on every topic
Which technique?
Name the pattern before you code
Estimation drills
Back-of-envelope numbers for system design
By company
Work through one company's set
Mock assessments
Timed company sets, no hints
Codebase rounds
Fix and extend a real repo
progress
sign in
Search
Ctrl K
menu
Learn
Learn (step by step)
Guides
Roadmap
Practice
Problems
Interview mode
Gauntlet
Quiz
Which technique?
Estimation drills
By company
Mock assessments
Codebase rounds
Play
Boss fights
You
Progress
Sign in
~/rounds
Rate limiter
medium
60 min
Python
Shopify-style
Stripe Bug Squash-style
1
Three keys, three times the limit
2
Build a feature
3
Make it fast
repo
gateway/
__init__.py
config.py
keys.py
limiter.py
middleware.py
models.py
tests/
visible/
test_merchant_limit.py
gw.py
README.md
README.md
read-only
# gateway The front door of a payments API. Every request carries an API key; each merchant can have several keys (one per warehouse, one per environment...). Rate limits are **per merchant**: all of a merchant's keys share one budget. gateway/models.py Request and Response gateway/keys.py KeyStore: which merchant owns an API key gateway/config.py LimitConfig: each merchant's limit and window gateway/limiter.py SlidingWindowLimiter: "at most N requests in any W seconds" gateway/middleware.py handle(): auth, rate limiting, then the app Times are seconds (floats) since some fixed start. A request at time `t` counts against the window `(t - window_s, t]`. Run the tests with `python -m pytest` (or press Run in the browser).
esc