StackPractices

Patterns

Software design and architecture patterns explained with real, runnable examples.

203 results

advanced

Agent Tool Selection Pattern

Dynamically select which tools an LLM agent can use based on the task context. Reduce token usage...

pattern ai-pattern function-calling
intermediate

Embedding Cache Pattern

Cache LLM embeddings to reduce API calls and cost. Store embeddings with a content hash key and...

intermediate

Human-in-the-Loop Pattern

Pause LLM agent execution for human approval before high-impact actions. Route decisions to a...

intermediate

LLM Fallback Pattern

Fall back to alternative LLM providers or models when the primary fails. Handle rate limits,...

intermediate

LLM Guardrails Pattern

Validate LLM inputs and outputs with rules, classifiers, and content filters. Prevent prompt...

intermediate

LLM Router Pattern

Route queries to different LLM models based on complexity, cost, and latency requirements. Classify...

intermediate

Prompt Chaining Pattern

Chain multiple LLM calls where each step's output feeds the next step's input. Break complex tasks...

intermediate

RAG Hybrid Search Pattern

Combine keyword (BM25) and semantic (vector) search to improve retrieval accuracy in RAG pipelines....

intermediate

Ambassador: Offload Cross-Cutting Concerns to a Proxy

How to offload cross-cutting concerns to a proxy ambassador. Covers connection pooling, retry...

advanced

Anti-Corruption Layer: Isolate Legacy with Adapters

How to isolate legacy systems with translation adapters. Covers ACL facade, domain translation,...

intermediate

Backends for Frontends: Dedicated Backend per Client Type

How to create dedicated backends per client type. Covers BFF for web, mobile, and desktop. Covers...

intermediate

Compute Resource Consolidation Pattern

Combine workloads into fewer compute resources to reduce cost, improve utilization, and simplify...

intermediate

External Configuration Store Pattern

Centralize application configuration outside of deployment artifacts to support live updates and...

intermediate

Gateway Routing Pattern

Route requests to multiple backend services through a single entry point that handles cross-cutting...

beginner

Health Endpoint Monitoring Pattern

Expose lightweight health endpoints so orchestrators, load balancers, and monitoring tools can...

intermediate

Leader Election Pattern

Coordinate a single active instance among multiple distributed nodes to avoid conflicts and...

intermediate

Modular Monolith: Single Deployable with Module Boundaries

How to build a modular monolith with strict internal module boundaries. Covers module isolation,...

advanced

Multi-Tenant Data Isolation Pattern

Isolate tenant data in shared infrastructure using row-level security, schema-per-tenant, or...

intermediate

Pipes and Filters Pattern: Composable Data Pipelines

Chain processing steps with independent filters connected by pipes. A pattern for data...

intermediate

Sidecar Pattern: Extend Services with Companion Containers

How to extend services with companion containers for cross-cutting concerns. Covers sidecar...

No results found.