ワンクリックで
api-conventions
// REST and WebSocket endpoint patterns, error handling, and Pydantic schema conventions for the backend
// REST and WebSocket endpoint patterns, error handling, and Pydantic schema conventions for the backend
| name | api-conventions |
| description | REST and WebSocket endpoint patterns, error handling, and Pydantic schema conventions for the backend |
| license | Apache-2.0 |
All REST endpoints go in backend/app/main.py under the /api prefix.
from .schemas import MyRequest, MyResponse
@app.post("/api/my-endpoint", response_model=MyResponse)
async def my_endpoint(req: MyRequest) -> MyResponse:
# Business logic here
return MyResponse(...)
Rules:
response_model — never return raw dictsschemas.py, not inline/api/from pydantic import BaseModel
class MyResponse(BaseModel):
"""Docstring explains what this response represents."""
field_name: str
optional_field: str | None = None
items: list[str] = []
Rules:
model_dump(), model_dump_json(), model_validate()The WebSocket handler in main.py follows this pattern:
@app.websocket("/ws/my-feature")
async def my_ws(websocket: WebSocket) -> None:
await websocket.accept()
try:
while True:
data = await websocket.receive_text()
payload = json.loads(data)
# Process and send responses
await websocket.send_text(response.model_dump_json())
except WebSocketDisconnect:
pass
Rules:
try/except WebSocketDisconnectmodel_dump_json(), not hand-built strings{"type": "done"} message to signal completion to the frontend{"type": "error"} for recoverable errors instead of closing the connectionHTTPException for business errorsrun_team(), send as {"type": "error"} to the clientCORS is configured in main.py for http://localhost:5173 (Vite dev server). For production, replace with the actual frontend origin.
Architecture, directory layout, communication protocol, and conventions for the full-stack multi-agent application
Step-by-step guide to add a new REST or WebSocket endpoint to the backend
Step-by-step guide to add a new agent to the multi-agent team
Step-by-step guide to add a new page or component to the React frontend
How the Code Reviewer agent conducts systematic code reviews with prioritized findings
How the Research Analyst agent conducts research, evaluates sources, and produces structured reports