# algoyounes/bindify architecture

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

- Interactive diagram: https://gitdiagram.com/algoyounes/bindify
- Repository: https://github.com/algoyounes/bindify

## Overview

##### Project Type and Purpose
- Bindify is a Laravel PHP package (library) that extends Laravel’s service container.
- It leverages PHP 8.2 Attributes to provide declarative, lazy interface-to-implementation bindings inside a Laravel application.

##### File Structure Overview
- src/Attributes: definitions of the #[BindWith] and #[BindType] attributes.
- src/Contexts: classes (BindContext) holding metadata for each binding.
- src/Contracts: internal interfaces (e.g., BindifyResolver).
- src/Providers: the BindifyServiceProvider that integrates into Laravel’s bootstrapping.
- src/Resolvers: core logic (AttributeResolver) that scans attributes and performs the binding.
- tests & workbench: example contracts and implementations to verify behavior.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Laravel Core Layer
    subgraph "Laravel Core"
        direction TB
        Composer["Composer Autoload"]:::core
        LaravelBoot["Laravel Bootstrapping"]:::core
        Container["Service Container\n(Illuminate\\Container\\Container)"]:::core
    end

    %% Bindify Package Layer
    subgraph "Bindify Package"
        direction TB
        ServiceProvider["BindifyServiceProvider"]:::package
        AttributeResolver["AttributeResolver"]:::package
        BindContext["BindContext"]:::package
        BindWith["BindWith Attribute"]:::package
        BindType["BindType Attribute"]:::package
        ResolverContract["BindifyResolver Interface"]:::package
    end

    %% Application Code Layer
    subgraph "Application Code"
        direction TB
        Interface["User Interface\n#[BindWith]"]:::app
        Impl["Concrete Implementation"]:::app
        TagRetrieval["Tagged Retrieval\n(container()->tagged)"]:::app
        Tests["Package Feature Tests"]:::app
        WBContracts["Workbench Example Contracts"]:::app
        WBImplDefault["DefaultImplementationService"]:::app
        WBImplAlt["AlternativeImplementationService"]:::app
    end

    %% Data Flow / Relationships
    Composer --> LaravelBoot
    LaravelBoot --> ServiceProvider
    ServiceProvider --> Container
    Container -->|"resolving event"| AttributeResolver
    Interface -->|"annotated"| BindWith
    Interface --> AttributeResolver
    BindWith --> AttributeResolver
    BindType --> AttributeResolver
    ResolverContract --> AttributeResolver
    AttributeResolver -->|"builds"| BindContext
    BindContext --> AttributeResolver
    AttributeResolver -->|"bindSingleton()/bindTransient()"| Container
    Container -->|"returns implementation"| Impl
    Container -->|"container()->tagged(tag)"| TagRetrieval
    WBContracts --> Interface
    WBImplDefault --> Impl
    WBImplAlt --> Impl
    Tests --> ServiceProvider

    %% Click Events
    click BindWith "https://github.com/algoyounes/bindify/blob/master/src/Attributes/BindWith.php"
    click BindType "https://github.com/algoyounes/bindify/blob/master/src/Attributes/BindType.php"
    click BindContext "https://github.com/algoyounes/bindify/blob/master/src/Contexts/BindContext.php"
    click ResolverContract "https://github.com/algoyounes/bindify/blob/master/src/Contracts/BindifyResolver.php"
    click ServiceProvider "https://github.com/algoyounes/bindify/blob/master/src/Providers/BindifyServiceProvider.php"
    click AttributeResolver "https://github.com/algoyounes/bindify/blob/master/src/Resolvers/AttributeResolver.php"
    click Tests "https://github.com/algoyounes/bindify/blob/master/tests/Feature/BindifyTest.php"
    click WBContracts "https://github.com/algoyounes/bindify/tree/master/workbench/app/Contracts/"
    click WBImplDefault "https://github.com/algoyounes/bindify/blob/master/workbench/app/DefaultImplementationService.php"
    click WBImplAlt "https://github.com/algoyounes/bindify/blob/master/workbench/app/AlternativeImplementationService.php"

    %% Styles
    classDef core fill:#a0d8ef,stroke:#333,stroke-width:1px;
    classDef package fill:#a8df65,stroke:#333,stroke-width:1px;
    classDef app fill:#f4a261,stroke:#333,stroke-width:1px;
```
