# ehsanfaridi92/framework architecture

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

- Interactive diagram: https://gitdiagram.com/ehsanfaridi92/framework
- Repository: https://github.com/ehsanfaridi92/framework

## Overview

##### High-level breakdown

- Build & CI/CD Business:
– BuildScript components, build commands (build.ps1, build.cmd, build.sh)
– Azure Pipeline integration via the Framework-Azure-Pipeline.yaml
– GitHub configurations (such as .github folder)

- Core Framework Modules (within Code/Src):
– Framework.Application.Contracts: Defines command and query contracts and corresponding handlers (ICommand, IRequest, etc.).
– Framework.Application: Implements and orchestrates command/request buses with potential decorators (transactional, logging, etc.).
– Framework.AspNetCore: Contains ASP.NET Core integrations, middleware (exception, rate limiting, logging, images handling), configuration classes and extension methods.
– Other modules such as Framework.Authentication, Framework.Authorization, Framework.Caching (in multiple flavors: abstractions, configuration, dependency injection, DotnetCore, Redis), Framework.Config (with Autofac integration), Framework.Consul, Framework.Core (the core utility layer including domain events, logging, pagination, etc.), Framework.DataAccess (multiple implementations for various databases like ClickHouse, EF, Mongo, NH), Framework.Domain for domain model definitions, as well as messaging and event processing components (Framework.EasyNetQ, Framework.EventProcessor, Framework.MassTransit, Framework.Messages, Framework.Query, Framework.RabbitMQ, Framework.Kafka, Framework.Redis, Framework.Restful, Framework.Security, Framework.Sentry, Framework.Specification, Framework.Swagger), among many others.

- Data Access & Persistence:
– Several libraries exist to support various persistence strategies (ClickHouse, EF, Mongo, NH).
– They contain common patterns such as Unit of Work, Repository, DomainEvent persistence, and mapping configurations.

- Messaging and Event Handling:
– There are dedicated modules managing inter-service and event-driven communication (Kafka, RabbitMQ, MassTransit, EasyNetQ, and related idempotency modules).
– They include configuration modules, producer/consumer interfaces and implementations, and event transformation logic.

- Utility & Testing:
– Framework.Utility, Framework.Testing.Core modules handle cross-cutting utility functions and the testing infrastructure.
– Test projects in Code/Test validate implementations across various modules (for instance unit tests in Framework.Domain.Tests.Unit and Framework.Utility.Tests.Unit).

##### Relationship and Interactions

- How messaging components interact: applications or event processors publish messages through components in Framework.Messages, RabbitMQ, MassTransit, Kafka, etc.

- Use of dependency injection (e.g., in Framework.Config.Autofac) for decoupling the different modules.

- Decorator patterns found in the code (such as the transactional or logging decorators in the application layer).

##### Architectural Patterns and Design Principles

- Layered or modular architecture: Infrastructure (Data Access, Messaging, Logging), Application (command/query buses, decorators), and Presentation (ASP.NET Core integrations).

- Heavy use of interfaces (like ICommand, IRequest, IQueryHandler, etc.) for abstraction, which suggests an emphasis on dependency inversion and loose coupling.

- Pattern usage such as Controller/Middleware usage in ASP.NET Core, the Repository/Unit of Work pattern in data access modules, and event-driven designs in messaging/event processing libraries.

- Integration points for external services (e.g., Consul, Sentry, Minio, Hazelcast).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% High-level Project Node
    Project["Framework Project"]:::core

    %% Build & CI/CD
    subgraph "Build & CI/CD"
        BS("BuildScript"):::build
        BCmd("build.cmd"):::build
        BPs("build.ps1"):::build
        BSh("build.sh"):::build
        AP("Azure Pipeline"):::build
    end

    %% Core Framework Modules
    subgraph "Core Framework Modules"
        AC("App Contracts"):::core
        AL("Application Layer"):::core
        ASP("ASP.NET Core"):::core
        Auth("Authentication"):::core
        Authz("Authorization"):::core
        CA("Caching Abstractions"):::core
        CC("Caching Configuration"):::core
        CDI("Caching DI"):::core
        CDC("Caching DotnetCore"):::core
        CR("Caching Redis Ext"):::core
        Caching("Caching"):::core
        Conf("Config"):::core
        CAF("Config Autofac"):::core
        Consul("Consul"):::core
        CoreUtil("Core Utilities"):::core
        Domain("Domain Models"):::core
    end

    %% Data Access & Persistence
    subgraph "Data Access & Persistence"
        CH("ClickHouse CH"):::data
        CHM("ClickHouse Migrator"):::data
        CHMain("ClickHouse"):::data
        EF("Entity Framework"):::data
        Mongo("MongoDB"):::data
        NH("NHibernate"):::data
    end

    %% Messaging & Event Processing
    subgraph "Messaging & Event Processing"
        EN("EasyNetQ"):::messaging
        EP("Event Processor"):::messaging
        MT("MassTransit"):::messaging
        MTM("MassTransit Message"):::messaging
        Msg("Messages"):::messaging
        Q("Query"):::messaging
        RMQ("RabbitMQ"):::messaging
        Kafka("Kafka"):::messaging
    end

    %% External Integrations & Cross-Cutting
    subgraph "External Integrations & Cross-Cutting"
        SL("SeriLog Logging"):::external
        Rest("RESTful"):::external
        Sec("Security"):::external
        Sent("Sentry"):::external
        Spec("Specification"):::external
        Swagger("Swagger"):::external
        FileMinio("FileUpload Minio"):::external
        FileUpload("FileUpload"):::external
        Hazel("Hazelcast"):::external
        Rate("Rate Limiting"):::external
        Redis("Redis"):::external
    end

    %% Utilities & Testing
    subgraph "Utilities & Testing"
        Util("Utilities"):::utility
        TestCore("Testing Core"):::utility
        TestProj("Test Projects"):::utility
    end

    %% Idempotency
    subgraph "Idempotency"
        IdemMongo("Mongo Idempotency"):::idempotency
        IdemSql("SQL Idempotency"):::idempotency
        IdemCore("Core Idempotency Abstractions"):::idempotency
    end

    %% Connections from Project to major groups
    Project --> BS
    Project --> AC
    Project --> EF
    Project --> EN
    Project --> SL
    Project --> Util
    Project --> IdemCore

    %% Core Framework Relationships
    ASP -->|"calls"| AL
    AL -->|"implements"| AC
    AL -->|"injects"| CAF
    AL -->|"uses"| CoreUtil
    ASP -->|"auth"| Auth
    ASP -->|"auth"| Authz

    %% Data Access Relationships
    AL -->|"queries"| EF
    AL -->|"queries"| Mongo
    AL -->|"queries"| NH
    AL -->|"queries"| CHMain
    CH --> CHMain
    CHM --> CHMain

    %% Messaging Relationships
    AL -->|"publishes"| Msg
    Msg -->|"sends"| RMQ
    Msg -->|"sends"| Kafka
    Msg -->|"sends"| EN
    EP -->|"integrates"| MT
    EP -->|"integrates"| MTM
    %% ASP.NET additional external calls
    ASP -->|"limits"| Rate
    ASP -->|"docs"| Swagger

    %% Utilities & Testing Relationships
    TestProj -->|"tests"| CoreUtil
    TestCore -->|"tests"| CoreUtil
    CoreUtil -->|"uses"| Util
    CoreUtil -->|"domain"| Domain

    %% Click Events
    click BS "https://github.com/ehsanfaridi92/framework/tree/dotnet8/BuildScript"
    click BCmd "https://github.com/ehsanfaridi92/framework/blob/dotnet8/build.cmd"
    click BPs "https://github.com/ehsanfaridi92/framework/blob/dotnet8/build.ps1"
    click BSh "https://github.com/ehsanfaridi92/framework/blob/dotnet8/build.sh"
    click AP "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Framework-Azure-Pipeline.yaml"

    click AC "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Application.Contracts"
    click AL "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Application"
    click ASP "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.AspNetCore"
    click Auth "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Authentication"
    click Authz "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Authorization"
    click CA "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Caching.Extensions.Abstractions"
    click CC "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Caching.Extensions.Configuration"
    click CDI "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Caching.Extensions.DependencyInjection"
    click CDC "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Caching.Extensions.DotnetCore"
    click CR "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Caching.Extensions.Redis"
    click Caching "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Caching"
    click Conf "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Config"
    click CAF "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Config.Autofac"
    click Consul "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Consul"
    click CoreUtil "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Core"
    click Domain "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Domain"

    click CH "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.DataAccess.ClickHouse.CH"
    click CHM "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.DataAccess.ClickHouse.Migrator"
    click CHMain "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.DataAccess.Clickhouse"
    click EF "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.DataAccess.EF"
    click Mongo "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.DataAccess.Mongo"
    click NH "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.DataAccess.NH"

    click EN "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.EasyNetQ"
    click EP "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.EventProcessor"
    click MT "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.MassTransit"
    click MTM "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.MassTransit.Message"
    click Msg "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Messages"
    click Q "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Query"
    click RMQ "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.RabbitMQ"
    click Kafka "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Kafka"

    click SL "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Logging.SeriLog"
    click Rest "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Restful"
    click Sec "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Security"
    click Sent "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Sentry"
    click Spec "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Specification"
    click Swagger "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Swagger"
    click FileMinio "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.FileUpload.Minio"
    click FileUpload "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.FileUpload"
    click Hazel "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Hazelcast"
    click Rate "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.RateLimit"
    click Redis "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Redis"

    click Util "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Utility"
    click TestCore "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Testing.Core"
    click TestProj "https://github.com/ehsanfaridi92/framework/tree/dotnet8/Code/Test"

    click IdemMongo "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Idempotency.Mongo"
    click IdemSql "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Idempotency.Sql"
    click IdemCore "https://github.com/ehsanfaridi92/framework/blob/dotnet8/Code/Src/Framework.Idempotency"

    %% Styles
    classDef build fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
    classDef core fill:#AED6F1,stroke:#3498DB,stroke-width:2px;
    classDef data fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef messaging fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#E74C3C,stroke-width:2px;
    classDef utility fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef idempotency fill:#A3E4D7,stroke:#1ABC9C,stroke-width:2px;
```
