Library Management REST API
Base URL:
https://api.example.com/v1
All request and response bodies use application/json. Dates use ISO 8601 in UTC. Resource IDs are UUIDs.
Endpoint Table
Books
Method Path Purpose Status Codes GET /books List and filter books 200, 400 POST /books Create a book record 201, 400, 409, 422 GET /books/{bookId} Retrieve a book 200, 404 PATCH /books/{bookId} Update book metadata or inventory 200, 400, 404, 409, 422 …
add(a, b)
Adds two values using JavaScript’s + operator.
Parameters
Name Type Constraints a any None. If either operand is a string, string concatenation may occur. b any None. If either operand is a string, string concatenation may occur. Returns
any — The result of evaluating a + b.
Errors
This function does not explicitly throw errors. JavaScript may throw a TypeError for incompatible operand types, such as mixing a bigint with a number.
Example
const result = add(2, 3);…
The Cost of Doing Nothing
Assumptions
Replace these inputs with internal figures as needed:
20 engineers run or wait for CI an average of 2 times per day
220 working days per year
Fully loaded engineering cost: $150/hour
Current suite duration: 45 minutes
Estimated productive time lost per run: 15 minutes due to parallel work, context switching, and delayed feedback
5 flaky-test reruns or investigations per day, averaging 20 minutes each
2 production incidents last quarter traced to untested paths
Average incident cost:…
Identity + Scope
You are the customer support assistant for a SaaS invoicing platform. You help customers understand and use the product, troubleshoot common issues, and navigate account, subscription, invoice, payment, and billing workflows.
Your scope includes:
Account access and settings
Creating, sending, editing, and tracking invoices
Payment status and payment-method questions
Subscription plans, renewals, cancellations, and billing-cycle explanations
Product troubleshooting using approved documentation
Collecting information for support escalation…
Caching Strategy
1. Data Classes
Data class Cache layer TTL and reasoning Invalidation trigger Staleness tolerance Product content: name, description, images, category, attributes CDN + distributed cache + app-local cache CDN: 15–60 min; distributed: 30 min; app-local: 1–5 min. This data changes infrequently and benefits most from edge caching. Product update event; purge affected product, category, search, and listing keys. 15–60 min for presentation data; near-zero for legal or compliance fields. …
Estimation scale
S: 0.5–1.5 engineering days
M: 2–3 engineering days
L: 4–5 engineering days
Assumes one engineer, code review included, existing CI/CD and authentication, and no major infrastructure procurement. QA/UAT time is included per slice but cross-system rollout support is not.
Delivery slices
1. Notification event contract and channel-agnostic model — M
Scope
Define notification types, recipients, payload schema, priority, channel eligibility, timestamps, and idempotency key.
Add producer-facing API or internal library.…
function addNumbers(firstNumber: number, secondNumber: number): number {
return firstNumber + secondNumber;
}
Added number parameter types to fix the implicit any parameters.
Restricted both operands to numbers, removing ambiguity between numeric addition and string concatenation.
Added an explicit number return type to document and enforce the function’s contract.
Renamed add, a, and b to addNumbers, firstNumber, and secondNumber for clearer intent.
Test Plan: Checkout Flow with Promo Codes and Three Payment Methods
Assumptions
The checkout flow supports:
Cart review
Shipping and billing information
Promo-code application/removal
Three payment methods:
Credit/debit card
Digital wallet
Bank transfer
Order confirmation and receipt
Tax, shipping, and discount calculation
Risk Assessment
| Risk | Impact | Likelihood | Priority | Primary Mitigation |
|---|---:|---:|---:|---|…
Title
Android app crashes when uploading a large photo
Environment
Platform: Android
App version: Unknown
Android version: Unknown
Device model: Unknown
Network conditions: Unknown
Assumption: The crash occurs when selecting or uploading a high-resolution or large-file-size photo.
Steps to Reproduce
Open the Android app.
Navigate to the photo upload feature.
Select a large or high-resolution photo.
Start the upload.
Observe that the app crashes.
Expected…
[Unreleased]
Added
Dark mode is now available for a more comfortable viewing experience in low-light environments.
Changed
⚠ BREAKING: Node.js 16 is no longer supported. Migrate to Node.js 18 or later before upgrading.
Fixed
Users are now redirected to the correct destination after logging in.
Removed
⚠ BREAKING: Support for Node.js 16 has been removed. Upgrade your environment to Node.js 18 or later.
Context
The API previously supported JWT authentication only. We now need to support API key–based integrations while protecting authentication endpoints and downstream services from excessive traffic and abuse.
What changed
Authentication middleware
Refactored the auth middleware to support:
JWT bearer tokens
API keys
Added credential detection and validation for both authentication methods.
Preserved existing JWT behavior and error handling.
Standardized the authenticated request context across JWT and API key flows.
Rate limiting…
Payment Webhook Processing Service — On-Call Runbook
0. 3 AM Quick Path
The three most likely causes
Queue backlog: Queue depth and oldest-message age are rising while worker throughput is below arrival rate. Check worker health, errors, and downstream saturation; scale only if dependencies can absorb it.
Provider timeout: Requests to or from one provider are timing out. Check provider status and timeout metrics; keep events durable and reduce retry pressure.…
Monorepo Makefile: Go API, React frontend, and Postgres via Docker Compose.
SHELL := /bin/bash
.DEFAULT_GOAL := help
API_DIR := api
WEB_DIR := frontend
DIST_DIR := dist
COMPOSE := docker compose
GO := go
NPM := npm
Use npm ci when a lockfile exists; fall back to npm install for first-time setup.
NPM_INSTALL := $(if $(wildcard $(WEB_DIR)/package-lock.json),$(NPM) ci,$(NPM) install)
.PHONY: help setup dev test lint build clean db-up db-migrate
help: ## Show available targets
@awk 'BEGIN {FS = ":.*## "; printf "Usage: make \033[36m<target>\033[0m\n\nTargets:\n"} \…
Bugs
Line 1: Parameters a and b have implicit any types when noImplicitAny is enabled.
Line 1: The return type is unspecified. Because + behaves differently for numbers and strings, the function’s intended behavior is ambiguous.
Security
No direct security vulnerabilities are present.
Explicit numeric types prevent unintended string concatenation or coercion when this function is used with loosely typed input.
Performance
The implementation is already optimal for numeric addition.
No additional allocations or unnecessary operations are performed.…
-- PostgreSQL schema.
-- Stores users, venues, reservable time slots, bookings, payments, and cancellations.
-- All timestamps are timezone-aware, and monetary values use fixed-precision NUMERIC.
CREATE TABLE users (
user_id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
email VARCHAR(320) NOT NULL,
full_name VARCHAR(200) NOT NULL,
phone VARCHAR(32),
status VARCHAR(20) NOT NULL DEFAULT 'active'
CHECK (status IN ('active', 'suspended')),
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,…
Performance review
Hot path complexity
Time: O(1) per call.
Space: O(1).
There are no loops, recursive calls, or input-dependent operations.
Allocation / GC pressure
For numeric inputs, the function typically creates no heap allocations, so GC pressure is negligible.
If either operand is a string, + performs concatenation and allocates a new string of size O(len(a) + len(b)).
Untyped parameters allow mixed operand types, which may introduce coercion and reduce JIT optimization stability at polymorphic call sites.
I/O / N+1 patterns…
# syntax=docker/dockerfile:1.7
FROM node:22-bookworm-slim AS base
ENV PNPM_HOME=/pnpm
ENV PATH=$PNPM_HOME:$PATH
RUN corepack enable
FROM base AS dependencies
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
pnpm install --frozen-lockfile
FROM dependencies AS build
COPY . .
RUN pnpm run build \
pnpm prune --prod
FROM node:22-bookworm-slim AS production
ENV NODE_ENV=production
WORKDIR /app
RUN apt-get update \
apt-get install -y --no-install-recommends ffmpeg curl \
rm -rf /var/lib/apt/lists/* \…
Actual cause
Your code calls .map() on a value that is undefined. Since .map() is an array method, the value was likely expected to be an array but was missing, not initialized yet, or accessed through the wrong property.
For example:
const items = undefined;
items.map(item = item.name); // TypeError
Most likely fixes
Initialize the value as an empty array
This is most likely when data is loaded asynchronously or stored in state.
const [items, setItems] = useState([]);
Or provide a fallback:
Kata: Global Meeting Scheduler
Problem Statement
Your company has teams in New York, London, Tokyo, and several other cities. Meeting requests arrive as local date-and-time strings together with their IANA time zones. Your task is to convert each request into a canonical UTC timestamp.
Unfortunately, local times are not always valid or unique:
During the spring daylight-saving transition, some local times do not exist.
During the autumn transition, some local times occur twice.
Time zones may use offsets that are not whole hours.…
How AI workflows work: one form in, a finished video out
A workflow is a ready-made recipe of AI steps. You pick a template, fill in a short form, and every step runs on its own until a finished video comes out. Here we follow one bedtime story video from the form to the result.
What happens when you press Run? The anatomy of an AI workflow
Let's open one workflow and look inside. A workflow is a graph: each box is a step, the arrows set the order, and steps that don't depend on each other run side by side. Your answers flow into the steps, some steps check their own work and run again, some wait for your approval, and every AI call is recorded with its own cost.