Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f99697a
Add documentation prompts for Reactive Domain library
Apr 15, 2025
f9b8082
Add comprehensive documentation for Reactive Domain library
Apr 16, 2025
7734833
Improve documentation navigation with learning path and next/previous…
Apr 16, 2025
ba93c45
Add component navigation with next/previous links
Apr 16, 2025
3f6bcfc
Add documentation and project status badges to README
Apr 16, 2025
e91ef8b
Address PR #169 review feedback: Update repository references and enh…
May 3, 2025
8677ee5
Removed the doc-prompt ai todo list from the project
May 3, 2025
aa05447
Delete doc-prompt.md
leopoldodonnell May 3, 2025
24f0f1a
Add index for key types including ReadModelBase, MessageBuilder, Comm…
May 3, 2025
96bd168
t pull --no-rebase origin reactive-documentation
May 3, 2025
601a903
Enhanced documentation with detailed descriptions and examples, added…
May 3, 2025
dca86f9
Add code example files to fix broken links in documentation
May 3, 2025
2c03ad8
Add remaining code examples to complete documentation
May 3, 2025
aa3a79b
Add documentation for EventRecorder and EventDrivenStateMachine classes
May 3, 2025
f46a067
Fix documentation links to point to ReactiveDomain organization and c…
May 11, 2025
aa654aa
Document component relationships with new architecture section and cr…
May 11, 2025
0792564
Fix code examples to use RaiseEvent() instead of Apply() for creating…
May 11, 2025
b23bbd7
Enhance architecture documentation with detailed CQRS and Event Sourc…
May 11, 2025
eae813e
Improve terminology consistency and technical accuracy across documen…
May 11, 2025
21c77c4
Complete API reference enhancements with comprehensive documentation …
May 11, 2025
33df182
Add comprehensive real-world examples for banking, e-commerce, and in…
May 11, 2025
582b9bd
Improve documentation navigation and structure with comprehensive cro…
May 11, 2025
97f8667
Enhance learning resources with comprehensive learning path and troub…
May 11, 2025
0e0546e
not needed
May 11, 2025
5c48637
Add comprehensive documentation for Event-Driven State Machine
May 11, 2025
1ef0bbf
Fix MessageBuilder documentation to clarify correlation tracking requ…
May 11, 2025
6035ff2
Update command.md to use MessageBuilder.From(source).Build() syntax i…
May 12, 2025
d232936
Update aggregate-root.md to use MessageBuilder.From(source).Build() s…
May 12, 2025
33309f8
Update event.md to use MessageBuilder.From(source).Build() syntax ins…
May 12, 2025
6872ea6
Update event handling documentation to match best practices
May 12, 2025
ad7750e
Update command processing documentation to match best practices
May 12, 2025
b658357
Update aggregate implementation documentation to reflect best practices
May 12, 2025
7f8ee64
Update repository documentation to reflect best practices and modern …
May 12, 2025
d423074
Update ReadModelBase and IReadModelRepository documentation with mode…
May 12, 2025
cdd0b8f
Complete CQRS Implementation documentation with query handling and ev…
May 12, 2025
88b7e16
Complete event sourcing patterns and saga implementation patterns doc…
May 12, 2025
221eaf6
Add comprehensive error handling patterns documentation
May 12, 2025
cbf60f8
Add comprehensive testing patterns documentation
May 12, 2025
f768353
Enhance test fixture examples in testing patterns documentation
May 12, 2025
5d4728a
Update Reactive Domain documentation with modern best practices
May 12, 2025
b78e19f
remove the checklist from git
May 12, 2025
78548cc
Fix Mermaid diagram syntax in component-relationships.md
May 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ ClientBin/
*.publishsettings
node_modules/
orleans.codegen.cs
todo.md

# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[![Build status](https://ci.appveyor.com/api/projects/status/oir89k5nyyouqtsm?svg=true)](https://ci.appveyor.com/project/jageall/reactive-domain)
[![Build Status](https://travis-ci.org/linedata/reactive-domain.svg?branch=master)](https://travis-ci.org/linedata/reactive-domain)
[![Build Status](https://travis-ci.org/ReactiveDomain/reactive-domain.svg?branch=master)](https://travis-ci.org/ReactiveDomain/reactive-domain)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](code_of_conduct.md)
[![Documentation](https://img.shields.io/badge/docs-latest-brightgreen.svg)](https://leopoldodonnell.github.io/reactive-domain/)
[![Documentation](https://img.shields.io/badge/docs-latest-brightgreen.svg)](https://reactivedomain.github.io/reactive-domain/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This points to a URL that doesn't exist

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![NuGet](https://img.shields.io/nuget/v/ReactiveDomain.svg)](https://www.nuget.org/packages/ReactiveDomain/)
[![GitHub stars](https://img.shields.io/github/stars/leopoldodonnell/reactive-domain.svg)](https://github.com/leopoldodonnell/reactive-domain/stargazers)
[![GitHub issues](https://img.shields.io/github/issues/leopoldodonnell/reactive-domain.svg)](https://github.com/leopoldodonnell/reactive-domain/issues)
[![GitHub stars](https://img.shields.io/github/stars/ReactiveDomain/reactive-domain.svg)](https://github.com/ReactiveDomain/reactive-domain/stargazers)
[![GitHub issues](https://img.shields.io/github/issues/ReactiveDomain/reactive-domain.svg)](https://github.com/ReactiveDomain/reactive-domain/issues)

# Reactive Domain

Expand Down
39 changes: 19 additions & 20 deletions doc-prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,25 @@ Use the following prompts to create comprehensive documentation for the Reactive

Create a table of contents for the documentation, including:

1. Overview
2. Core Concepts
3. Component Documentation
4. Interface Documentation
5. Usage Patterns
6. Code Examples
7. Troubleshooting Guide
8. API Reference
9. Architecture Guide
10. Migration Guide
11. Glossary
12. FAQ
13. Deployment Guide
14. Performance Optimization Guide
15. Security Guide
16. Integration Guide
17. Video Tutorial Script
18. Workshop Materials
19. Documentation Structure

1. [x] Overview
2. [x] Core Concepts
3. [x] Component Documentation (partially complete)
4. [x] Interface Documentation (partially complete)
5. [x] Usage Patterns
6. [x] Code Examples (structure only)
7. [x] Troubleshooting Guide
8. [x] API Reference (partially complete)
9. [x] Architecture Guide
10. [x] Migration Guide
11. [x] Glossary
12. [x] FAQ
13. [x] Deployment Guide
14. [x] Performance Optimization Guide
15. [x] Security Guide
16. [x] Integration Guide
17. [x] Video Tutorial Script
18. [x] Workshop Materials
19. [x] Documentation Structure

## Overview Prompt

Expand Down
163 changes: 163 additions & 0 deletions docs/api-reference/types/command.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Command

[← Back to API Reference](../README.md) | [← Back to Table of Contents](../../README.md)

`Command` is a base class in Reactive Domain that implements the `ICorrelatedMessage` interface and serves as the foundation for all command messages in the system.

## Overview

Commands in Reactive Domain represent requests for the system to perform an action. They are part of the write side of the CQRS pattern and typically result in state changes. The `Command` base class provides common functionality for all command implementations, including correlation and causation tracking.

## Class Definition

```csharp
public abstract class Command : ICommand, ICorrelatedMessage
{
public Guid MsgId { get; }
public Guid CorrelationId { get; }
public Guid CausationId { get; }

protected Command()
{
MsgId = Guid.NewGuid();
CorrelationId = MsgId;
CausationId = MsgId;
}

protected Command(Guid correlationId, Guid causationId)
{
MsgId = Guid.NewGuid();
CorrelationId = correlationId;
CausationId = causationId;
}
}
```

## Key Features

- **Message Identity**: Provides a unique `MsgId` for each command
- **Correlation Tracking**: Implements `ICorrelatedMessage` for tracking related messages
- **Immutability**: Ensures commands are immutable after creation
- **Type Safety**: Provides a type-safe base for all command implementations

## Usage

### Defining a Command

To create a new command type, inherit from the `Command` base class:

```csharp
public class CreateAccount : Command
{
public readonly Guid AccountId;
public readonly string AccountNumber;
public readonly string CustomerName;

public CreateAccount(Guid accountId, string accountNumber, string customerName)
: base()
{
AccountId = accountId;
AccountNumber = accountNumber;
CustomerName = customerName;
}

// Constructor for correlated commands
public CreateAccount(Guid accountId, string accountNumber, string customerName,
Guid correlationId, Guid causationId)
: base(correlationId, causationId)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This overload of the base ctor should not be used explicitly. Use the MessageBuilder factory to set correlation and causation IDs. Most classes that inherit from Command will implicitly use the default ctor.

AccountId = accountId;
AccountNumber = accountNumber;
CustomerName = customerName;
}
}
```

### Using MessageBuilder with Commands

It's recommended to use the `MessageBuilder` factory to create commands with proper correlation:

```csharp
// Create a new command that starts a correlation chain
var createCommand = MessageBuilder.New(() => new CreateAccount(
Guid.NewGuid(),
"ACC-123",
"John Doe"
));

// Create a command from an existing message
var depositCommand = MessageBuilder.From(createCommand, () => new DepositFunds(
((CreateAccount)createCommand).AccountId,
100.00m
));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use .From(createCommand).Build(...) here.

```

### Handling Commands

Commands are typically handled by command handlers:

```csharp
public class CreateAccountHandler : ICommandHandler<CreateAccount>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is atypical. A class that handles commands will typically implement IHandleCommand<T> for each type that it handles.

{
private readonly ICorrelatedRepository _repository;

public CreateAccountHandler(ICorrelatedRepository repository)
{
_repository = repository;
}

public void Handle(CreateAccount command)
{
var account = new Account(command.AccountId, command);
_repository.Save(account, command);
}
}
```

## Integration with Aggregates

Commands are used to modify aggregates, which then produce events:

```csharp
public class Account : AggregateRoot
{
public Account(Guid id, ICorrelatedMessage source) : base(id)
{
Apply(MessageBuilder.From(source, () => new AccountCreated(id, source.CorrelationId, source.MsgId)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. See previous comment about this.

}

public void Deposit(decimal amount, ICorrelatedMessage source)
{
Apply(MessageBuilder.From(source, () => new FundsDeposited(Id, amount)));
}
}
```

## Best Practices

1. **Immutable Commands**: Make all command properties read-only
2. **Descriptive Names**: Use verb-noun naming convention (e.g., `CreateAccount`, `DepositFunds`)
3. **Minimal Data**: Include only the data needed to perform the action
4. **Use MessageBuilder**: Always use `MessageBuilder` to create commands with proper correlation
5. **Validation**: Validate commands before processing them

## Common Pitfalls

1. **Mutable Commands**: Avoid mutable properties in commands
2. **Business Logic in Commands**: Commands should be simple data carriers without business logic
3. **Missing Correlation**: Ensure correlation information is properly maintained
4. **Large Commands**: Keep commands focused and minimal

## Related Components

- [ICommand](./icommand.md): Interface for command messages
- [ICorrelatedMessage](./icorrelated-message.md): Interface for messages with correlation information
- [MessageBuilder](./message-builder.md): Factory for creating correlated messages
- [ICommandHandler](./icommand-handler.md): Interface for handling commands

---

**Navigation**:
- [← Previous: MessageBuilder](./message-builder.md)
- [↑ Back to Top](#command)
- [→ Next: Event](./event.md)
Loading