> For the complete documentation index, see [llms.txt](https://brightercommand.gitbook.io/paramore-brighter-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://brightercommand.gitbook.io/paramore-brighter-documentation/darker/querypipeline/darkerandbrighterpipelines.md).

# Darker and Brighter Pipelines

Darker's query pipeline shares many similarities with Brighter's request pipeline, as both implement the same Russian Doll Model for middleware composition.

> **Explanation** · Applies to **Darker V4** · Prerequisites: [Query Pipeline and Decorators](/paramore-brighter-documentation/darker/querypipeline.md)

Darker's query pipeline shares many similarities with [Brighter's request pipeline](/paramore-brighter-documentation/commands-handlers-and-pipelines/buildingapipeline.md), as both implement the same Russian Doll Model for middleware composition. However, there are some key differences to be aware of when working with both frameworks.

## Darker and Brighter Pipeline Similarities

**Russian Doll Model:** Both frameworks use the same pipeline architecture where each handler/decorator wraps the next one in the chain, allowing cross-cutting concerns to execute before and after the core handler logic.

**Attribute-Based Ordering:** Both use attributes with step numbers to control decorator execution order:

```csharp
// ...
// Brighter
[RequestLogging(1)]
[UsePolicy("RetryPolicy", 2)]
public override Task<AddGreetingResponse> HandleAsync(AddGreetingCommand command, ...)

// Darker
[QueryLogging(1)]
[RetryableQuery(2, "DefaultCircuitBreaker")]
public override Task<string> ExecuteAsync(GetPersonNameQuery query, ...)
```

**Policy Integration:** Both integrate with Polly for resilience policies (retry, circuit breaker, timeout).

**Extensible Architecture:** Both support custom decorators for application-specific cross-cutting concerns.

## Darker and Brighter Pipeline Differences

**Return Values:**

* **Darker**: Query handlers return results (`TResult`), and the pipeline preserves and returns these results
* **Brighter**: Command handlers typically return `void` or the command itself; events are used to signal results

**External Bus Support:**

* **Brighter**: Supports external messaging through service activators, message mappers, and external bus integration
* **Darker**: Focuses on in-process query handling only; no external messaging support

**Decorator Focus:**

* **Darker**: Decorators are query-specific (QueryLogging, RetryableQuery, FallbackPolicy)
* **Brighter**: Decorators are request-specific (RequestLogging, UsePolicy, UseInbox, UseOutbox)

**Use Cases:**

* **Darker**: Read-side operations, queries that don't change state
* **Brighter**: Write-side operations, commands that change state, event publishing

When using both Brighter and Darker together in a CQRS architecture, you'll apply similar patterns but with framework-specific decorators. For more information on using both frameworks together, see [CQRS with Brighter and Darker](/paramore-brighter-documentation/understanding-brighter/cqrswithbrighteranddarker.md).

## Further Reading

* [Query Pipeline and Decorators](/paramore-brighter-documentation/darker/querypipeline.md) - Darker's pipeline in full
* [Building a Pipeline of Request Handlers](/paramore-brighter-documentation/commands-handlers-and-pipelines/buildingapipeline.md) - Brighter's pipeline in full
* [CQRS with Brighter and Darker](/paramore-brighter-documentation/understanding-brighter/cqrswithbrighteranddarker.md) - Why there are two pipelines at all


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://brightercommand.gitbook.io/paramore-brighter-documentation/darker/querypipeline/darkerandbrighterpipelines.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
