# hmlongco/factory architecture

> Architecture diagram of the GitHub repository hmlongco/factory, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hmlongco/factory
- Repository: https://github.com/hmlongco/factory

## Overview

##### Main Components

a. Core Components:
- Container System
- Factory Registration System
- Dependency Resolution System
- Scope Management System
- Context Management System
- Property Wrapper System

b. Supporting Components:
- Debugging Infrastructure
- Testing Support
- SwiftUI Integration
- Concurrency Support

**┌─────────────────────────────────────────────────────────┐**
- Client Application                     │
- ┬─────────────────────────┬───────────────┘

**┌───────────────▼─────┐       ┌──────────▼──────────┐**
- Property Wrappers  │       │  Direct Resolution  │
- @Injected         │       │  Container.shared    │
- @LazyInjected     │       └──────────┬──────────┘
- @InjectedObject   │                  │
- ┬───────────┘                  │

**┌─────────▼──────────────────────────────▼───────────────┐**
- Factory Core                           │
- ┬───────────────────────────────┤
- Registration        │         Resolution            │
- ┌─────────────────┐  │  ┌────────────────────────┐   │
- Factory Definition│  │  │   Dependency Graph     │   │
- Scope Management │  │  │   Instance Creation    │   │
- Context Handling │  │  │   Scope Resolution     │   │
- ┘  │  └────────────────────────┘   │
- ┘

- ┌──────────▼──────────┐
- Scope System     │
- ┌────────────────┐  │
- Singleton   │  │
- Cached     │  │
- Shared     │  │
- Unique     │  │
- ┘  │
- ┘

- ┌──────────▼──────────┐
- Context System    │
- ┌────────────────┐  │
- Debug      │  │
- Preview     │  │
- Test       │  │
- Simulator    │  │
- ┘  │
- ┘

##### Additional Elements

Callouts for:
- Concurrency support
- Debug tracing capabilities
- Testing integration points
- SwiftUI preview support
- Module separation capabilities

##### Implementation Details

- The container-based architecture
- The factory pattern implementation
- The property wrapper system
- The scope management system
- The context-aware resolution system

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Application Layer"]
        PW["Property Wrappers"]
        DR["Direct Resolution"]
    end

    subgraph Interface["Interface Layer"]
        Injected["@Injected"]:::wrapper
        LazyInjected["@LazyInjected"]:::wrapper
        InjectedObject["@InjectedObject"]:::wrapper
        Container["Container.shared"]:::core
    end

    subgraph Core["Factory Core"]
        Factory["Factory"]:::core
        Registration["Registration System"]:::core
        Resolution["Resolution System"]:::core
        Modifiers["Modifiers System"]:::core
        Locking["Locking Mechanism"]:::core
    end

    subgraph Support["Support Systems"]
        Scopes["Scope Management"]:::support
        Contexts["Context Management"]:::support
        Debug["Debugging System"]:::support
    end

    subgraph Integration["Integration Layer"]
        Testing["Testing Support"]:::integration
        SwiftUI["SwiftUI Integration"]:::integration
    end

    %% Relationships
    PW --> Interface
    DR --> Container
    
    Injected & LazyInjected & InjectedObject --> Factory
    Container --> Factory
    
    Factory --> Registration
    Factory --> Resolution
    Factory --> Modifiers
    Factory --> Locking
    
    Registration <--> Resolution
    Resolution --> Scopes
    Resolution --> Contexts
    
    Factory --> Debug
    Factory --> Testing
    Factory --> SwiftUI

    %% Click Events
    click Factory "https://github.com/hmlongco/Factory/blob/main/Sources/Factory/Factory/Factory.swift"
    click Registration "https://github.com/hmlongco/Factory/blob/main/Sources/Factory/Factory/Registrations.swift"
    click Resolution "https://github.com/hmlongco/Factory/blob/main/Sources/Factory/Factory/Resolutions.swift"
    click Modifiers "https://github.com/hmlongco/Factory/blob/main/Sources/Factory/Factory/Modifiers.swift"
    click Locking "https://github.com/hmlongco/Factory/blob/main/Sources/Factory/Factory/Locking.swift"
    click Scopes "https://github.com/hmlongco/Factory/blob/main/Sources/Factory/Factory/Scopes.swift"
    click Contexts "https://github.com/hmlongco/Factory/blob/main/Sources/Factory/Factory/Contexts.swift"
    click Debug "https://github.com/hmlongco/Factory/blob/main/Sources/Factory/Factory/Development/Debugging.md"
    click Testing "https://github.com/hmlongco/Factory/tree/main/Tests/FactoryTests"
    click SwiftUI "https://github.com/hmlongco/Factory/blob/main/FactoryDemo/FactoryDemo/ContentView.swift"
    click Container "https://github.com/hmlongco/Factory/blob/main/Sources/Factory/Factory/Containers.swift"
    click Injected "https://github.com/hmlongco/Factory/blob/main/Sources/Factory/Factory/Injections.swift"
    click LazyInjected "https://github.com/hmlongco/Factory/blob/main/Sources/Factory/Factory/Injections.swift"
    click InjectedObject "https://github.com/hmlongco/Factory/blob/main/Sources/Factory/Factory/Injections.swift"

    %% Styles
    classDef core fill:#2374ab,stroke:#2374ab,color:#fff
    classDef wrapper fill:#47b39c,stroke:#47b39c,color:#fff
    classDef support fill:#ffc43d,stroke:#ffc43d,color:#000
    classDef integration fill:#999,stroke:#999,color:#fff

    %% Legend
    subgraph Legend
        CoreComponent["Core Component"]:::core
        WrapperComponent["Wrapper Component"]:::wrapper
        SupportComponent["Support Component"]:::support
        IntegrationComponent["Integration Component"]:::integration
    end
```
