# iokode/opinionatedframework architecture

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

- Interactive diagram: https://gitdiagram.com/iokode/opinionatedframework
- Repository: https://github.com/iokode/opinionatedframework

## Overview

Based on our analysis of the file tree and README, OpinionatedFramework is a comprehensive .NET 8+ framework designed to streamline the development of the application (or domain) layer by providing pre-built contracts and their default implementations. The framework is modular by design and organized into several components, each handling a specific concern (such as commands, filesystem interactions, emailing, encryption, events, logging, persistence, and more). It also includes bootstrapping and source generation capabilities to enhance developer productivity.

##### Main Components
- Bootstrapping: Represents the initialization logic (e.g., container setup, dependency scanning) found in the “src/Bootstrapping” directory and “DefaultBootstrapping” project.
- Foundation Layer: This is the heart of the framework’s core functionalities and contracts. It contains sub-components such as Commands, Emailing, Events, FileSystem, Persistence, Security, Logging, Notifications, and more (found in “src/Foundation”).
- Contract Implementations: Every core interface (contract) has its default implementation spread across the “src/ContractImplementations.*” directories (e.g., CommandExecutor, Aes256GcmModeEncrypter, Hangfire, MailKit, MicrosoftLogging, NHibernate, etc.). These projects effectively “plug into” the foundation layer, providing the concrete behavior.
- Source Generators: Code generation tools (under “src/SourceGenerators.*”) that automatically generate code related to ensuring, facades, migrations, and SQL query objects. These reduce boilerplate and enforce common patterns.
- Testing Modules: Comprehensive tests are included to verify individual modules (with separate test projects such as “src/Tests.*”). While not part of runtime architecture, they provide insight into the project’s capabilities and expected usage.
- Infrastructure and Internals: Supporting modules (like “src/Internals” and “src/MSBuild”) and documentation (under “docs”) which assist in build configuration and setup.

##### Relationships and Interactions
- Source Generators as an auxiliary engine that helps compile or generate some of the required supporting code. Connect these to the Foundation and Contract Implementations where auto-generation aids in creating supporting code structures.
- “Tests” block interacting with each of the above components to validate correctness and adherence to architectural principles. These tests help ensure the reliability of each module and their integration.

##### Architectural Patterns and Design Principles
- Dependency inversion by noting that the Foundation defines interfaces (contracts) while implementations can be swapped as needed.
- Separation of concerns between the core application/domain logic (Foundation) and the infrastructural implementation (Contract Implementations).
- Use of middleware patterns within the Command implementation (as referenced in the Foundation Commands), as well as the possible use of the Unit of Work in persistence.
- The bootstrapping phase is critical: mention how the framework uses its own service container (or static locator) to tie the components together without being coupled to external dependency injection frameworks.

##### Technology and Framework Specifics
- Important libraries (e.g., MailKit for emailing, NHibernate for persistence) associated with each module.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Bootstrapping Subgraph
    subgraph "Bootstrapping"
        BS1("Bootstrapping – Container Setup")
        BS2("Default Bootstrapping")
    end

    %% Foundation Layer
    F("Foundation – Core Contracts")

    %% Contract Implementations Subgraph
    subgraph "Contract Implementations"
        C1("CommandExecutor")
        C2("Aes256GcmModeEncrypter")
        C3("NHibernate")
    end

    %% Source Generators Subgraph
    subgraph "Source Generators"
        SG1("Ensuring")
        SG2("Facades")
        SG3("Migrations")
        SG4("SqlQueryObjects")
    end

    %% Testing Modules Subgraph
    subgraph "Testing Modules"
        T1("Tests – CommandExecutor")
        T2("Tests – Ensuring")
        T3("Tests – Foundation")
    end

    %% Infrastructure and Internals Subgraph
    subgraph "Infrastructure / Internals"
        I1("Internals")
        I2("MSBuild")
    end

    %% Documentation and Platform
    D("Documentation")
    P("Platform: .NET 8+")

    %% Connections
    BS1 -->|"initializes"| F
    BS2 -->|"initializes"| F

    F -->|"defines_contracts_for"| C1
    F -->|"defines_contracts_for"| C2
    F -->|"defines_contracts_for"| C3

    BS1 -->|"configures"| C1
    BS1 -->|"configures"| C2
    BS1 -->|"configures"| C3
    BS2 -->|"configures"| C1
    BS2 -->|"configures"| C2
    BS2 -->|"configures"| C3

    SG1 -->|"augments"| F
    SG2 -->|"augments"| F
    SG3 -->|"augments"| F
    SG4 -->|"augments"| F

    SG1 -->|"supports"| C1
    SG2 -->|"supports"| C2
    SG3 -->|"supports"| C3

    T3 ---|"tests"| F
    T1 ---|"tests"| C1
    T2 ---|"tests"| SG1

    I1 -->|"supports_build"| BS1
    I2 -->|"supports_build"| BS1

    D ---|"documents"| F

    P -->|"targets"| F

    %% Click Events
    click BS1 "https://github.com/iokode/opinionatedframework/tree/main/src/Bootstrapping"
    click BS2 "https://github.com/iokode/opinionatedframework/tree/main/src/DefaultBootstrapping"
    click F "https://github.com/iokode/opinionatedframework/tree/main/src/Foundation"
    click C1 "https://github.com/iokode/opinionatedframework/blob/main/src/ContractImplementations.CommandExecutor"
    click C2 "https://github.com/iokode/opinionatedframework/blob/main/src/ContractImplementations.Aes256GcmModeEncrypter"
    click C3 "https://github.com/iokode/opinionatedframework/blob/main/src/ContractImplementations.NHibernate"
    click SG1 "https://github.com/iokode/opinionatedframework/blob/main/src/SourceGenerators.Ensuring"
    click SG2 "https://github.com/iokode/opinionatedframework/blob/main/src/SourceGenerators.Facades"
    click SG3 "https://github.com/iokode/opinionatedframework/blob/main/src/SourceGenerators.Migrations"
    click SG4 "https://github.com/iokode/opinionatedframework/blob/main/src/SourceGenerators.SqlQueryObjects"
    click T1 "https://github.com/iokode/opinionatedframework/blob/main/src/Tests.CommandExecutor"
    click T2 "https://github.com/iokode/opinionatedframework/blob/main/src/Tests.Ensuring"
    click T3 "https://github.com/iokode/opinionatedframework/blob/main/src/Tests.Foundation"
    click I1 "https://github.com/iokode/opinionatedframework/tree/main/src/Internals"
    click I2 "https://github.com/iokode/opinionatedframework/tree/main/src/MSBuild"
    click D "https://github.com/iokode/opinionatedframework/tree/main/docs"

    %% Styles
    class BS1,BS2 bootstrapping
    class F foundation
    class C1,C2,C3 contract
    class SG1,SG2,SG3,SG4 sourcegen
    class T1,T2,T3 tests
    class I1,I2 infra
    class D doc
    class P platform

    %% Class Definitions
    classDef bootstrapping fill:#ffcc99,stroke:#cc6600,stroke-width:2px;
    classDef foundation fill:#aaccff,stroke:#3366cc,stroke-width:2px;
    classDef contract fill:#ccffcc,stroke:#669966,stroke-width:2px;
    classDef sourcegen fill:#e6ccff,stroke:#9966cc,stroke-width:2px;
    classDef tests fill:#ffffcc,stroke:#cccc66,stroke-width:2px;
    classDef infra fill:#ffebcc,stroke:#cc9966,stroke-width:2px;
    classDef doc fill:#e6ffe6,stroke:#66cc66,stroke-width:2px;
    classDef platform fill:#cceeff,stroke:#3399cc,stroke-width:2px;
```
