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 product inventory management API with FastAPI and Python. The API tracks products and stock adjustments.
POST /api/products -- create a product with name: str, sku: str, price: float (> 0), quantity: int (>= 0)GET /api/products -- list all products, with optional query params min_price: float, max_price: float, in_stock: boolGET /api/products/{product_id} -- get product by IDPUT /api/products/{product_id} -- update product detailsPOST /api/products/{product_id}/adjust-stock -- adjust stock with adjustment: int (positive to add, negative to remove), reason: strGET /api/products/{product_id}/stock-history -- get stock adjustment history for a productBusiness rules:
Produce Python files:
app/main.py -- FastAPI app with routesapp/models.py -- Pydantic modelsapp/storage.py -- in-memory storage (no real database)Do not include test files or deployment configuration.