CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/python-project-structure

Python project structure — pyproject.toml, src layout, __init__.py, .gitignore, dependency groups, type hints, py.typed, test structure, entry points, ruff/mypy configuration

91

1.03x
Quality

87%

Does it follow best practices?

Impact

99%

1.03x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-5/

Restructure a Single-File Flask App into a Proper Project

Problem/Feature Description

A small e-commerce company has a Flask application that started as a quick prototype and grew to over 800 lines in a single app.py file. The file contains everything: route handlers for products, orders, and users, database queries using raw SQL, hardcoded configuration values, and inline error handling. There are no tests.

The team needs help restructuring this into a maintainable project with proper packaging, separated concerns, configuration management, and a test foundation. They also want to add linting and type checking to their CI pipeline.

The application currently handles:

  • Product CRUD (list, get, create, update)
  • Order management (create order, get order, list orders by user)
  • User registration and profile viewing
  • SQLite database with raw queries
  • Hardcoded DATABASE_URL, SECRET_KEY, and DEBUG flag

Output Specification

Produce a restructured project with:

  • pyproject.toml -- with Flask and dependencies, dev/test optional dependency groups, ruff and mypy configuration, requires-python, build-system
  • .gitignore -- proper Python ignores (venv, pycache, .env, dist, coverage)
  • Application package with __init__.py in all directories:
    • main.py -- Flask app factory using create_app() pattern
    • config.py -- Settings loaded from environment using pydantic-settings (database_url, secret_key, debug)
    • routes/products.py -- Product endpoints using Flask Blueprint
    • routes/orders.py -- Order endpoints using Flask Blueprint
    • routes/users.py -- User endpoints using Flask Blueprint
    • db.py -- Database connection and query helpers
    • models.py -- Data models/schemas for Products, Orders, Users
    • errors.py -- Custom exceptions and error handler registration
  • tests/ with __init__.py, conftest.py (with app fixture and test client), and at least one test file

All functions must have type annotations. Do not use setup.py.

evals

tile.json