# pakanrahmani/framework architecture

> Architecture diagram of the GitHub repository pakanrahmani/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/pakanrahmani/framework
- Repository: https://github.com/pakanrahmani/framework

## Overview

##### Main Components
- Build & Infrastructure: Include the BuildScript directory, which handles build automation (using NUKE, .csproj files, and associated build scripts), showing the integration with CI/CD pipelines.
- Core Modules: This includes the fundamental assemblies under Code/Src/Framework.Core (handling chaining of handlers, events, exceptions, logging, and utilities) along with Domain and Messaging modules under Code/Src/Framework.Domain and Code/Src/Framework.Messages.
- Application and API Integration: Under Code/Src/Framework.Application and Framework.AspNetCore, you have components that manage command bus execution, middleware, HTTP context features, and conventions tailored to web applications.
- Cross-Cutting and Infrastructure Services:
- Authorization (Framework.Authorization)
- Configuration and Dependency Injection (Framework.Config and Framework.Config.Autofac)
- Logging (e.g., Framework.Logging.SeriLog)
- Testing utilities (Framework.Testing.Core)
- Data Access Layer: This is split into several strategies:
- Entity Framework (EF)
- MongoDB
- NHibernate (NH)
Each module under Code/Src/Framework.DataAccess.* means you have a clear separation in persistence technologies.
- Messaging and Event Handling: Components for message bus, event publishing, and distributed events are evident in:
- Framework.MassTransit, Framework.RabbitMQ, Framework.Kafka, and Framework.EasyNetQ.
- Utility and Extensions: Framework.Utility and additional helpers/extensions included across modules.
- Miscellaneous Modules: Additional areas such as FileUpload, Swagger integration (Framework.Swagger), RESTful builders (Framework.Restful), and Specification patterns (Framework.Specification).

##### Architectural Patterns and Principles
- Separation of Concerns and Dependency Injection: Emphasize the use of dependency injection (Autofac modules, configuration loaders) to decouple different layers.
- CQRS and Event-Driven Architecture: Explicitly show command and query separation as well as event aggregation and publication that underpin many of the modules.
- Cross-cutting Services: Components like Authorization and Logging should be noted as aspects that weave into numerous other modules.

##### Essential Elements
- A clearly labeled build/infrastructure block at the top (or on the side) showing BuildScript and CI/CD integration.
- Modules for both the application layer (Framework.Application and Framework.AspNetCore) and the core domain logic (Framework.Core, Framework.Domain, and Framework.Specification).
- Messaging components such as RabbitMQ, Kafka, MassTransit, and EasyNetQ placed near a “Messaging/Event Handling” block.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build & Infrastructure Layer
    subgraph "Build & Infrastructure"
        BS["Build.cs"]:::build
        BP["_build.csproj"]:::build
    end

    %% Core Modules Layer
    subgraph "Core Modules"
        Core["Framework.Core"]:::core
        Domain["Framework.Domain"]:::core
        Messages["Framework.Messages"]:::core
    end

    %% Application and API Integration Layer
    subgraph "Application and API Integration"
        App["Framework.Application"]:::application
        AspNet["Framework.AspNetCore"]:::application
    end

    %% Cross-Cutting Services Layer
    subgraph "Cross-Cutting Services"
        Auth["Framework.Authorization"]:::crosscut
        Config["Framework.Config"]:::crosscut
        Autofac["Framework.Config.Autofac"]:::crosscut
        Serilog["Framework.Logging.SeriLog"]:::crosscut
        Testing["Framework.Testing.Core"]:::crosscut
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        EF["Framework.DataAccess.EF"]:::data
        Mongo["Framework.DataAccess.Mongo"]:::data
        NH["Framework.DataAccess.NH"]:::data
    end

    %% Messaging and Event Handling Layer
    subgraph "Messaging and Event Handling"
        MassTransit["Framework.MassTransit"]:::messaging
        RabbitMQ["Framework.RabbitMQ"]:::messaging
        Kafka["Framework.Kafka"]:::messaging
        EasyNetQ["Framework.EasyNetQ"]:::messaging
    end

    %% Utilities and Miscellaneous Layer
    subgraph "Utilities and Miscellaneous"
        Utility["Framework.Utility"]:::misc
        FileUpload["Framework.FileUpload"]:::misc
        Swagger["Framework.Swagger"]:::misc
        Restful["Framework.Restful"]:::misc
        Specification["Framework.Specification"]:::misc
    end

    %% Connections between Layers
    %% Build triggers core build
    BP -->|"builds"| Core

    %% Core Modules internal relationships
    Core -->|"handles"| Domain
    Core -->|"publishes"| Messages

    %% Application and API Integration flow
    AspNet -->|"HTTP_Request"| App
    App -->|"executes"| Core

    %% Application uses Cross-Cutting Services
    App -->|"DI_Config"| Config
    Autofac -->|"injects"| App
    Config -->|"configures"| Core
    Config -->|"configures"| App
    Serilog -->|"logs"| Core
    Serilog -->|"logs"| App
    Auth -->|"authorizes"| AspNet
    Testing -->|"tests"| Core

    %% Core depends on Data Access
    Core -->|"data_access"| EF
    Core -->|"data_access"| Mongo
    Core -->|"data_access"| NH

    %% Core publishes events to Messaging systems
    Core -->|"event_bus"| MassTransit
    Core -->|"event_bus"| RabbitMQ
    Core -->|"event_bus"| Kafka
    Core -->|"event_bus"| EasyNetQ

    %% API Integration extends with Utilities and Miscellaneous modules
    AspNet -->|"integrates_with"| Swagger
    AspNet -->|"integrates_with"| Restful
    AspNet -->|"integrates_with"| FileUpload
    AspNet -->|"integrates_with"| Specification
    Core -->|"extends_with"| Utility

    %% Click Events
    click BS "https://github.com/pakanrahmani/framework/blob/master/BuildScript/Build.cs"
    click BP "https://github.com/pakanrahmani/framework/blob/master/BuildScript/_build.csproj"
    click Core "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.Core"
    click Domain "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.Domain"
    click Messages "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.Messages"
    click App "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.Application"
    click AspNet "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.AspNetCore"
    click Auth "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.Authorization"
    click Config "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.Config"
    click Autofac "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.Config.Autofac"
    click Serilog "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.Logging.SeriLog"
    click Testing "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.Testing.Core"
    click EF "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.DataAccess.EF"
    click Mongo "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.DataAccess.Mongo"
    click NH "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.DataAccess.NH"
    click MassTransit "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.MassTransit"
    click RabbitMQ "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.RabbitMQ"
    click Kafka "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.Kafka"
    click EasyNetQ "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.EasyNetQ"
    click Utility "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.Utility"
    click FileUpload "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.FileUpload"
    click Swagger "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.Swagger"
    click Restful "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.Restful"
    click Specification "https://github.com/pakanrahmani/framework/blob/master/Code/Src/Framework.Specification"

    %% Styles
    classDef build fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef core fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef application fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef crosscut fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
    classDef data fill:#fcf3cf,stroke:#f39c12,stroke-width:2px;
    classDef messaging fill:#d2b4de,stroke:#8e44ad,stroke-width:2px;
    classDef misc fill:#e8daef,stroke:#af7ac5,stroke-width:2px;
```
