Mature .NET systems converge on a feature-first shape where intentions are explicit, invariants live in the domain, and the HTTP layer becomes a thin adapter. That shape can be named REPR: Request > Entity > Processor > Response. It does not replace Clean Architecture or CQRS; it is what those ideas tend to produce when scaled across teams and time. This article articulates REPR as a foundational pattern and demonstrates a precise expression using FastEndpoints in modern .NET, keeping the surface small and the business logic central.

The goal is clarity, a slice per use-case, composed of an intent (Request), a truthful domain core (Entity), a use case script (Processor), and a consumer-shaped contract (Response). Controllers, service layers, and incidental abstractions fall away because the slice itself carries the meaning. The result is a codebase that reads by verbs rather than by layers, which is the natural unit of reasoning for product and engineering alike.

Why REPR Emerges from Clean Architecture and CQRS

Clean Architecture pushes dependencies inward and centres decisions in the domain. CQRS separates reads and writes to sharpen intent. Yet both leave open the practical question: What is the smallest useful unit of a feature? REPR answers with a compact pipeline. The Request captures intent without leaking storage concerns. The Entity enforces business rules and invariants. The Processor orchestrates precisely what the use-case demands and nothing more. The Response returns a business outcome suitable for its consumer, not an accidental snapshot of internal state.

This alignment reduces cognitive load. A feature has a single entry and a single exit, and the domain is the only place allowed to change truth. Cross-cutting concerns become pipeline steps around the Processor instead of boilerplate inside it. Teams scale by owning sets of verbs rather than slices of a layered cake.

The Feature Slice: Directory Shape and Mental Model

A coherent slice contains only what it needs, co-located for discoverability. An example for approving a Submission (the same structure fits quotes, orders, pricing, or claims):

Code
/Features/Submissions/Approve
Code
  ApproveSubmissionRequest.cs
Code
  ApproveSubmissionResponse.cs
Code
  ApproveSubmissionValidator.cs
Code
  ApproveSubmissionEndpoint.cs
Code
  ApproveSubmissionProcessor.cs
Code
  Submission.cs
Code
  ISubmissionRepository.cs
Code
  EfSubmissionRepository.cs

Each file is small and purposeful. The Endpoint adapts transport to intent. The Processor applies policy and coordinates domain work. The Entity owns invariants and protects truth. The repository is a narrow port that returns the shapes the domain needs.

The REPR Flow

The Request expresses what the caller wants. The Processor asks the Entity to perform domain operations under invariant checks. The Repository persists or projects as needed. The Response communicates the outcome in consumer terms. The HTTP or messaging edge is merely a conduit.

Request and Response: Intent and Outcome

Requests model intent; they are not transport bags or EF rows. Responses model what consumers need; they are not entities.

Code
// Request > intent, not storage schema.
Code
public sealed record ApproveSubmissionRequest(long SubmissionId, string ApprovedBy);
Code
Code
// Response > consumer-shaped business outcome.
Code
public sealed record ApproveSubmissionResponse(
Code
    long SubmissionId,
Code
    DateTime ApprovedAtUtc,
Code
    string ApprovedBy,
Code
    string StatusMessage);

Names should read like language in the domain. Versioning the Response is an explicit contract decision, not an accident.

Entity: The Only Place Allowed to Change Truth

Entities own invariants. Processors never toggle fields directly; they call domain methods that enforce rules atomically.

Code
public sealed class Submission(long id, DateTime createdAtUtc)
Code
{
Code
    public long Id { get; } = id;
Code
    public DateTime CreatedAtUtc { get; } = createdAtUtc;
Code
Code
    public bool IsApproved { get; private set; }
Code
    public DateTime? ApprovedAtUtc { get; private set; }
Code
    public string? ApprovedBy { get; private set; }
Code
Code
    public Result Approve(string approver, DateTime nowUtc)
Code
    {
Code
        if (IsApproved)
Code
            return Result.Fail("Submission is already approved.");
Code
Code
        if (string.IsNullOrWhiteSpace(approver))
Code
            return Result.Fail("Approver is required.");
Code
Code
        IsApproved  = true;
Code
        ApprovedAtUtc = nowUtc;
Code
        ApprovedBy  = approver;
Code
Code
        return Result.Ok();
Code
    }
Code
}

A small, explicit domain method prevents entire categories of drift, such as direct flag mutation scattered across handlers.

Repository Port: Narrow and Purposeful

Commands require Entities to enforce invariants; queries typically require projections. A port keeps the Processor independent of storage concerns.

Code
public interface ISubmissionRepository
Code
{
Code
    Task<Submission?> GetAsync(long id, CancellationToken ct);
Code
    Task SaveAsync(Submission Submission, CancellationToken ct);
Code
}

Implementation choices (EF Core, Dapper, external service) do not change the Processor surface. N+1 issues are solved inside the repository contract, not leaked into callers.

Processor: The Use-Case Script

The Processor composes the use-case: load, ask, change, persist, reply. It does not perform transport work or data access gymnastics; it orchestrates policy with the Entity.

Code
public interface IClock { DateTime UtcNow { get; } }
Code
public sealed class SystemClock : IClock { public DateTime UtcNow => DateTime.UtcNow; }
Code
Code
public sealed class ApproveSubmissionProcessor(ISubmissionRepository repo, IClock clock)
Code
{
Code
    public async Task<Result<ApproveSubmissionResponse>> Handle(ApproveSubmissionRequest req, CancellationToken ct)
Code
    {
Code
        var Submission = await repo.GetAsync(req.SubmissionId, ct);
Code
        if (Submission is null)
Code
            return Result.Fail<ApproveSubmissionResponse>("Submission not found.");
Code
Code
        var approved = Submission.Approve(req.ApprovedBy, clock.UtcNow);
Code
        if (approved.IsFailure)
Code
            return approved.Cast<ApproveSubmissionResponse>();
Code
Code
        await repo.SaveAsync(Submission, ct);
Code
Code
        return Result.Ok(new ApproveSubmissionResponse(
Code
            Submission.Id,
Code
            Submission.ApprovedAtUtc!.Value,
Code
            Submission.ApprovedBy!,
Code
            "Approved"));
Code
    }
Code
}

This class should remain short. If it grows, the Entity likely needs a new domain operation to absorb rules.

FastEndpoints: The Precise HTTP Adapter

FastEndpoints models the HTTP edge with minimal ceremony. The Endpoint accepts the Request and delegates to the Processor, returning a Response or an error mapping.

Code
using FastEndpoints;
Code
Code
public sealed class ApproveSubmissionEndpoint(ApproveSubmissionProcessor processor)
Code
    : Endpoint<ApproveSubmissionRequest, ApproveSubmissionResponse>
Code
{
Code
    public override void Configure()
Code
    {
Code
        Post("/Submission/Submissions/{SubmissionId:long}/approve");
Code
        Version(1);
Code
        Summary(s =>
Code
        {
Code
            s.Summary = "Approve a Submission";
Code
            s.Description = "Approves a Submission if business rules allow.";
Code
            s.ExampleRequest = new ApproveSubmissionRequest(42, "Approver01");
Code
        });
Code
    }
Code
Code
    public override async Task HandleAsync(ApproveSubmissionRequest req, CancellationToken ct)
Code
    {
Code
        var result = await processor.Handle(req, ct);
Code
        if (result.IsSuccess)
Code
            await SendOkAsync(result.Value, ct);
Code
        else
Code
            await SendErrorsAsync(400, result.Message);
Code
    }
Code
}

The Endpoint remains transport-centric. It does not read data stores, compute business rules, or create hidden dependencies.

Validation: Polite at the Edge, Strict in the Core

Transport-level validation protects the Processor from malformed input, and invariants in the Entity protect the core from impossible states.

Code
using FastEndpoints;
Code
using FluentValidation;
Code
Code
public sealed class ApproveSubmissionValidator : Validator<ApproveSubmissionRequest>
Code
{
Code
    public ApproveSubmissionValidator()
Code
    {
Code
        RuleLevelCascadeMode = CascadeMode.Stop;
Code
        RuleFor(r => r.SubmissionId).GreaterThan(0);
Code
        RuleFor(r => r.ApprovedBy).NotEmpty().MaximumLength(200);
Code
    }
Code
}

This split is essential. It prevents duplication and avoids shifting business rules into validators where they cannot be enforced consistently.

Program Setup: Small Surface, Clear Wiring

Minimal registration with DI and FastEndpoints keeps the composition explicit and discoverable.

Code
var builder = WebApplication.CreateBuilder(args);
Code
Code
builder.Services.AddDbContext<MyDbContext>(...);
Code
builder.Services.AddScoped<ISubmissionRepository, EfSubmissionRepository>();
Code
builder.Services.AddScoped<ApproveSubmissionProcessor>();
Code
builder.Services.AddSingleton<IClock, SystemClock>();
Code
Code
builder.Services.AddFastEndpoints();
Code
builder.Services.AddFluentValidationAutoValidation();
Code
builder.Services.AddSwaggerDoc();
Code
Code
var app = builder.Build();
Code
Code
app.UseAuthorization();
Code
app.UseFastEndpoints();
Code
app.UseOpenApi();
Code
app.UseSwaggerUi3();
Code
Code
app.Run();

New slices add themselves by file convention; the application is composed of features rather than layers.

Query Slices: Reads Benefit Even More

Read models become explicit, projection-first, and immune to accidental IQueryable leakage. The Request captures query intent, the Processor (or Endpoint for simple reads) projects to a consumer shape.

Code
public sealed record GetSubmissionsRequest(int Page = 1, int PageSize = 20);
Code
Code
public sealed record SubmissionSummary(long Id, bool IsApproved, DateTime CreatedAtUtc);
Code
Code
public sealed class GetSubmissionsEndpoint(MyDbContext db)
Code
    : Endpoint<GetSubmissionsRequest, IReadOnlyList<SubmissionSummary>>
Code
{
Code
    public override void Configure()
Code
    {
Code
        Get("/uwSubmission/Submissions");
Code
        Version(1);
Code
    }
Code
Code
    public override async Task HandleAsync(GetSubmissionsRequest req, CancellationToken ct)
Code
    {
Code
        if (req.Page <= 0 || req.PageSize is <= 0 or > 200)
Code
        {
Code
            await SendErrorsAsync(400, "Invalid paging");
Code
            return;
Code
        }
Code
Code
        var data = await db.Submissions
Code
            .AsNoTracking()
Code
            .OrderByDescending(h => h.CreatedAtUtc)
Code
            .Skip((req.Page - 1) * req.PageSize)
Code
            .Take(req.PageSize)
Code
            .Select(h => new SubmissionSummary(h.Id, h.IsApproved, h.CreatedAtUtc))
Code
            .ToListAsync(ct);
Code
Code
        await SendOkAsync(data, ct);
Code
    }
Code
}

Read and write slices share the same mental model and directory shape, simplifying navigation and ownership.

Cross-Cutting Concerns: Pipeline, Not Boilerplate

In REPR, cross-cutting concerns belong around the Processor as pipeline steps or behaviours, not inside it. FastEndpoints supports pre/post processors at the HTTP edge; a mediator or composition pattern can provide behaviours around the Processor for logging, correlation, authorisation, idempotency, and resilience.

A simple correlation pre-processor:

Code
public sealed class CorrelationPreProcessor<TReq, TRes>(
Code
    ILogger<CorrelationPreProcessor<TReq,TRes>> log)
Code
    : IPreProcessor<Endpoint<TReq,TRes>>
Code
    where TReq : notnull
Code
{
Code
    public Task PreProcessAsync(Endpoint<TReq,TRes> ep, CancellationToken ct)
Code
    {
Code
        var cid = ep.HttpContext.TraceIdentifier;
Code
        ep.HttpContext.Items["cid"] = cid;
Code
        log.LogInformation("Handling {Request} cid={Cid}", typeof(TReq).Name, cid);
Code
        return Task.CompletedTask;
Code
    }
Code
}

Applied globally or per endpoint, this keeps transport concerns at the edge and business concerns in the core.

Events and Outbox: Facts Out, Reliably

Many command slices emit domain events in addition to returning a Response. Pair REPR with an outbox so that event recording is transactional with state changes. The Processor writes the Entity and the outbox record within the same unit of work. A background dispatcher publishes from the outbox. The Response may carry a correlation ID for traceability without tying the API to event schemas.

This pattern aligns neatly with REPR’s flow: intent in, invariant-checked state change, facts recorded, outcome returned.

Testing: Small, Fast, and Honest

REPR improves testability by shrinking surface areas. Entities are tested directly via domain methods. Processors are tested with fake repositories and clocks, asserting on Result<T> and domain state. Endpoints can be verified with FastEndpoints’ in-memory host where HTTP-level assurance is required, but business logic never depends on a web server to be testable.

A Processor test is concise and meaningful:

Code
[Fact]
Code
public async Task Approve_Sets_State_And_Returns_Response()
Code
{
Code
    var now = new DateTime(2025, 10, 24, 12, 0, 0, DateTimeKind.Utc);
Code
    var clock = Substitute.For<IClock>(); clock.UtcNow.Returns(now);
Code
Code
    var Submission = new Submission(42, now.AddDays(-1));
Code
    var repo = Substitute.For<ISubmissionRepository>();
Code
    repo.GetAsync(42, Arg.Any<CancellationToken>()).Returns(Submission);
Code
Code
    var processor = new ApproveSubmissionProcessor(repo, clock);
Code
Code
    var result = await processor.Handle(new ApproveSubmissionRequest(42, "PK"), CancellationToken.None);
Code
Code
    result.IsSuccess.ShouldBeTrue();
Code
    Submission.IsApproved.ShouldBeTrue();
Code
    Submission.ApprovedAtUtc.ShouldBe(now);
Code
    Submission.ApprovedBy.ShouldBe("PK");
Code
    await repo.Received(1).SaveAsync(Submission, Arg.Any<CancellationToken>());
Code
}

The test demonstrates intent, rule enforcement, and persistence orchestration without scaffolding overhead.

Anti-Patterns to Avoid

A few pitfalls undermine the benefits:

  • Requests that mirror database rows rather than intent encourage accidental coupling and bloat.

  • Processors that toggle fields directly instead of calling domain methods bypass invariants.

  • Repositories that return IQueryable leak persistence concerns and invite N+1 issues outside the boundary.

  • Responses that expose Entities create fragile contracts and accidental internal coupling.

  • Generic “BaseRepository<T>” or “Service” classes that centralise convenience instead of domain language lead to anaemic designs.

REPR’s strength is clarity; resist abstractions that obscure intent.

Impact and Ownership

Teams reason by verbs and outcomes. PRs review faster when a slice reads like a story, Request, Processor, Response, with invariants visible in an Entity. Observability improves because logs and metrics align with Request types and semantic operations instead of raw URLs. Ownership maps to features rather than controllers or horizontal layers, enabling autonomous delivery without accidental contention.

REPR is not a framework and does not require a mediator, controller, or a particular storage engine. It is the minimal shape a serious codebase adopts when Clean Architecture and CQRS are applied with discipline and scaled across a product’s lifetime. Expressed with FastEndpoints, the HTTP edge becomes quiet and intention-based, and the domain regains custody of truth.

The practical move is simple: for the next non-trivial feature, create a slice named for the verb. Write the Request so the intent is explicit. Put rules in an Entity method. Keep the Processor short and orchestral. Return a Response that a consumer would actually want. Repeat until the architecture fades into the furniture and only the product remains visible.