Welcome! This exercise is about debugging and extending a small FastAPI app. You will find a rate limiter that behaves incorrectly under certain conditions, then improve it step by step.
The tasks build on each other. There are more tasks than fit in an hour, so finish what you can and explain your reasoning as you go.
# Install dependencies
uv sync
# Start the server
uv run uvicorn app.web_app:app --reload
# In another terminal, test the endpoint
curl http://localhost:8000/api/resourcerate-limiter-challenge/
├── app/
│ ├── web_app.py # FastAPI application
│ ├── rate_limiter.py # Rate limiter implementation
│ └── config.py # Configuration
├── tests/
│ ├── task0/test_basic_limiting.py # Basic tests (should pass)
│ ├── task1/test_consistency.py # Bug-revealing tests (will fail)
│ └── task2...task5/ (see task folders)
├── scripts/
│ └── demo_bug.py # Demonstrates the bug
├── tasks/
│ └── ... task instructions
└── CHALLENGE.md # This file
- Start with Task 1, then move on in order.
- The tests act as the specification. It is OK to read them.
- You do not need to change the tests.
- Avoid hardcoding values; use configuration or runtime data.
Task instructions live in the tasks/ folder. Start with Task 1:
tasks/task1/README.md
When you finish Task 1, continue with tasks/task2/README.md.
Run all tests at once:
uv run pytest -vRun a specific test file:
uv run pytest tests/task1 -vRun a specific test:
uv run pytest tests/task1/test_consistency.py::TestWindowConsistency::test_consistency_across_edges -vPlease include:
- Your modified code
- A brief explanation of the bug (Task 1)
- Any design decisions or trade-offs you made
- Instructions for running your solution
Good luck!