"""Shared rate-limiter instance. Lives in its own module so routers can import it without triggering the circular import that would occur if they imported from app.main. The limiter keys on the remote address, so it is only meaningful where one IP really is one client. `settings.rate_limit_enabled` exists to switch it off where that is not true (the E2E suite drives every page load from 127.0.0.1) — see the comment on that setting in `app/config.py`. """ from slowapi import Limiter from slowapi.util import get_remote_address from app.config import settings limiter = Limiter(key_func=get_remote_address, enabled=settings.rate_limit_enabled)