What is this?
This site covers all 23 Gang of Four (GoF) design patterns — the foundational patterns catalogued by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides in their seminal 1994 book Design Patterns: Elements of Reusable Object-Oriented Software.
Every pattern is implemented in TypeScript using NestJS conventions: dependency injection, modules, controllers, and decorators. Each example uses a real-world e-commerce domain — products, orders, payments, shipping — so the patterns feel practical rather than academic.
How the patterns are organized
The 23 patterns are divided into three categories:
- Creational (5 patterns) — Deal with object creation mechanisms. Includes Singleton, Factory Method, Abstract Factory, Builder, and Prototype.
- Structural (7 patterns) — Concern class and object composition. Includes Adapter, Bridge, Composite, Decorator, Facade, Flyweight, and Proxy.
- Behavioral (11 patterns) — Focus on communication between objects. Includes Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, and Visitor.
What each pattern page includes
- The Problem — A concrete scenario where the pattern is needed.
- The Solution — How the pattern addresses the problem.
- Structure — The roles and their responsibilities.
- Implementation — Full TypeScript source code with syntax highlighting.
- NestJS Integration — How the pattern maps to NestJS's provider system, DI container, and module architecture.
- When to Use / When NOT to Use — Practical guidance on applicability.
- Related Patterns — Cross-references to complementary or alternative patterns.
Technology
This site is built with Astro, styled with Tailwind CSS, and uses MDX for content pages. All code examples are real TypeScript files imported at build time with Shiki syntax highlighting.