Auto-generated tile from GitHub (10 skills)
92
94%
Does it follow best practices?
Impact
92%
1.16xAverage score across 44 eval scenarios
Advisory
Suggest reviewing before use
A logistics startup is building an order management microservice on Fastify with PostgreSQL as the database. The team is starting from scratch and wants to set up the database layer correctly from day one, following patterns they can scale as the service grows.
The engineering lead has set three ground rules. First, the database client must integrate cleanly with Fastify's plugin and lifecycle system — when the server shuts down the database connection must also be released properly, and the database accessor must be available to all route plugins without passing it around manually. Second, route handlers must not contain raw database queries. Instead, data access must be encapsulated in repository objects that can be tested independently. Third, the database connection must be configured for production load: connection pool size and timeout values must be explicitly set rather than left at library defaults.
The service manages orders and order line items. An order has an id, a customer_id, a status (one of: pending, confirmed, shipped, delivered, cancelled), and a created_at timestamp. A line item has an id, an order_id, a product_id, a quantity, and a unit_price.
You do not need a running PostgreSQL instance. Implement the code correctly for when one would be present — the focus is on the architecture and integration patterns, not on producing queryable results.
Produce the following files:
package.json — type: "module", dependencies, and a start scriptsrc/app.ts — Fastify application factory. Export buildApp()src/plugins/database.ts — database plugin that integrates PostgreSQL with the Fastify lifecycle, exposes the connection to the rest of the application, and properly handles shutdownsrc/repositories/orders.ts — a repository module that implements at minimum: findById(id), findByCustomer(customerId), create(data), and updateStatus(id, status) operationssrc/repositories/line-items.ts — a repository module with at minimum findByOrder(orderId) and create(data) operationssrc/plugins/repositories.ts — a Fastify plugin that creates the repository instances and makes them accessible to route handlerssrc/routes/orders.ts — a route plugin with at minimum GET /orders/:id, GET /orders?customerId=..., POST /orders, and PUT /orders/:id/status. Handlers must use the repository layer — no direct database queries in route filessrc/server.ts — the entry point that starts the serverschema.sql — a SQL file with CREATE TABLE statements for the orders and line_items tablesevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
scenario-11
scenario-12
scenario-13
scenario-14
scenario-15
scenario-16
scenario-17
scenario-18
scenario-19
scenario-20
scenario-21
scenario-22
scenario-23
scenario-24
scenario-25
scenario-26
scenario-27
scenario-28
scenario-29
scenario-30
scenario-31
scenario-32
scenario-33
scenario-34
scenario-35
scenario-36
scenario-37
scenario-38
scenario-39
scenario-40
scenario-41
scenario-42
scenario-43
scenario-44
skills
documentation
fastify
init
linting-neostandard-eslint9
node
nodejs-core
rules
oauth
octocat
snipgrapher