# extrys/injekko architecture

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

- Interactive diagram: https://gitdiagram.com/extrys/injekko
- Repository: https://github.com/extrys/injekko

## Overview

##### Project type and purpose
- Injekko is an open-source, compile-time dependency-injection framework for Unity.
- It uses a Roslyn Source Generator (InjekkoGen) to scan your code for custom attributes (InjekAttribute) defined in the InjekkoBinding library, auto-generates strongly-typed resolver code, and compiles it into your Assembly. A small “playground” app demonstrates and tests the runtime behavior.

##### File structure
- InjekkoBinding/
– A .NET Standard 2.0 class-library exposing `[Injek]` attributes and container base classes (Service Locator contexts: global, scene, object).
- InjekkoGen/
– A Roslyn Source Generator project (.NET 8.0 + .NETStandard2.0) that references DependencyInjectionGeneratorLib.
– Contains code (`InjekkoSourceGenerator.cs`) that runs at compile time, finds `InjekAttribute` usages, and emits generated resolver classes as C# files.
- InjekkoPlayground/
– A .NET 6.0 console/Unity-like mockup app.
– Under `Containers/` and `EngineMockup/` it uses generated code to wire up dependencies and simulate Unity scenes and game objects.
– `Logs/` shows output of generated code and runtime scene logs.

##### README for additional insights
- Highlights zero‐reflection, Roslyn code generation, Unity integration, multiple contexts, and a playground.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Compile Time Zone
    subgraph "Compile Time" 
        direction TB
        DeveloperCode["Developer Code (Annotations)"]:::user
        BindingLib["InjekkoBinding Library"]:::library
        SourceGen["Roslyn Source Generator"]:::library
        GeneratedCode["Generated Resolver Code"]:::artifact
        CompilerStage["Compilation & Build Pipeline"]:::process
    end

    %% Runtime Zone
    subgraph "Runtime" 
        direction TB
        FinalAssembly["Final Assembly (DLL/EXE)"]:::artifact
        subgraph "Runtime Container Contexts"
            direction TB
            GlobalCtx["ProjectContext"]:::context
            SceneCtx["SceneContext"]:::context
            ObjectCtx["GameObjectContext"]:::context
        end
        subgraph "Engine Mockup"
            direction TB
            ProjectMock["Project"]:::external
            SceneMock["Scene"]:::external
            GameObjectMock["GameObject"]:::external
            ComponentMock["Component"]:::external
        end
        PlaygroundApp["Runtime Application (Playground)"]:::process
        subgraph "Runtime Logs"
            GeneratedLog["GeneratedCode.txt"]:::log
            SceneLog["SceneLog.txt"]:::log
        end
    end

    %% Relationships
    DeveloperCode -->|"sources + [Injek] Metadata"| SourceGen
    BindingLib -->|"attributes & base classes"| SourceGen
    SourceGen -->|"emits .cs files"| GeneratedCode
    GeneratedCode -->|"inputs to"| CompilerStage
    SourceGen -->|"references DI Generator Lib"| CompilerStage
    BindingLib -->|"references"| CompilerStage
    DeveloperCode -->|"compiled by"| CompilerStage
    CompilerStage -->|"produces"| FinalAssembly

    FinalAssembly -->|"loaded by"| PlaygroundApp
    PlaygroundApp -->|"instantiates"| GlobalCtx
    GlobalCtx -->|"creates"| SceneCtx
    SceneCtx -->|"creates"| ObjectCtx
    PlaygroundApp -->|"drives lifecycle on"| ProjectMock
    PlaygroundApp -->|"drives lifecycle on"| SceneMock
    PlaygroundApp -->|"drives lifecycle on"| GameObjectMock
    PlaygroundApp -->|"drives lifecycle on"| ComponentMock
    PlaygroundApp -->|"writes"| GeneratedLog
    PlaygroundApp -->|"writes"| SceneLog

    %% Click Events for component mapping
    click DeveloperCode "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/Program.cs"
    click DeveloperCode "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/Player.cs"
    click DeveloperCode "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/TestDependencies/DependencyA.cs"
    click DeveloperCode "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/TestDependencies/DependencyB.cs"
    click DeveloperCode "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/TestDependencies/DependencyC.cs"
    click BindingLib "https://github.com/extrys/injekko/blob/main/InjekkoBinding/InjekAttribute.cs"
    click BindingLib "https://github.com/extrys/injekko/blob/main/InjekkoBinding/InjekkoContainer.cs"
    click BindingLib "https://github.com/extrys/injekko/blob/main/InjekkoBinding/InjekkoBinding.csproj"
    click SourceGen "https://github.com/extrys/injekko/blob/main/InjekkoGen/InjekkoSourceGenerator.cs"
    click SourceGen "https://github.com/extrys/injekko/blob/main/InjekkoGen/InjekMethodReceiver.cs"
    click SourceGen "https://github.com/extrys/injekko/blob/main/InjekkoGen/InjekAttribute.cs"
    click SourceGen "https://github.com/extrys/injekko/blob/main/InjekkoGen/InjekkoGen.csproj"
    click GlobalCtx "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/Containers/ProjectContext.cs"
    click SceneCtx "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/Containers/SceneContext.cs"
    click ObjectCtx "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/Containers/GameObjectContext.cs"
    click PlaygroundApp "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/Containers/Context.cs"
    click ProjectMock "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/EngineMockup/Project.cs"
    click SceneMock "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/EngineMockup/Scene.cs"
    click GameObjectMock "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/EngineMockup/GameObject.cs"
    click ComponentMock "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/EngineMockup/Component.cs"
    click GeneratedCode "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/obj/Debug/net6.0/generated/InjekkoGen/Injekko.Codegen.InjekkoSourceGenerator/ContainerGenerated.cs"
    click GeneratedCode "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/obj/Debug/net6.0/generated/InjekkoGen/Injekko.Codegen.InjekkoSourceGenerator/InjekAttribute.cs"
    click GeneratedCode "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/obj/Debug/net6.0/generated/InjekkoGen/Injekko.Codegen.InjekkoSourceGenerator/Injekko.cs"
    click GeneratedCode "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/obj/Debug/net6.0/generated/InjekkoGen/Injekko.Codegen.InjekkoSourceGenerator/InjekkoGenerated.cs"
    click GeneratedLog "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/Logs/GeneratedCode.txt"
    click SceneLog "https://github.com/extrys/injekko/blob/main/InjekkoPlayground/Logs/SceneLog.txt"

    %% Styles
    classDef library fill:#AED6F1,stroke:#2980B9,color:#154360;
    classDef artifact fill:#ABEBC6,stroke:#27AE60,color:#145A32;
    classDef user fill:#F9E79F,stroke:#B7950B,color:#7D6608;
    classDef process fill:#F5B7B1,stroke:#C0392B,color:#641E16;
    classDef context fill:#E8DAEF,stroke:#8E44AD,color:#4A235A;
    classDef external fill:#D5DBDB,stroke:#7B7D7D,color:#1B2631;
    classDef log fill:#FADBD8,stroke:#922B21,color:#641E16;
```
