PouryaKit.Modularity 0.1.0-preview.1

This is a prerelease version of PouryaKit.Modularity.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package PouryaKit.Modularity --version 0.1.0-preview.1
                    
NuGet\Install-Package PouryaKit.Modularity -Version 0.1.0-preview.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PouryaKit.Modularity" Version="0.1.0-preview.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PouryaKit.Modularity" Version="0.1.0-preview.1" />
                    
Directory.Packages.props
<PackageReference Include="PouryaKit.Modularity" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PouryaKit.Modularity --version 0.1.0-preview.1
                    
#r "nuget: PouryaKit.Modularity, 0.1.0-preview.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PouryaKit.Modularity@0.1.0-preview.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PouryaKit.Modularity&version=0.1.0-preview.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=PouryaKit.Modularity&version=0.1.0-preview.1&prerelease
                    
Install as a Cake Tool

PouryaKit.Modularity

NuGet .NET 10 License: MIT

PouryaKit.Modularity

Modules for a Host. A Module is a business boundary that declares what it needs and offers in one public class, its Composition Root, and keeps everything else internal. Anything outside it, an endpoint, a job, another Module or a test, runs one of its Operations through its Gateway and passes an Operation Context that says which Actor it runs for.

Install

dotnet add package PouryaKit.Modularity --prerelease

When to use it

  • You are writing a Module's Composition Root, or composing the Host from its Modules.
  • Code outside a Module needs to run one of its commands or queries.
  • One Module needs an answer from another before its Operation can go on.
  • A Host fails when it is built or started, and you want to know which check stopped it.

It builds on PouryaKit.Cqrs. A Host with a single Module may leave it out, as the monolith template does until a second Module arrives.

Quick start

Add each Module to the Host:

builder.AddPouryaKitModules(modules => modules.Add<InventoryModule>());

Declare the Module in its Composition Root, as the Proving Sample's Billing does:

public sealed class BillingModule : IModuleDefinition
{
    public void Configure(ModuleBuilder module)
    {
        module.UsePouryaKitPostgres<BillingDbContext>(connectionName: "app", schema: "billing");
        module.AddPouryaKitCqrs();
        module.Subscribe<ProductCreatedV1, OpenPriceListIntegrationEventHandler>(
            "billing.product-created"
        );
        module.Subscribe<AccountOpenedV1, OpenWelcomeQuoteIntegrationEventHandler>(
            "billing.account-opened"
        );
        module.AddPouryaKitDelayedCommand<ExpireQuoteCommand>("billing.expire-quote");
    }
}

Run an Operation through its Gateway, with the context of the running request. This endpoint also needs PouryaKit.Web, which begins the request's Operation and supplies ToHttpResult():

routes.MapGet(
    "/stock-items/{productId}",
    async (
        Guid productId,
        OperationContext context,
        IGatewayProcessor<InventoryModule> inventory,
        CancellationToken cancellationToken
    ) =>
        (
            await inventory.QueryAsync(
                new GetStockItemQuery(productId),
                context,
                cancellationToken
            )
        ).ToHttpResult()
);

What you get

  • One public class per Module, with everything else internal, and architecture tests that hold the boundary.
  • IGatewayProcessor<TModule>, the only way in: each call is one Operation in a scope of its own.
  • Every Operation belongs to one Module, which owns what it declares.
  • A Host that fails when it is built or started, naming what its composition got wrong, before it serves.

There is no anonymous or default Actor. Every Gateway call needs an Operation Context: create a new one for each Operation that starts work, with Actor.Person or a named Actor.System, and pass Continue() of the running context for work an Operation causes.

Learn more

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on PouryaKit.Modularity:

Package Downloads
PouryaKit.AI

The Host's one chat client for OpenAI, Azure OpenAI or Ollama, a Module's commands and queries as Gateway tools that run as Operations, and agents and workflows over that client.

PouryaKit.Testing

Test against the hosted application: PostgreSQL in a Testcontainers container, data reset between tests, Operations through a Gateway, deliveries awaited and dead letters replayed.

PouryaKit.Reporting.Module

The Kit's report Module: report jobs generated in the background, stored through the Host's file storage and served to their requester by a time-limited link.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-preview.2 91 11/1/2026
0.1.0-preview.1 97 10/31/2026
0.1.0-preview.0.28 85 10/26/2026