Web performance patterns — lazy loading, bundle optimization, query optimization, compression, and resource management
81
77%
Does it follow best practices?
Impact
97%
3.23xAverage score across 3 eval scenarios
Passed
No known issues
Build a REST API that returns order history for a customer. Each order has line items (products ordered with quantities and prices).
The backend is Node.js with Express and a PostgreSQL database.
CREATE TABLE customers (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
email TEXT NOT NULL UNIQUE
);
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
customer_id INTEGER REFERENCES customers(id),
status TEXT NOT NULL DEFAULT 'pending',
created_at TIMESTAMP DEFAULT NOW()
);
CREATE TABLE order_items (
id SERIAL PRIMARY KEY,
order_id INTEGER REFERENCES orders(id),
product_name TEXT NOT NULL,
quantity INTEGER NOT NULL,
unit_price DECIMAL(10,2) NOT NULL
);GET /api/customers/:id/orders — Returns orders for a customer, each order including its line items and the computed total priceGET /api/orders/:id — Returns a single order with its line items and computed totalitems array and a computed total fieldsrc/index.ts — Express server setupsrc/db.ts — Database connection setupsrc/routes/orders.ts — Order route handlerssrc/types.ts — TypeScript type definitionsDo not include test files or build configuration.