# frabbit/veins-di architecture

> Architecture diagram of the GitHub repository frabbit/veins-di, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/frabbit/veins-di
- Repository: https://github.com/frabbit/veins-di

## Overview

##### Main Components

a) Framework Core Components:
- Module System (Primary Container)
- Macro Processing Layer
- Dependency Resolution System
- Type Registration System

b) Runtime Flow Components:
- Bootstrap Process
- Dependency Graph
- Instance Creation Pipeline
- Lazy Loading Mechanism

**┌─ Public API Layer ─────────────────┐**
- Module.make()                      │
- .add()                            │
- .run()                            │
- .bootstrap()                      │
- ┘

**┌─ Macro Processing Layer ───────────┐**
- ModuleMacrosImpl                   │
- Type Analysis                      │
- Dependency Resolution              │
- Code Generation                    │
- ┘

**┌─ Runtime Layer ──────────────────┐**
- Instance Management              │
- Lazy Resolution                  │
- Dependency Graph                 │
- ┘

##### Key Elements to Highlight

- Compile-time components (blue)
- Runtime components (green)
- Public API (orange)
- Generated code (purple)

##### Important Relationships

- Module hierarchy (parent-child relationships)
- Type registration flow
- Dependency resolution process
- Instance creation sequence
- Lazy loading triggers

##### Additional Elements

- Symbol meanings
- Component types

##### Implementation Notes

- The compile-time nature of the framework
- The type-driven dependency resolution
- The module system's hierarchical nature
- The lazy loading mechanism
- The bootstrap process

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef api fill:#f96,stroke:#333,stroke-width:2px
    classDef macro fill:#69f,stroke:#333,stroke-width:2px
    classDef runtime fill:#6b9,stroke:#333,stroke-width:2px
    classDef generated fill:#c6f,stroke:#333,stroke-width:2px

    %% Public API Layer
    subgraph API
        ModuleAPI["Module API"]:::api
        Make["Module.make()"]:::api
        Add["add()"]:::api
        Run["run()"]:::api
        Bootstrap["bootstrap()"]:::api
        
        ModuleAPI --> Make
        ModuleAPI --> Add
        ModuleAPI --> Run
        ModuleAPI --> Bootstrap
    end

    %% Macro Processing Layer
    subgraph MacroLayer
        MacroImpl["ModuleMacrosImpl"]:::macro
        TypeAnalysis["Type Analysis"]:::macro
        DependencyRes["Dependency Resolution"]:::macro
        CodeGen["Code Generation"]:::macro
        MacroTools["Macro Utilities"]:::macro
        
        MacroImpl --> TypeAnalysis
        TypeAnalysis --> DependencyRes
        DependencyRes --> CodeGen
        MacroTools --> MacroImpl
    end

    %% Runtime Layer
    subgraph Runtime
        InstanceMgmt["Instance Management"]:::runtime
        LazyRes["Lazy Resolution"]:::runtime
        DepGraph["Dependency Graph"]:::runtime
        TypeReg["Type Registration"]:::runtime
        Bundle["Bundle System"]:::runtime
        ComplexTypes["Complex Type Handler"]:::runtime
        
        InstanceMgmt --> LazyRes
        LazyRes --> DepGraph
        DepGraph --> TypeReg
        TypeReg --> Bundle
        Bundle --> ComplexTypes
    end

    %% Inter-layer connections
    ModuleAPI --> MacroImpl
    CodeGen -.-> InstanceMgmt
    DependencyRes -.-> DepGraph
    Bootstrap --> InstanceMgmt

    %% Click events for component mapping
    click ModuleAPI "https://github.com/frabbit/veins-di/blob/master/src/veins/di/Module.hx"
    click MacroImpl "https://github.com/frabbit/veins-di/blob/master/src/veins/di/macros/ModuleMacrosImpl.hx"
    click MacroTools "https://github.com/frabbit/veins-di/blob/master/src/veins/di/macros/Tools.hx"
    click LazyRes "https://github.com/frabbit/veins-di/blob/master/samples/02-lazy/Main.hx"
    click DependencyRes "https://github.com/frabbit/veins-di/blob/master/samples/03-dependencies/Main.hx"
    click TypeReg "https://github.com/frabbit/veins-di/blob/master/samples/04-types/Main.hx"
    click ComplexTypes "https://github.com/frabbit/veins-di/blob/master/samples/05-complex-types/Main.hx"
    click Bundle "https://github.com/frabbit/veins-di/blob/master/samples/06-bundles/Main.hx"

    %% Legend
    subgraph Legend
        L1["API Component"]:::api
        L2["Macro Component"]:::macro
        L3["Runtime Component"]:::runtime
        L4["Generated Code"]:::generated
    end
```
