← All Patterns
Factory Pattern diagram
Factory Pattern — structural diagram

Motivation

Direct instantiation scatters construction logic, prevents governance, and couples application code to concrete implementations. When construction requires config, caching, thread-safety, and lifecycle management, doing it inline becomes unmanageable.

K9-AIF factories are static — they cannot be instantiated. They maintain a thread-safe registry and return cached instances. All major components are provisioned exclusively through factories.

Structure

Key Concepts

AgentRegistry OrchestratorRegistry RouterFactory LLMFactory ModelRouterFactory SecretManagerFactory CacheFactory singleton caching bootstrap pattern

Used in K9-AIF

AgentRegistry OrchestratorRegistry RouterFactory LLMFactory ModelRouterFactory SecretManagerFactory CacheFactory PersistenceFactory