CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/sqlite-node-best-practices

SQLite best practices for Node.js with better-sqlite3 — WAL mode, pragmas, foreign keys, STRICT tables, transactions, migrations, graceful shutdown, and query patterns

97

1.65x
Quality

98%

Does it follow best practices?

Impact

96%

1.65x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-4/

Inventory Tracker Service

Problem/Feature Description

A small warehouse needs an inventory tracking service built with Node.js, TypeScript, and Express. Use SQLite for the database (runs on a single machine at the warehouse).

The system needs:

  • Products: name, SKU (unique), category, unit cost and sell price, current stock quantity, reorder threshold.
  • Stock movements: record every stock change (received shipment, sold, returned, adjusted). Each movement has a product reference, quantity change (positive for inbound, negative for outbound), movement type, a note, and timestamp.
  • Receive shipment: accept a list of items (product SKU + quantity) from a supplier delivery. Update stock quantities for all items. This must be atomic — if any SKU is invalid, none of the stock updates should apply.
  • Record a sale: decrease stock for a list of items sold. Must check that sufficient stock exists for each item before committing. If any item has insufficient stock, reject the entire sale.
  • Stock report: current stock levels for all products, with a flag for items below reorder threshold.
  • Movement history: list all stock movements for a product within a date range.

Output Specification

Produce:

  • src/db.ts — Database connection and schema
  • src/inventory.ts — Core inventory functions (receive shipment, record sale, reports)
  • src/index.ts — Express routes
  • package.json — With dependencies

Complete TypeScript, no placeholders.

evals

tile.json