CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/separation-of-concerns

Enforce strict three-layer architecture: thin HTTP routes, pure service logic with domain errors, isolated data access with dependency injection.

94

1.08x
Quality

93%

Does it follow best practices?

Impact

97%

1.08x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-4/

Library Catalog API

Problem/Feature Description

A public library is modernizing its catalog system. They need a backend API to manage books — allowing staff to look up books by ISBN, add new titles, and mark books as checked out or returned. The current codebase is a single Express.js file with everything mixed together, making it impossible to add unit tests before an upcoming refactor.

A senior engineer has been asked to restructure the catalog management feature as a properly layered system, so that the business logic can be tested independently and the data access can be swapped out (e.g., moving from SQLite to PostgreSQL later) without touching the business rules.

Implement the catalog management feature with at minimum:

  • Look up a book by ISBN
  • Add a new book to the catalog
  • Check out a book (business rule: a book can only be checked out if it is currently available)
  • Return a book

Output Specification

Produce TypeScript source files implementing the catalog feature:

  • src/routes/catalog.ts — HTTP route handlers
  • src/services/catalogService.ts — Business logic
  • src/repositories/bookRepo.ts — Data access (use an in-memory store to simulate a database)
  • src/types/book.ts — Type/interface definitions for the Book domain object

The in-memory store should be initialized with at least 3 sample books so the implementation can be reasoned about. The implementation does not need to run; focus on structure and correct layering.

Also produce architecture-notes.md describing how the three layers interact and how data flows through them.

evals

tile.json