Patterns
Design patterns and architectural blueprints for solving common engineering challenges. Reusable solutions that stand the test of time.
Abstract Factory
Provides an interface for creating families of related or dependent objects without specifying their concrete classes. Used when a system needs to be independent of how its objects are created.
Adapter
Allows objects with incompatible interfaces to collaborate. Acts as a wrapper between two interfaces, converting the interface of a class into another interface clients expect.
Ambassador
Creates a helper service that handles cross-cutting concerns like retries, circuit breaking, and authentication on behalf of a client service.
B-Tree
A self-balancing tree data structure that maintains sorted data and enables efficient insertion, deletion, and search operations. The standard index structure in relational databases.
Bloom Filter
A space-efficient probabilistic data structure for testing whether an element is a member of a set. Can return false positives but never false negatives. Used in caching and spell checkers.
Bridge
Decouples an abstraction from its implementation so that the two can vary independently. Used when both the abstraction and implementation may have multiple variations.
Builder
Separates the construction of a complex object from its representation, allowing the same construction process to create different representations. Ideal for objects with many optional parameters.
Chain of Responsibility
Passes a request along a chain of handlers. Each handler decides either to process the request or pass it to the next handler in the chain.
Circuit Breaker
Prevents an application from repeatedly trying to execute an operation that is likely to fail. Opens the circuit to fail fast and allows recovery time for the downstream service.
Command
Encapsulates a request as an object, allowing parameterization of clients with queues, requests, and operations. Supports undoable operations and logging.
Composite
Composes objects into tree structures to represent part-whole hierarchies. Lets clients treat individual objects and compositions uniformly.
Consistent Hashing
A distributed hashing scheme that minimizes key redistribution when the number of nodes changes. Used by DynamoDB, Cassandra, and CDNs for data partitioning.
CQRS
Separates read and write operations into different models. Commands handle writes, queries handle reads — often with different data stores optimized for each purpose.
Decorator
Attaches additional responsibilities to an object dynamically. Provides a flexible alternative to subclassing for extending functionality.
Event Sourcing
Stores the state of a system as a sequence of events rather than the current state. Enables full auditability, time travel, and complex event processing.
Facade
Provides a unified interface to a set of interfaces in a subsystem. Defines a higher-level interface that makes the subsystem easier to use.
Factory Method
Defines an interface for creating an object, but lets subclasses decide which class to instantiate. Promotes loose coupling by deferring object creation to subclasses.
Fanout
Distributes incoming messages or tasks to multiple workers or queues for parallel processing. Widely used in data pipelines and event-driven architectures.
Flyweight
Uses sharing to support large numbers of fine-grained objects efficiently. Reduces memory usage by sharing common parts of state between multiple objects.
Gossip Protocol
A peer-to-peer communication protocol where nodes periodically exchange state information with random peers. Used for failure detection in distributed systems like Cassandra and Consul.
Hash Index
An index structure that uses a hash function to map keys to bucket locations. Provides O(1) lookup for equality queries but does not support range queries.
Interpreter
Given a language, defines a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.
Iterator
Provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation. Supports multiple traversals.
Leader-Follower
A thread coordination pattern where one thread (leader) waits for events while others (followers) process them. The leader promotes a follower upon receiving an event.
LRU Cache
Evicts the least recently used items when the cache reaches capacity. Combines a hash map for O(1) lookups with a doubly-linked list for efficient eviction tracking.
LSM Tree
A data structure optimized for write-heavy workloads. Maintains data in a series of immutable sorted files merged in the background. Used by LevelDB, RocksDB, and Cassandra.
MapReduce
A programming model for processing large datasets in parallel across distributed clusters. Consists of a Map step (filter/sort) and a Reduce step (summarize/aggregate).
Mediator
Defines an object that encapsulates how a set of objects interact. Promotes loose coupling by preventing objects from referring to each other explicitly.
Memento
Captures and externalizes an object's internal state so that the object can be restored to this state later. Supports undo and rollback operations.
Multi-Leader Replication
A database replication strategy where multiple nodes accept writes and replicate changes to each other. Useful for multi-datacenter deployments and offline-first applications.
MVC
Separates an application into three interconnected components: Model (data), View (UI), and Controller (business logic). The dominant pattern for web frameworks.
MVCC
Multi-Version Concurrency Control allows concurrent access to a database by keeping multiple versions of each data item. Readers see a consistent snapshot without blocking writers.
MVVM
Extends MVC by separating the View from its backing data using a ViewModel that exposes data and commands. Popular in modern UI frameworks like Angular, Vue, and WPF.
Observer
Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
Paxos
A consensus algorithm that enables a distributed system to agree on a single value despite failures. Foundational to distributed consensus and leader election.
Prototype
Creates new objects by copying an existing object, known as the prototype. Useful when object creation is expensive and you want to avoid subclasses.
Proxy
Provides a surrogate or placeholder for another object to control access to it. Useful for lazy loading, access control, logging, and caching.
Publish-Subscribe
A messaging pattern where senders (publishers) send messages without knowing the receivers (subscribers). Decouples components through a message broker.
Raft
A consensus algorithm designed to be more understandable than Paxos. Uses leader election and log replication to achieve consensus in distributed systems. Powers etcd and Consul.
Replication
The process of maintaining copies of data across multiple nodes. Provides fault tolerance, high availability, and improved read performance in distributed systems.
Repository
Mediates between the domain and data mapping layers, acting like an in-memory domain object collection. Centralizes data access logic and improves testability.
Retry Pattern
Enables an application to retry a failed operation in anticipation of transient failures. Often combined with exponential backoff and jitter to avoid overwhelming the downstream service.
Saga
Manages distributed transactions by breaking them into a sequence of local transactions with compensating actions for rollback. Essential for microservices.
Sharding
Partitions a large database into smaller, faster, more manageable parts called shards. Each shard holds a subset of data and can be managed independently.
Sidecar
Deploys auxiliary components (logging, monitoring, networking) as a separate container alongside the main application container. Common in service mesh architectures.
Singleton
Ensures a class has only one instance and provides a global point of access to it. Commonly used for logging, driver objects, caching, and thread pools.
State
Allows an object to alter its behavior when its internal state changes. The object will appear to change its class at runtime.
Strangler Fig
Incrementally replaces a legacy system by building a new system alongside it and gradually routing functionality from the old to the new, eventually decommissioning the old.
Strategy
Defines a family of algorithms, encapsulates each one, and makes them interchangeable. Lets the algorithm vary independently from clients that use it.
Template Method
Defines the skeleton of an algorithm in a method, deferring some steps to subclasses. Lets subclasses redefine certain steps without changing the algorithm's structure.
Two-Phase Commit
A distributed transaction protocol that ensures all participating nodes either commit or abort a transaction. Provides atomicity across multiple databases or services.
Visitor
Represents an operation to be performed on elements of an object structure. Lets you define a new operation without changing the classes of the elements.

