Templates

35 curated code starters. Search, filter, copy, and build.

35 results

REST API with Express.js

javascriptAPI

A minimal Express.js REST API with CRUD endpoints for managing todo items, including JSON body parsing and error handling middleware.

expressrestcrud

React Custom Hook (useLocalStorage)

typescriptFrontend

A type-safe React hook that persists state to localStorage with automatic serialization and deserialization.

reacthookslocalstorage

Python Binary Search

pythonAlgorithms

Iterative and recursive binary search implementations that work on any sorted sequence, returning the index or -1.

binary-searchalgorithmssearching

Python Flask REST API

pythonAPI

A lightweight Flask REST API with in-memory storage, request validation, and JSON error responses.

flaskrestpython

TypeScript Generic Stack

typescriptAlgorithms

A fully typed generic Stack implementation with push, pop, peek, size, and iterator support.

genericsdata-structurestack

Go HTTP Server

goBackend

A production-style Go HTTP server with structured JSON logging, graceful shutdown, and health-check endpoint.

gohttpserver

Rust CLI Argument Parser

rustUtilities

A zero-dependency CLI argument parser that supports flags, options with values, and positional arguments.

rustcliargs

SQL CRUD Queries

sqlDatabase

Complete CREATE, READ, UPDATE, DELETE queries for a users table with indexing, filtering, and pagination.

sqlcrudpostgresql

Docker Compose (Node + PostgreSQL)

yamlDevOps

A two-service Docker Compose file that runs a Node.js API alongside a PostgreSQL database with health checks and volume mounts.

dockercomposenode

GitHub Actions CI/CD Pipeline

yamlDevOps

A CI/CD workflow that runs tests on push/PR and deploys to a staging environment on the main branch.

github-actionscicd

Python Decorator Pattern

pythonUtilities

Reusable decorators for timing, retrying with exponential backoff, and singleton enforcement.

pythondecoratorspatterns

JavaScript Debounce & Throttle

javascriptFrontend

Production-ready debounce and throttle utilities with leading/trailing edge options and cancel support.

debouncethrottleperformance

React Context + Reducer Pattern

typescriptFrontend

A type-safe React context combined with useReducer for global state management, complete with actions and a custom hook.

reactcontextreducer

TypeScript Event Emitter

typescriptBackend

A fully typed, generic Event Emitter class supporting on, off, once, and emit with wildcard listeners.

eventspubsubpatterns

Python Async Web Scraper

pythonUtilities

A concurrent web scraper using aiohttp and asyncio that fetches multiple pages with rate limiting and error handling.

asyncaiohttpscraper

JWT Auth Middleware (Node.js)

javascriptAuth

Express middleware for issuing and verifying JSON Web Tokens with configurable secret, expiry, and role-based authorization.

jwtauthmiddleware

React Testing Library Component Test

typescriptTesting

A comprehensive test suite for a Counter component using React Testing Library and Vitest/Jest, covering user interactions and edge cases.

testingreact-testing-libraryjest

Python Sorting Algorithms Comparison

pythonAlgorithms

Implementations of bubble sort, merge sort, and quicksort with timing benchmarks and correctness verification.

sortingalgorithmsbenchmark

Bash Script: Project Setup

bashDevOps

A portable Bash script that scaffolds a new Node.js/TypeScript project with Git, ESLint, Prettier, and GitHub repo creation.

bashscaffoldingproject-setup

Next.js API Route with Zod Validation

typescriptAPI

A Next.js App Router API route that validates request bodies and query params using Zod schemas with proper error responses.

nextjszodvalidation

Python Data Class with Validation

pythonBackend

A validated data class using __post_init__ for field constraints, a from_dict factory method, and serialization.

dataclassvalidationpython

JavaScript Promise.all with Error Handling

javascriptUtilities

Robust patterns for concurrent promise execution including settleAll, retryPromise, and batched execution.

promisesasyncerror-handling

TypeScript Middleware Chain Pattern

typescriptBackend

A composable middleware chain similar to Koa/Express that processes requests through a pipeline of async handlers.

middlewarepatternschain

SQL Window Functions

sqlDatabase

Advanced SQL queries demonstrating ROW_NUMBER, RANK, LAG/LEAD, running totals, and moving averages over an orders table.

sqlwindow-functionsanalytics

Rust File Reader

rustUtilities

A Rust utility that reads a text file line-by-line with buffered I/O, counts words and lines, and reports file metadata.

rustfile-iobuffered

Go REST API with Chi

goAPI

A clean REST API built with the Chi router featuring CRUD endpoints, JSON middleware, and a custom 404 handler.

gochirest

Python SQLAlchemy ORM Model

pythonDatabase

SQLAlchemy 2.0 ORM models with relationships, a typed repository pattern, and query examples including joins and pagination.

sqlalchemyormpython

JavaScript Deep Clone Utility

javascriptUtilities

A deep clone utility that handles Date, RegExp, Map, Set, Array, plain objects, and circular references without structuredClone.

deep-cloneutilityimmutable

TypeScript Builder Pattern

typescriptBackend

A type-safe, fluent Builder pattern for constructing complex objects step-by-step with compile-time validation of required fields.

builderpatternsfluent-api

CSS Grid Layout System

typescriptFrontend

A responsive CSS Grid layout system with utility classes, named grid areas, auto-fit responsive columns, and dark mode support.

cssgridlayout

Python FastAPI Endpoint

pythonAPI

A complete FastAPI application with Pydantic models, path/query/body parameter validation, and automatic OpenAPI docs.

fastapipydanticpython

JavaScript Array Utility Functions

javascriptUtilities

A library of reusable higher-order array utilities including chunk, flatten, unique, groupBy, sortBy, and zip.

arraysfunctionalutilities

Python LRU Cache Implementation

pythonAlgorithms

A from-scratch LRU cache using an OrderedDict with O(1) get/put operations, eviction policy, and a decorator interface.

lrucachedata-structure

YAML Kubernetes Deployment

yamlDevOps

A production-ready Kubernetes Deployment and Service manifest for a Node.js app with health checks, resource limits, and HPA.

kubernetesk8sdeployment

TypeScript Result Error Handling

typescriptUtilities

A Result monad type for functional error handling without try/catch, supporting map, flatMap, unwrap, and match.

resultmonaderror-handling