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

Support Ticket System API

Problem/Feature Description

A SaaS company needs a Flask API for their internal support ticket system. Support agents create tickets on behalf of customers, update ticket status, and add comments.

Data model:

  • Ticket: title, description, status (open/in_progress/resolved/closed), priority (low/medium/high/urgent), customer_email, created_at, updated_at
  • Comment: text, author_name, created_at (per ticket)

Endpoints:

  • POST /api/tickets -- create a ticket (title, description, customer_email, priority required)
  • GET /api/tickets -- list tickets with optional ?status=open&priority=urgent filters
  • GET /api/tickets/<id> -- get ticket with its comments
  • PATCH /api/tickets/<id> -- update status and/or priority
  • POST /api/tickets/<id>/comments -- add a comment to a ticket
  • GET /api/health -- health check endpoint returning {"status": "healthy"}

Requirements:

  • Status transitions must be validated: a "closed" ticket cannot be reopened (PATCH should return an error).
  • Customer email must be a valid email format.
  • All responses (success and error) must follow a consistent JSON structure.
  • Logging: every request should be logged with method, path, status code, and duration.
  • The app must handle both JSON content type requests and return proper errors for non-JSON POST/PATCH requests.
  • Configuration should support different environments (development, testing, production).

Output Specification

Produce Python source files in a ticket-system/ directory:

  • app/__init__.py -- application factory
  • app/extensions.py -- extension instances
  • app/errors.py -- custom exceptions and error handlers
  • app/db.py -- data store
  • app/routes/tickets.py -- tickets blueprint
  • app/routes/comments.py -- comments blueprint
  • app/routes/health.py -- health blueprint
  • config.py -- configuration classes (Development, Testing, Production)
  • tests/conftest.py -- test fixtures
  • run.py -- entry point
  • requirements.txt

Do not run pip install or start the server.

evals

tile.json