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 an order management API with FastAPI and Python for a small e-commerce backend.
POST /api/orders -- create an order with customer_email: str, items: list where each item has product_name: str, quantity: int (> 0), unit_price: float (> 0)GET /api/orders/{order_id} -- get order details including computed totalGET /api/orders -- list orders, with optional status: str filter and customer_email: str filterPATCH /api/orders/{order_id}/status -- update order status with status: str (allowed transitions: "pending" -> "confirmed" -> "shipped" -> "delivered"; any state -> "cancelled" except "delivered")POST /api/orders/{order_id}/notes -- add a note to an order with text: str, author: strGET /api/orders/{order_id}/notes -- list notes for an orderBusiness rules:
Produce Python files:
app/main.py -- FastAPI app with routesapp/models.py -- Pydantic schemas for requests and responsesapp/store.py -- in-memory data store (no real database)Do not include test files or deployment configuration.