A lightweight command-line tool that analyzes CQRS command relationships within a .NET solution using the Roslyn compiler API.
In complex enterprise systems, especially those following the CQRS + MediatR pattern, it’s often difficult to see how commands interact with each other.
For example, executing one command may trigger several others — directly or indirectly — but these dependencies are hidden inside handler logic.
CQRS Flow Analyzer solves this by automatically detecting and visualizing these command invocation chains.
This allows you to:
- Quickly understand what other commands are triggered when a specific command runs.
- Identify side effects and dependencies before modifying an existing command.
- Speed up onboarding when joining a new or unfamiliar project.
- Improve confidence in code changes by seeing the impact scope visually.
The analyzer:
- Loads a
.slnfile using MSBuildWorkspace. - Scans all projects for classes implementing
IRequestHandler<TRequest, TResponse>(via Roslyn syntax trees). - Finds all usages of
mediator.Send(new SomeCommand(...))inside handler methods. - Builds a recursive tree of command-to-command relationships.
- Displays the result in a colored tree view in the console and
exports it to a.txtfile for documentation.
CQRS Command Flow
├── SubmitOrderCommand
│ ├── ValidateOrderCommand
│ │ └── NotifyWarehouseCommand
│ ├── ChargePaymentCommand
│ │ └── SendInvoiceCommand
│ └── UpdateInventoryCommand
│ └── NotifySupplierCommand
└── CancelOrderCommand
├── RefundPaymentCommand
└── ReleaseInventoryCommand
└── NotifyCustomerCommand
- Architectural Clarity – Understand your CQRS command flow at a glance.
- Onboarding Efficiency – New developers can learn system behavior quickly.
- Impact Analysis – Before refactoring or deleting a command, check what depends on it.
- Documentation Aid – Auto-generates readable command trees for Confluence or code reviews.
cfa "path-to-solution.sln"