CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/flask-best-practices

Flask patterns -- application factory, blueprints, error handlers, extensions, request lifecycle, configuration, logging, CLI commands

98

1.28x
Quality

98%

Does it follow best practices?

Impact

98%

1.28x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-3/

Recipe Sharing API

Problem/Feature Description

A cooking enthusiast community wants a Flask API for sharing recipes. Users can create recipes with ingredients and steps, browse recipes by category, and rate them.

Data model:

  • Recipe: title, description, prep_time_minutes, cook_time_minutes, servings, category (appetizer/main/dessert/snack)
  • Ingredient: name, quantity, unit (per recipe)
  • Step: step_number, instruction (per recipe)
  • Rating: score (1-5), comment (per recipe)

Endpoints needed:

  • POST /api/recipes -- create a recipe (with nested ingredients and steps in the request body)
  • GET /api/recipes -- list recipes with optional ?category=dessert filter
  • GET /api/recipes/<id> -- get a recipe with its ingredients, steps, and average rating
  • POST /api/recipes/<id>/ratings -- add a rating to a recipe
  • DELETE /api/recipes/<id> -- delete a recipe and its related data

Requirements:

  • Validate that recipes have at least one ingredient and one step.
  • Ratings must be 1-5 integers.
  • Use a proper Flask project structure that a team could maintain.
  • Include a CLI command flask seed-recipes that populates sample data for development.

Output Specification

Produce Python source files in a recipe-api/ directory:

  • app/__init__.py -- application factory with CLI command registration
  • app/extensions.py -- extension instances
  • app/errors.py -- custom exceptions and error handlers
  • app/db.py -- data store
  • app/routes/recipes.py -- recipes blueprint
  • app/routes/ratings.py -- ratings blueprint
  • tests/conftest.py -- test fixtures
  • run.py -- entry point
  • requirements.txt

Do not run pip install or start the server.

evals

tile.json