Every backend service MUST use structured logging — pino/structlog/slog, JSON format, request IDs, proper log levels. console.log is never acceptable.
88
85%
Does it follow best practices?
Impact
97%
3.03xAverage score across 4 eval scenarios
Passed
No known issues
A mobile app company needs a Python FastAPI service to manage user notification preferences. Users can configure which types of notifications they want (push, email, SMS) and set quiet hours. The service runs behind an API gateway in AWS.
The service needs these endpoints:
POST /api/users/{user_id}/preferences — Create or replace notification preferences. Accepts: push_enabled (bool), email_enabled (bool), sms_enabled (bool), quiet_hours_start (optional, HH:MM format), quiet_hours_end (optional, HH:MM format). If quiet hours are provided, both start and end must be present.GET /api/users/{user_id}/preferences — Retrieve a user's notification preferences. Returns 404 if no preferences set.PATCH /api/users/{user_id}/preferences — Partially update preferences. Only provided fields are updated.POST /api/users/{user_id}/check — Check if a notification should be sent right now. Accepts: notification_type ("push", "email", "sms") and current_time (ISO format). Returns {"should_send": true/false} based on whether that channel is enabled and current time is outside quiet hours.Use an in-memory dict for storage. The service should be production-grade in terms of code quality.
Produce:
output/requirements.txt with dependenciesoutput/main.py — FastAPI application with middleware and startupoutput/routes/preferences.py — Route handlersoutput/models.py — Pydantic modelsComplete Python code, no placeholders or TODO comments.