Table of Contents

Patterns

Welcome! This section is the reference home for PatternKit’s core building blocks. Each page explains the why, the shape (APIs), and gives a tiny snippet so you can drop the pattern straight into your codebase.

If you’re looking for end-to-end, production-shaped demos, check the Examples & Demos section—those pages show these patterns working together (auth/logging chains, payment pipelines, router, coercer, etc.).


How these fit together

  • Behavioral patterns describe what runs & when (chains and strategies, observers, mediators, state machines).

  • Creational helpers build immutable, fast artifacts (routers, pipelines) from tiny delegates.

  • Common themes:

    • First-match wins (predictable branching without if ladders).
    • Branchless rule packs (ActionChain<T> with When/ThenContinue/ThenStop/Finally).
    • Immutable after Build() (thread-safe, allocation-light hot paths).

Behavioral

Chain

Strategy

Template

Iterator

Mediator

Command

Observer

State

Interpreter


Creational (Builder)

Structural


Additional Patterns

  • TypeDispatcher Type-safe runtime dispatch that routes objects to handlers based on their concrete type.

Where to see them in action

  • Auth & Logging Chain — request-ID logging + strict auth short-circuit using ActionChain.
  • Strategy-Based CoercionTryStrategy turns mixed inputs into typed values.
  • Mediated / Config-Driven Transaction Pipelines — chains + strategies for totals, rounding, tender routing.
  • Minimal Web Request RouterBranchBuilder for middleware and routes.
  • State Machine — order lifecycle with entry/exit hooks and default behaviors.

Tip: every pattern page has a tiny example; the demos show realistic combinations with TinyBDD tests you can read like specs.