Skip to content

Latest commit

 

History

History
130 lines (109 loc) · 19.4 KB

File metadata and controls

130 lines (109 loc) · 19.4 KB

Design Pattern Cross-Reference

Maps every design pattern (23 GoF + 7 architectural) to every system design (17 classic + 11 AI) in this repository.


Creational Patterns

# Design Pattern Category Used In
1 Singleton Creational Amazon, Spotify, Netflix, Rate Limiter, URL Shortener, Distributed Cache, Message Queue, API Gateway, ChatGPT, RAG Search Engine, AI Agent Memory, Multi-Model Gateway, Code Search Engine, Document Assistant, Recommendation Engine, Enterprise Support Bot, Dropbox, AI Observability, Prompt Injection Guard, AI Governance, Airport, Parking Lot, Sudoku, WhatsApp, Uber, Twitter Feed, YouTube, Google Docs
2 Factory Method Creational Netflix (encoding codec factory), Amazon (product type factory), YouTube (transcoding job factory), Uber (ride type factory), Message Queue (message type factory), Document Assistant (chunking strategy factory), Code Search Engine (index factory), Recommendation Engine (model factory), Multi-Model Gateway (provider client factory), WhatsApp (message format factory)
3 Abstract Factory Creational Amazon (product families — books, electronics, clothing across regions), YouTube (video transcoding profile families), Multi-Model Gateway (cross-provider client families — chat, embedding, image), UI Toolkit (cross-platform widgets)
4 Builder Creational Amazon (order builder with items, shipping, payment), Dropbox (file sync state builder), URL Shortener (short URL builder with options), Recommendation Engine (query builder with filters, weights), Document Assistant (pipeline builder), Code Search Engine (index config builder), AI Agent Memory (memory builder), ChatGPT (conversation context builder)
5 Prototype Creational Distributed Cache (cache entry cloning for writes), Sudoku (board state clone for backtracking), Google Docs (document element copy/paste), Netflix (content profile clone), YouTube (video processing pipeline template clone)

Structural Patterns

# Design Pattern Category Used In
6 Adapter Structural API Gateway (backend protocol adaptation — gRPC→REST, SOAP→JSON), Multi-Model Gateway (unified LLM provider interface — OpenAI, Anthropic, Cohere adapters), RAG Search Engine (vector DB adapters — Pinecone, Weaviate, Chroma), WhatsApp (message format adapters — SMS, MMS, WhatsApp protocol), Dropbox (storage adapter — local, S3, GCS), YouTube (transcoding format adapters), Netflix (device adaptation layer)
7 Bridge Structural YouTube (transcoding: platform abstraction × codec implementation), Netflix (streaming: device type × DRM scheme), Recommendation Engine (algorithm × data source — collaborative filtering on ratings, content-based on metadata), Document Assistant (ingestion source × storage backend), Code Search Engine (index type × storage backend)
8 Composite Structural Amazon (product catalog: categories contain subcategories contain products), Google Docs (document: paragraphs contain runs contain characters), Dropbox (file system: folders contain files and subfolders), Airport (airspace: sectors contain zones), Parking Lot (levels contain rows contain spots), AI Agent Memory (hierarchical memory: episodes → segments → facts)
9 Decorator Structural ChatGPT (LLM service decorators — logging, token tracking, caching), API Gateway (request processing pipeline — auth, rate limiter, logger, compressor), Rate Limiter (rate limit decorator + logging decorator), AI Observability (TracerDecorator wrapping LLM calls), Prompt Injection Guard (GuardDecorator wrapping LLM endpoints), AI Governance (ComplianceTrackerDecorator wrapping ML pipeline steps), Multi-Model Gateway (retry, fallback, circuit breaker decorators), Enterprise Support Bot (escalation decorator), Document Assistant (pipeline step decorators — validate, format, log)
10 Facade Structural Amazon (checkout facade — unified interface over cart, payment, shipping, inventory), YouTube (upload facade — ingest, transcode, thumbnail, metadata), Dropbox (sync facade — file watcher, indexer, uploader, conflict resolver), Message Queue (client facade — simplified publish/subscribe), Distributed Cache (cache facade — get/set/evict over cluster nodes), API Gateway (unified entry facade over microservices), Uber (ride booking facade)
11 Flyweight Structural Google Docs (character formatting — shared font/color/style objects), Sudoku (cell state reuse for constraint propagation), WhatsApp (message metadata — shared user profile objects), Twitter Feed (tweet display — reused user avatar, tweet card components), YouTube (video metadata — shared category, tag objects), Spotify (track metadata — shared album, artist objects)
12 Proxy Structural Distributed Cache (cache proxy — intercepts requests for cache-aside), Rate Limiter (rate limit proxy — checks before forwarding), API Gateway (reverse proxy — routing, load balancing, auth), URL Shortener (redirect proxy), ChatGPT (LLMResponseCache proxy — cache identical queries), RAG Search Engine (vector store proxy — connection pooling, retry), Multi-Model Gateway (model proxy — fallback, circuit breaker), Dropbox (file proxy — lazy loading of large files)

Behavioral Patterns

# Design Pattern Category Used In
13 Chain of Responsibility Behavioral ChatGPT (moderation pipeline — toxicity → PII → relevancy), API Gateway (filter chain — auth → rate limit → logging → routing), AI Observability (AlertPipeline — threshold check → severity assess → notify), Prompt Injection Guard (InputGuardChain — heuristic → pattern → ML → LLM judge; OutputGuardChain — PII → content → constraint), AI Governance (RiskClassificationChain — rules-based → ML-based → human review), Document Assistant (document processing pipeline — parse → validate → enrich → store), Rate Limiter (rate limit rule chain), Recommendation Engine (filter chain for candidate generation), Enterprise Support Bot (escalation chain), Multi-Model Gateway (fallback chain)
14 Command Behavioral ChatGPT (async RAG job queue — document ingestion commands), Message Queue (message as command — decouple producer from consumer), Amazon (order processing commands — place, cancel, refund, ship), Dropbox (sync commands — upload, download, delete, rename), AI Governance (audit commands — LogDecision, GenerateReport, FlagViolation), Prompt Injection Guard (AuditLog commands — log, query, export), Code Search Engine (index commands — add, remove, reindex), Document Assistant (pipeline commands — transform, annotate, summarize), Recommendation Engine (training commands — train, evaluate, deploy)
15 Interpreter Behavioral URL Shortener (short code encoding/decoding — base62 interpreter), RAG Search Engine (query language interpreter — filters, operators, nested queries), Code Search Engine (code search query language), Enterprise Support Bot (intent parser for support queries), Rule Engine (business rule evaluation), Search Engine (query parser), SQL Database (SQL query interpreter)
16 Iterator Behavioral Twitter Feed (timeline iteration — paginated tweet stream), Amazon (product listing page iteration — infinite scroll), Spotify (playlist iteration — sequential track playback), YouTube (video feed iteration — recommended content stream), Document Assistant (document chunk iteration for processing), Code Search Engine (result set iteration), RAG Search Engine (retrieved chunk iteration)
17 Mediator Behavioral WhatsApp (message broker — mediates between senders and receivers), Airport (air traffic control — mediates between aircraft), Uber (ride matching — mediates between riders and drivers), Message Queue (broker — mediates producers and consumers), Chat system (room/channel mediator), AI Agent Memory (memory coordinator between agents)
18 Memento Behavioral ChatGPT (conversation save/restore for undo, branching, rollback), Google Docs (undo/redo — document state snapshots), AI Observability (EvalSnapshot — eval run comparison), AI Governance (ModelVersion snapshots for compliance audits), Prompt Injection Guard (RequestSnapshot — forensic analysis of security events), Uber (ride state — snapshots for failure recovery), Document Assistant (document revision history), AI Agent Memory (memory state checkpoint)
19 Observer Behavioral ChatGPT (ResponseStream — streaming tokens to SSE, WebSocket subscribers), Twitter Feed (new tweet notifications — push to followers), YouTube (subscriber notifications — new video alerts), LinkedIn (feed updates), Spotify (playlist changes — collaborative playlist updates), Dropbox (file sync — local changes notify cloud, cloud changes notify local), Amazon (order status — notify customer, warehouse, shipping), AI Observability (TraceCollector → DashboardUpdater, DriftMonitor), Prompt Injection Guard (SecurityEventBus → DashboardAlert, SecurityLogger), AI Governance (PolicyEnforcer → ModelReevaluator, AuditNotifier), Enterprise Support Bot (event bus for ticket lifecycle), RAG Search Engine (index update notifications), Multi-Model Gateway (provider health change notifications)
20 State Behavioral Uber (ride lifecycle — requesting → accepted → en route → completed → paid), Amazon (order state — pending → confirmed → shipped → delivered → returned), WhatsApp (message delivery state — sent → delivered → read), API Gateway (connection state — opening → open → closing → closed), Document Assistant (document workflow state — draft → review → approved → published), YouTube (video processing state — uploaded → transcoding → ready → failed), Parking Lot (spot state — available → reserved → occupied)
21 Strategy Behavioral Uber (pricing — surge, distance, time), YouTube (transcoding — VP9, H.264, AV1), Twitter Feed (timeline — rank, chronological, topic-based), Rate Limiter (algorithms — token bucket, leaky bucket, sliding window), Dropbox (sync — full sync, incremental, selective), Message Queue (delivery — at-most-once, at-least-once, exactly-once), API Gateway (routing — round-robin, least connections, IP hash), Load Balancer (routing — round-robin, weighted, least connections), ChatGPT (ModelProvider — GPT-4, Claude, Llama; RAGStrategy — simple, HyDE, agentic), RAG Search Engine (chunking — fixed, semantic, recursive; search — dense, sparse, hybrid; embedding — OpenAI, Cohere, BGE), AI Agent Memory (retrieval — recency, relevance, importance; consolidation — summarization, reflection), Multi-Model Gateway (routing — latency-based, cost-based, capability-based), Code Search Engine (search — BM25, embedding, hybrid; embedding — codeBERT, Ada, Unixcoder), Document Assistant (ingestion — batch, streaming; chunking — fixed, semantic; retrieval — vector, keyword, hybrid), Recommendation Engine (algorithm — collaborative, content-based, hybrid; ANN — HNSW, IVF, brute force; embedding — ALS, BERT, graph-based), Enterprise Support Bot (retrieval — FAQ, vector, hybrid), AI Observability (EvaluationMetric — correctness, faithfulness, relevance, hallucination, tone; DriftDetector — distribution shift, token usage, performance degradation), Prompt Injection Guard (DetectionStrategy — heuristic, ML, LLM, ensemble; SanitizationStrategy — redact, replace, block, flag), AI Governance (BiasDetector — demographic parity, equal opportunity, disparate impact; Explainer — SHAP, LIME, counterfactual), SQL Database (storage — B-tree, LSM; join — hash, merge, nested loop; concurrency — optimistic, pessimistic, MVCC), Docker (networking — bridge, host, overlay; storage — aufs, overlay2, devicemapper), Search Engine (ranking — PageRank, BM25, learning-to-rank; index — inverted, forward), Web Crawler (crawl strategy — BFS, DFS, focused), CDN (routing — geo, latency-based; cache — LRU, LFU, TTL), Git (merge — fast-forward, recursive, octopus), Ambassador (routing, circuit breaking, retry)
22 Template Method Behavioral AI Observability (EvalPipeline — load → infer → compute → report), AI Governance (CompliancePipeline — ingest → validate → explain → detect → report), Document Assistant (document processing pipeline — parse → chunk → embed → index), Recommendation Engine (training pipeline — sample → featurize → train → evaluate), Code Search Engine (indexing pipeline — scan → parse → tokenize → index), Amazon (order processing — validate → authorize → fulfill → ship → confirm), Netflix (content ingestion — receive → transcode → package → distribute)
23 Visitor Behavioral Document Assistant (document export — MarkdownVisitor, PDFVisitor, HTMLVisitor for document elements), Code Search Engine (AST visitor — parse code into searchable tokens), File system (disk usage calculator — FileVisitor pattern), Compiler (semantic analysis — type checker visitor over AST nodes)

Architectural Patterns

# Design Pattern Category Used In
24 Repository Architectural AI Governance (ModelRegistry — data access for model records), Prompt Injection Guard (PatternDatabase — pattern storage and retrieval), Enterprise Support Bot (ticket repository, knowledge base repository), Code Search Engine (index repository), Document Assistant (document store), Recommendation Engine (user-item interaction repository), Amazon (product catalog repository), Spotify (track/playlist repository)
25 Service Layer Architectural ChatGPT (LLMOrchestrator — coordinates providers, RAG, moderation, caching), API Gateway (gateway service), Amazon (order service, payment service, inventory service), Netflix (streaming service, recommendation service), Uber (ride service, payment service, notification service), YouTube (upload service, transcoding service), Dropbox (sync service), AI Agent Memory (memory service), Multi-Model Gateway (gateway service), Enterprise Support Bot (ticket service), AI Observability (telemetry service)
26 Dependency Injection Architectural ChatGPT (providers, RAG strategies, moderation injected into orchestrator), Multi-Model Gateway (providers, routers, caches injected), API Gateway (filters, routes injected), Recommendation Engine (algorithms, embedders injected), Document Assistant (ingestion, chunking, retrieval injected), AI Observability (metrics, detectors, alerters injected), Prompt Injection Guard (guards, sanitizers, detectors injected), AI Governance (bias detectors, explainers, classifiers injected), Uber (pricing, dispatch, payment injected)
27 Event-Driven Architecture Architectural Twitter Feed (new tweet events → fan-out to followers), YouTube (upload event → trigger transcode → notify subscribers), Amazon (order event → payment, inventory, shipping services react), Dropbox (file change event → propagate to peers), Message Queue (event publish/subscribe across services), AI Observability (trace events → metrics, dashboard, alerts), Prompt Injection Guard (security events → dashboard, logging, SIEM), AI Governance (policy change events → model re-evaluation, audit), RAG Search Engine (document update events → re-embed, re-index), Enterprise Support Bot (ticket events → assign, escalate, close)
28 CQRS Architectural Amazon (write — order placement; read — product catalog, order history — separate optimized stores), Twitter Feed (write — tweet ingestion into timeline; read — fan-out delivery to followers), WhatsApp (write — message sending; read — message history retrieval), YouTube (write — video upload; read — streaming, recommendations), Dropbox (write — file upload; read — file sync), Recommendation Engine (write — interaction logging; read — recommendation serving), Code Search Engine (write — indexing; read — searching)
29 Saga / Distributed Transaction Architectural Amazon (order saga — reserve inventory → charge payment → ship → release inventory on failure), Uber (ride saga — create ride → charge rider → pay driver → complete; rollback on any failure), Netflix (content publishing saga — ingest → transcode → package → distribute), WhatsApp (message delivery saga — send → server confirm → deliver → read receipt), Multi-Model Gateway (model call saga — call primary → fallback → timeout → circuit open)
30 MVC / Layered Architecture Architectural Spotify (view — UI; controller — playback, search; model — tracks, playlists, users), YouTube (view — video player, feed; controller — upload, search; model — videos, channels), Amazon (view — product pages, cart; controller — checkout, search; model — products, orders, users), Twitter Feed (view — timeline; controller — tweet, follow; model — tweets, users, timelines), API Gateway (presentation → orchestration → domain → persistence), Most web-facing system designs follow layered architecture

Pattern Distribution Summary

Design Pattern Total Systems
Singleton 30
Strategy 30
Observer 30
Decorator 16
Facade 10
Proxy 9
Chain of Responsibility 14
Command 12
State 9
Iterator 9
Mediator 8
Memento 12
Template Method 11
Adapter 10
Factory Method 11
Builder 9
Composite 9
Bridge 6
Flyweight 6
Prototype 5
Abstract Factory 5
Interpreter 8
Visitor 4
Event-Driven Architecture 16
Service Layer 14
Dependency Injection 12
CQRS 9
Saga 5
Repository 10
MVC / Layered Architecture 7

AI System Design Pattern Matrix

Pattern ChatGPT RAG Search AI Agent Memory Multi-Model Gateway Code Search Doc Assistant Rec Engine Enterprise Bot AI Observability Prompt Injection Guard AI Governance
Singleton
Strategy
Observer
Decorator
Chain of Resp.
Command
Template Method
Memento
Proxy
Facade
Adapter
Factory Method
Builder
Mediator
State
Event-Driven
Service Layer
Dependency Inj.
Repository
Saga
CQRS

Last updated: 2026-05-31. Covers 30 system designs (17 classic + 11 AI, 30 GoF + architectural patterns).