CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/springboot-error-handling

Error handling for Spring Boot APIs — @ControllerAdvice, structured error

84

1.76x
Quality

75%

Does it follow best practices?

Impact

99%

1.76x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-5/

Build a Restaurant Ordering API

Problem/Feature Description

A restaurant chain needs a backend API for their online ordering system. Build it using Spring Boot and Java.

Resources:

  • MenuItem: { id, name, description, price, category, available }
  • Order: { id, customerName, customerPhone, items: [{menuItemId, quantity, specialInstructions}], status, total, createdAt }

Endpoints:

  • GET /api/menu -- list all menu items, support filtering by category query parameter
  • GET /api/menu/{id} -- get a single menu item
  • POST /api/menu -- add a menu item (name required, price > 0, category must be one of: appetizer, main, dessert, drink)
  • PUT /api/menu/{id} -- update a menu item
  • DELETE /api/menu/{id} -- remove a menu item (only if not referenced by pending orders)
  • POST /api/orders -- place an order:
    • customerName and customerPhone are required
    • items array must be non-empty
    • each item must reference an existing, available menu item
    • quantity must be between 1 and 10
    • calculate and store the order total
  • GET /api/orders/{id} -- get order details
  • PATCH /api/orders/{id}/status -- update order status (valid transitions: pending -> preparing -> ready -> completed, or pending -> cancelled)

Business rules:

  • Menu item names must be unique within a category
  • An order cannot be modified once its status is "preparing" or beyond
  • Phone number must match a simple pattern (at least 10 digits)

Seed the menu with 5-8 sample items. Use in-memory storage or H2.

Output Specification

Produce a complete Spring Boot project:

  • src/main/java/com/example/ -- controller, service, model, and repository packages
  • pom.xml or build.gradle -- with dependencies
  • src/main/resources/application.properties -- configuration

You may create additional files as needed for a well-structured codebase.

evals

tile.json