# leandros/ferrunix architecture

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

- Interactive diagram: https://gitdiagram.com/leandros/ferrunix
- Repository: https://github.com/leandros/ferrunix

## Overview

##### Main Components

a) Core Components:
- ferrunix-core: The main engine of the DI framework
- ferrunix-macros: The derive macro implementation
- ferrunix: The main public API crate

b) Supporting Components:
- Documentation system (book)
- Examples
- Testing infrastructure
- Build and CI tools (xtask)

##### Public API Layer
- Entry point through the main `ferrunix` crate
- Expose high-level interfaces for users

##### Macro Processing Layer
- Custom derive macros for dependency injection
- Attribute processing
- Code generation facilities

##### Core Implementation Layer
- Registry management
- Dependency resolution
- Lifecycle management
- Error handling
- Async support

##### Use a top-down approach with three main sections

**┌─────────────────────────────────────┐**
- Public API Layer          │
- (ferrunix)               │
- ┘
- ↑
**┌─────────────────────────────────────┐**
- Macro Processing Layer      │
- (ferrunix-macros)          │
- ┘
- ↑
**┌─────────────────────────────────────┐**
- Core Implementation         │
- (ferrunix-core)            │
- ┘

##### For each layer, include the following details

Core Implementation Layer:
- Object Builder (Sync/Async)
- Dependency Resolution
- Cycle Detection
- Registration Management
- Type System Integration

Macro Processing Layer:
- Attribute Processing
- Derive Macro Implementation
- Code Generation
- Injection Logic

Public API Layer:
- Registry Interface
- Builder Patterns
- Error Handling
- Public Traits

- Data flow direction
- Type information flow

##### Specific features
- Async support paths
- Error propagation channels
- Registration flows
- Dependency resolution paths

Important Considerations:

##### How the three main crates interact
- ferrunix → ferrunix-core (runtime dependency)
- ferrunix → ferrunix-macros (compile-time dependency)
- ferrunix-macros → ferrunix-core (type information only)

##### Subsystems from ferrunix-core
- Registry management
- Object lifecycle
- Dependency resolution
- Error handling

##### Extension points
- Custom derive implementations
- Trait implementations
- Builder customization

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef api fill:#2196F3,stroke:#1565C0,color:white
    classDef macro fill:#4CAF50,stroke:#388E3C,color:white
    classDef core fill:#FF9800,stroke:#F57C00,color:white
    classDef docs fill:#9E9E9E,stroke:#616161,color:white
    classDef tools fill:#607D8B,stroke:#455A64,color:white

    subgraph Public["Public API Layer"]
        API["Main Public Interface"]:::api
    end

    subgraph Macro["Macro Processing Layer"]
        MP["Main Macro Implementation"]:::macro
        AP["Attribute Processing"]:::macro
        IL["Injection Logic"]:::macro
        MU["Macro Utilities"]:::macro
    end

    subgraph Core["Core Implementation Layer"]
        OB["Object Builder"]:::core
        AOB["Async Object Builder"]:::core
        SOB["Sync Object Builder"]:::core
        DR["Dependency Resolution"]:::core
        CD["Cycle Detection"]:::core
        RM["Registration Management"]:::core
        RI["Registry Implementation"]:::core
        EH["Error Handling"]:::core
        TS["Type System"]:::core
    end

    subgraph Docs["Documentation"]
        UG["User Guide"]:::docs
        RG["Reference Guide"]:::docs
        EX["Examples"]:::docs
        SD["Simple DI Example"]:::docs
        DD["Derived DI Example"]:::docs
    end

    subgraph Tools["Build and CI Tools"]
        CI["CI Implementation"]:::tools
        DB["Documentation Build"]:::tools
        PT["Publishing Tools"]:::tools
    end

    %% Relationships
    API --> MP
    API --> OB
    MP --> IL
    MP --> AP
    MP --> MU
    IL --> TS
    OB --> AOB
    OB --> SOB
    OB --> DR
    DR --> CD
    DR --> RM
    RM --> RI
    RI --> EH
    RI --> TS
    EX --> SD
    EX --> DD

    %% Click events
    click API "https://github.com/Leandros/ferrunix/blob/master/ferrunix/src/lib.rs"
    click MP "https://github.com/Leandros/ferrunix/blob/master/ferrunix-macros/src/lib.rs"
    click AP "https://github.com/Leandros/ferrunix/blob/master/ferrunix-macros/src/attr.rs"
    click IL "https://github.com/Leandros/ferrunix/blob/master/ferrunix-macros/src/inject.rs"
    click MU "https://github.com/Leandros/ferrunix/blob/master/ferrunix-macros/src/utils.rs"
    click OB "https://github.com/Leandros/ferrunix/blob/master/ferrunix-core/src/object_builder.rs"
    click AOB "https://github.com/Leandros/ferrunix/blob/master/ferrunix-core/src/object_builder_async.rs"
    click SOB "https://github.com/Leandros/ferrunix/blob/master/ferrunix-core/src/object_builder_sync.rs"
    click DR "https://github.com/Leandros/ferrunix/blob/master/ferrunix-core/src/dependencies.rs"
    click CD "https://github.com/Leandros/ferrunix/blob/master/ferrunix-core/src/cycle_detection.rs"
    click RM "https://github.com/Leandros/ferrunix/blob/master/ferrunix-core/src/registration.rs"
    click RI "https://github.com/Leandros/ferrunix/blob/master/ferrunix-core/src/registry.rs"
    click EH "https://github.com/Leandros/ferrunix/blob/master/ferrunix-core/src/error.rs"
    click TS "https://github.com/Leandros/ferrunix/blob/master/ferrunix-core/src/types.rs"
    click UG "https://github.com/Leandros/ferrunix/tree/master/book/src/user-guide"
    click RG "https://github.com/Leandros/ferrunix/tree/master/book/src/reference-guide"
    click SD "https://github.com/Leandros/ferrunix/tree/master/examples/simple"
    click DD "https://github.com/Leandros/ferrunix/tree/master/examples/derived"
    click CI "https://github.com/Leandros/ferrunix/blob/master/xtask/src/ci.rs"
    click DB "https://github.com/Leandros/ferrunix/blob/master/xtask/src/docs.rs"
    click PT "https://github.com/Leandros/ferrunix/blob/master/xtask/src/publish.rs"
```
