Build a small isolated CRUD application
A small application factory is a useful integration exercise: each test receives a fresh app and a fresh store. Creating, reading and deleting records then exercises several HTTP contracts without sharing mutable global data between tests.
Use a Pydantic request model for creation, distinct status codes for creation and deletion, and explicit 404 responses for missing records. Return copies or response data rather than exposing the store object itself. This demonstration store is intentionally in memory; restarting the application loses its contents, which is different from a persistent database contract.
from fastapi import FastAPI
def build_app():
app = FastAPI()
store = {}
@app.get("/count")
async def count():
return {"count": len(store)}
return app
print(build_app().openapi()["paths"].keys())Your task
Implement build_app(): POST /notes with nonempty text creates {id,text}, IDs start at 1, HTTP 201. GET /notes/{id} reads it. DELETE returns 204 with no body. Missing records return 404. Every app has its own store.
The explanation opens here once every check passes.