Skip to content

Getting Started

  1. Install the Core Library

    Provides the essential types needed for domain modeling and use case implementation (Value Object, Entity, Fin<T>, CQRS interfaces). Required for all projects.

    Terminal window
    dotnet add package Functorium
  2. Install Source Generators

    Provides the [GenerateObservablePort], [GenerateEntityId], and CtxEnricherGenerator source generators. Add to your Adapter project.

    Terminal window
    dotnet add package Functorium.SourceGenerators
  3. Install Testing Utilities

    Provides testing utilities including architecture rule validation and structured log testing. Add to your test project.

    Terminal window
    dotnet add package Functorium.Testing

The first thing to try after installing Functorium is an Always-valid Value Object. The following is a minimal implementation of a Value Object representing an email address.

public sealed partial class Email : SimpleValueObject<string>
{
public const int MaxLength = 320;
private Email(string value) : base(value) { }
public static Fin<Email> Create(string? value) =>
CreateFromValidation(Validate(value), v => new Email(v));
public static Validation<Error, string> Validate(string? value) =>
ValidationRules<Email>
.NotNull(value)
.ThenNotEmpty()
.ThenNormalize(v => v.Trim().ToLowerInvariant())
.ThenMaxLength(MaxLength);
}

The Create method returns Fin<Email>. For valid input, an Email instance is returned; for invalid input, a structured error code (such as DomainErrors.Email.Empty) is returned. No exceptions are thrown.

For detailed Value Object implementation patterns, see the Value Objects Guide.

Learn Functorium’s core concepts through step-by-step hands-on exercises.

TutorialTopicExercises
Functional Value Object ImplementationValue Object, validation, immutability29
Specification PatternSpecification, Expression Tree18
CQRS Repository PatternCQRS, Repository, Query Adapter22
Usecase Pipeline ConstraintsGeneric variance, IFinResponse, Pipeline constraints20
Architecture Rule TestingArchitecture rules, ClassValidator16
Source Generator ObservabilitySource Generator, Observable wrapper
Release Note AutomationAI automation, release notes

Functorium provides OpenTelemetry-based 3-Pillar observability (Logging, Metrics, Tracing). All observability fields use snake_case + dot notation for consistency with OpenTelemetry semantic conventions. The Command Pipeline (7 stages) and Query Pipeline (8 stages) automatically apply instrumentation to all use cases, and the CtxEnricher Source Generator automatically propagates business context (ctx.* fields) to Logging and Tracing.

Functorium Observability

Here is a recommended learning path for making the most of Functorium.