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-1/

Bookstore Inventory Service

Problem/Feature Description

A local bookstore wants a Flask API to manage their inventory. They currently track everything in spreadsheets and want to move to a simple web service. The API should manage books (title, author, isbn, price, quantity_in_stock) and categories (name, description). A book belongs to one category.

Requirements:

  1. CRUD endpoints for books and categories.
  2. A GET /api/books?category=fiction&in_stock=true endpoint with optional filtering.
  3. A POST /api/books/<id>/restock endpoint that increases a book's quantity.
  4. Rate limiting on write endpoints (create, update, restock) to prevent accidental duplicate submissions.
  5. Proper validation -- ISBN must be provided, price must be positive, quantity can't be negative.
  6. Use SQLite for persistence with a simple schema.

The bookstore owner is not technical, so error messages should be clear and the API should never show Python tracebacks.

Output Specification

Produce Python source files in a bookstore/ directory:

  • app/__init__.py -- application factory
  • app/extensions.py -- CORS, rate limiter instances
  • app/errors.py -- custom exceptions and error handlers
  • app/db.py -- SQLite setup, init_db(), get_db()
  • app/routes/books.py -- books blueprint
  • app/routes/categories.py -- categories blueprint
  • tests/conftest.py -- test fixtures with in-memory SQLite
  • run.py -- entry point
  • requirements.txt

Do not run pip install or start the server.

evals

scenario-1

criteria.json

task.md

tile.json