Production error handling for FastAPI — exception handlers, structured error
96
96%
Does it follow best practices?
Impact
98%
6.12xAverage score across 5 eval scenarios
Passed
No known issues
Build a payment processing API with FastAPI and Python. The API manages customers and their payments.
POST /api/customers -- create a customer with name: str, email: str, balance: floatGET /api/customers/{customer_id} -- get customer by IDPOST /api/payments -- process a payment with customer_id: int, amount: float, currency: str (must be "USD", "EUR", or "GBP")GET /api/payments/{payment_id} -- get payment by IDPOST /api/payments/{payment_id}/refund -- refund a payment (only if status is "completed")Business rules:
Produce Python files:
app/main.py -- FastAPI app with routesapp/models.py -- Pydantic models for requests/responsesapp/database.py -- in-memory data store (dict-based, no real database needed)Do not include test files or deployment configuration.