BR.Workflow.Contracts
2.2.40
dotnet add package BR.Workflow.Contracts --version 2.2.40
NuGet\Install-Package BR.Workflow.Contracts -Version 2.2.40
<PackageReference Include="BR.Workflow.Contracts" Version="2.2.40" />
<PackageVersion Include="BR.Workflow.Contracts" Version="2.2.40" />Directory.Packages.props
<PackageReference Include="BR.Workflow.Contracts" />Project file
paket add BR.Workflow.Contracts --version 2.2.40
#r "nuget: BR.Workflow.Contracts, 2.2.40"
#:package BR.Workflow.Contracts@2.2.40
#addin nuget:?package=BR.Workflow.Contracts&version=2.2.40Install as a Cake Addin
#tool nuget:?package=BR.Workflow.Contracts&version=2.2.40Install as a Cake Tool
BR.Workflow.Contracts
NuGet .NET License Build Status
A comprehensive .NET 8 library containing Temporal workflow and activity contracts for distributed workflow processing systems. Built with Clean Architecture principles and clear separation of concerns across service domains.
π― What This Package Provides
BR.Workflow.Contracts is the foundation for building distributed, scalable workflow systems using Temporal.io and .NET 8. It provides:
- ποΈ Workflow Contracts - Define workflow orchestration patterns
- β‘ Activity Contracts - Define individual processing steps
- π Data Models - Immutable, validated data contracts
- π§ Utility Extensions - Helper methods for common operations
- π¨ Clean Architecture - Well-organized, maintainable code structure
ποΈ Architecture Overview
This package implements Clean Architecture with clear separation by service domains:
Service Domains
| Domain | Purpose | Key Responsibilities |
|---|---|---|
| REI (Real Estate Ingestor) | Event validation and blob operations | Event validation, blob downloads, status updates |
| REP (Real Estate Processor) | Order processing and business logic | Order management, schema validation, client communication |
| PT (Payload Transformer) | Data transformation for external services | Data mapping, format conversion, schema validation |
Architecture Principles
- β Separation of Concerns - Clear boundaries between domains
- β Dependency Inversion - Interfaces depend on abstractions
- β Single Responsibility - Each contract has one purpose
- β Open/Closed - Extensible without modification
- β Interface Segregation - Clients only depend on what they use
β¨ Key Features
Core Features
- π .NET 8 Compatible - Latest language features and performance improvements
- π Nullable Reference Types - Full nullable annotations for better code safety
- π Data Annotations - Comprehensive validation attributes
- π XML Documentation - Complete API documentation
- π§΅ Immutable Records - Thread-safe, immutable data contracts
- π§ Extension Methods - Utility extensions for common operations
Temporal Integration
- β° Native Temporal Support - Built for Temporal.io workflows
- π Workflow Orchestration - Define complex workflow patterns
- β‘ Activity Contracts - Define individual processing steps
- π― Task Queue Management - Organized by service domain
Production Ready
- π§ͺ Comprehensive Testing - Full test coverage
- π Performance Optimized - Minimal allocations and async patterns
- π Security Focused - Input validation and secure defaults
- π Monitoring Ready - Built-in audit and error tracking
π¦ Installation
NuGet Package
dotnet add package BR.Workflow.Contracts
Package Manager Console
Install-Package BR.Workflow.Contracts
Direct Reference
<PackageReference Include="BR.Workflow.Contracts" Version="1.0.17" />
ποΈ Project Structure
BR.Workflow.Contracts/
βββ π Workflows/ # Workflow orchestration contracts
β βββ IStartRealEstateWorkflow.cs # Main workflow interface
β βββ Models/
β βββ RealEstateWorkflowOutput.cs
β
βββ π Activities/ # Activity contracts by service domain
β βββ π REI/ # Real Estate Ingestor (3 activities)
β β βββ IValidateEventActivity.cs
β β βββ IDownloadBlobActivity.cs
β β βββ IUpdateOrderStatusInBlobActivity.cs
β β
β βββ βοΈ REP/ # Real Estate Processor (9 activities)
β β βββ IValidateSchemaTemplateActivity.cs
β β βββ IDetermineActionTypeActivity.cs
β β βββ ICreateOrderActivity.cs
β β βββ IUpdateOrderActivity.cs
β β βββ IApproveOrderActivity.cs
β β βββ IRejectOrderActivity.cs
β β βββ INotifyClientActivity.cs
β β βββ IUpdateDbActivity.cs
β β βββ ICallApiGatewayActivity.cs
β β
β βββ π PT/ # Payload Transformer (1 activity)
β βββ ITransformPayloadActivity.cs
β
βββ π Models/ # Data models organized by domain
β βββ π Common/ # Shared models across all services
β β βββ AuditInfo.cs # Workflow execution audit
β β βββ ErrorInfo.cs # Error details and tracking
β β βββ ValidationError.cs # Validation failure details
β β βββ ValidationResult.cs # Validation operation results
β β βββ StatusUpdate.cs # Status change notifications
β β βββ ApiGatewayResponse.cs # External API responses
β β βββ BlobMetadata.cs # Blob storage metadata
β β βββ DownloadInfo.cs # Download operation details
β β βββ DuplicateCheck.cs # Duplicate detection results
β β
β βββ π¨ Kafka/ # Kafka payload and workflow input
β β βββ RealEstateWorkflowInput.cs # Main workflow input
β β βββ EventInfo.cs # Event metadata and correlation
β β βββ ClientInfo.cs # Client identification
β β βββ BlobInfo.cs # Blob storage information
β β βββ DeadLetterEvent.cs # DLQ event handling
β β βββ DlqDetails.cs # DLQ failure details
β β
β βββ π REI/ # Real Estate Ingestor models
β β βββ ValidateEventInput.cs # Event validation input
β β βββ ValidateEventOutput.cs # Event validation results
β β βββ DownloadBlobInput.cs # Blob download parameters
β β βββ DownloadBlobOutput.cs # Blob download results
β β βββ UpdateOrderStatusInput.cs # Status update input
β β βββ UpdateOrderStatusOutput.cs # Status update results
β β
β βββ βοΈ REP/ # Real Estate Processor models
β β βββ ValidateSchemaInput.cs # Schema validation input
β β βββ ValidateSchemaOutput.cs # Schema validation results
β β βββ DetermineActionInput.cs # Action determination input
β β βββ DetermineActionOutput.cs # Action determination results
β β βββ CreateOrderInput.cs # Order creation input
β β βββ CreateOrderOutput.cs # Order creation results
β β βββ UpdateOrderInput.cs # Order update input
β β βββ UpdateOrderOutput.cs # Order update results
β β βββ ApproveOrderInput.cs # Order approval input
β β βββ ApproveOrderOutput.cs # Order approval results
β β βββ RejectOrderInput.cs # Order rejection input
β β βββ RejectOrderOutput.cs # Order rejection results
β β βββ NotifyClientInput.cs # Client notification input
β β βββ NotifyClientOutput.cs # Client notification results
β β βββ UpdateDbInput.cs # Database update input
β β βββ UpdateDbOutput.cs # Database update results
β β βββ CallApiGatewayInput.cs # API Gateway call input
β β βββ CallApiGatewayOutput.cs # API Gateway call results
β β
β βββ π PT/ # Payload Transformer models
β βββ TransformPayloadInput.cs # Transformation input
β βββ TransformPayloadOutput.cs # Transformation results
β βββ TransformationRules.cs # Transformation configuration
β
βββ π Enums/ # Type-safe enumerations
β βββ ActionType.cs # Order processing actions
β βββ BrightRiverStatus.cs # Bright River specific statuses
β βββ DeliveryStatus.cs # Delivery operation statuses
β βββ HttpMethod.cs # HTTP method constants
β βββ NotificationType.cs # Notification type definitions
β βββ OrderStatus.cs # Order lifecycle statuses
β βββ ValidationSeverity.cs # Validation error severity levels
β
βββ π Extensions/ # Utility extension methods
β βββ TemporalExtensions.cs # Workflow result helpers
β βββ ContractExtensions.cs # Contract utility methods
β βββ ValidationExtensions.cs # Validation helper methods
β
βββ π Constants/ # Configuration constants
β βββ ActivityNames.cs # Activity naming constants
β βββ ConfigurationKeys.cs # Configuration key constants
β βββ TaskQueues.cs # Task queue names
β βββ WorkflowNames.cs # Workflow naming constants
β βββ WorkflowTypes.cs # Workflow type definitions
β
βββ π Scripts/ # Build and deployment automation
βββ build-and-publish.ps1 # PowerShell build & publish script
βββ build-and-publish.cmd # Windows batch build & publish script
βββ build.ps1 # Comprehensive build script
βββ build.cmd # Windows build script
βββ publish.ps1 # NuGet publishing script
π Quick Start Guide
1. Basic Workflow Implementation
using BR.Workflow.Contracts.Workflows;
using BR.Workflow.Contracts.Models.Kafka;
using BR.Workflow.Contracts.Workflows.Models;
public class StartRealEstateWorkflow : IStartRealEstateWorkflow
{
public async Task<RealEstateWorkflowOutput> ExecuteAsync(RealEstateWorkflowInput input)
{
try
{
// Your workflow logic here
return new RealEstateWorkflowOutput
{
WorkflowId = Guid.NewGuid(),
Status = "Completed",
ClientId = input.ClientInfo.Id,
OrderId = Guid.NewGuid(),
ActionType = ActionType.Create,
ApiGatewayResponse = new ApiGatewayResponse
{
Success = true,
StatusCode = 200,
Message = "Order created successfully"
},
AuditInfo = new AuditInfo
{
CompletedAt = DateTime.UtcNow,
ErrorInfo = Array.Empty<ErrorInfo>()
}
};
}
catch (Exception ex)
{
return new RealEstateWorkflowOutput
{
WorkflowId = Guid.NewGuid(),
Status = "Failed",
ClientId = input.ClientInfo.Id,
OrderId = Guid.Empty,
ActionType = ActionType.Create,
ApiGatewayResponse = new ApiGatewayResponse
{
Success = false,
StatusCode = 500,
Message = ex.Message
},
AuditInfo = new AuditInfo
{
CompletedAt = DateTime.UtcNow,
ErrorInfo = new[] { new ErrorInfo { Message = ex.Message, Severity = ValidationSeverity.Error } }
}
};
}
}
}
2. Activity Implementation
using BR.Workflow.Contracts.Activities.REI;
using BR.Workflow.Contracts.Models.REI;
using BR.Workflow.Contracts.Models.Common;
public class ValidateEventActivity : IValidateEventActivity
{
public async Task<ValidateEventOutput> ValidateAsync(ValidateEventInput input)
{
var validationErrors = new List<ValidationError>();
// Validate correlation ID
if (string.IsNullOrEmpty(input.CorrelationId))
{
validationErrors.Add(new ValidationError
{
Field = nameof(input.CorrelationId),
Message = "Correlation ID is required",
Severity = ValidationSeverity.Error
});
}
// Validate client ID
if (input.ClientId == Guid.Empty)
{
validationErrors.Add(new ValidationError
{
Field = nameof(input.ClientId),
Message = "Valid Client ID is required",
Severity = ValidationSeverity.Error
});
}
// Check for duplicates
var duplicateCheck = await CheckForDuplicatesAsync(input.CorrelationId, input.ClientId);
return new ValidateEventOutput
{
CanProceed = validationErrors.Count == 0,
DuplicateCheck = duplicateCheck,
ValidationErrors = validationErrors.ToArray()
};
}
private async Task<DuplicateCheck> CheckForDuplicatesAsync(string correlationId, Guid clientId)
{
// Your duplicate checking logic here
return new DuplicateCheck
{
RecentlyDownloaded = false,
DownloadCount = 0
};
}
}
3. Using Extension Methods
using BR.Workflow.Contracts.Extensions;
// Create workflow results easily
var successResult = TemporalExtensions.CreateSuccessResult(
workflowId: Guid.NewGuid(),
status: "Completed",
clientId: clientId,
orderId: orderId,
actionType: ActionType.Create
);
// Validate contract inputs
if (!input.IsValid())
{
var errors = input.GetValidationErrors();
foreach (var error in errors)
{
Console.WriteLine($"Validation Error: {error.Field} - {error.Message}");
}
}
// Create error results
var errorResult = TemporalExtensions.CreateErrorResult(
workflowId: Guid.NewGuid(),
status: "Failed",
clientId: clientId,
orderId: orderId,
actionType: ActionType.Create,
errorMessage: "Processing failed"
);
π§ Service Domain Deep Dive
π REI (Real Estate Ingestor)
Purpose: Handle incoming events and manage blob storage operations
Key Activities:
IValidateEventActivity- Validate incoming events and check for duplicatesIDownloadBlobActivity- Download blob content from Azure StorageIUpdateOrderStatusInBlobActivity- Update order status in blob storage
Use Cases:
- Event deduplication and validation
- Blob content retrieval for processing
- Status tracking in blob storage
βοΈ REP (Real Estate Processor)
Purpose: Core business logic for order processing and client communication
Key Activities:
IValidateSchemaTemplateActivity- Validate data against business schemasIDetermineActionTypeActivity- Determine processing action typeICreateOrderActivity- Create new ordersIUpdateOrderActivity- Update existing ordersIApproveOrderActivity- Approve ordersIRejectOrderActivity- Reject ordersINotifyClientActivity- Notify clients of status changesIUpdateDbActivity- Update processing status in databaseICallApiGatewayActivity- Communicate with external services
Use Cases:
- Order lifecycle management
- Business rule validation
- Client communication
- External service integration
π PT (Property Transformer)
Purpose: Transform data between different service formats
Key Activities:
ITransformPayloadActivity- Transform data between formats
Use Cases:
- Data format conversion
- Schema mapping
- External service compatibility
π¨ Kafka Integration
The library provides dual-purpose models that serve both Kafka messaging and workflow processing:
Kafka Payload Models
| Model | Purpose | Key Properties |
|---|---|---|
RealEstateWorkflowInput |
Main workflow input from Kafka | EventInfo, ClientInfo, BlobInfo |
EventInfo |
Event metadata and correlation | Name, CorrelationId, Timestamp |
ClientInfo |
Client identification | Id, Name, Reference |
BlobInfo |
Azure Blob Storage information | Url, Container, BlobName |
Key Features
- JSON Serialization -
JsonPropertyNameattributes for camelCase JSON - Kafka Compatibility - Optimized for message serialization/deserialization
- Workflow Integration - Seamless integration with Temporal workflows
- Type Safety - Full nullable reference type support
- Validation - Comprehensive data validation attributes
Usage Pattern
// Kafka message processing
var kafkaPayload = JsonSerializer.Deserialize<RealEstateWorkflowInput>(kafkaMessage);
// Validate the payload
if (!kafkaPayload.IsValid())
{
var errors = kafkaPayload.GetValidationErrors();
// Handle validation errors...
}
// Workflow execution
var result = await workflow.ExecuteAsync(kafkaPayload);
π Complete Contract Reference
Workflows
| Interface | Purpose | Output |
|---|---|---|
IStartRealEstateWorkflow |
Main workflow orchestration | RealEstateWorkflowOutput |
Activities (13 Total)
REI Activities (3)
| Activity | Purpose | Input | Output |
|---|---|---|---|
IValidateEventActivity |
Validate incoming events | ValidateEventInput |
ValidateEventOutput |
IDownloadBlobActivity |
Download blob content | DownloadBlobInput |
DownloadBlobOutput |
IUpdateOrderStatusInBlobActivity |
Update blob status | UpdateOrderStatusInput |
UpdateOrderStatusOutput |
REP Activities (9)
| Activity | Purpose | Input | Output |
|---|---|---|---|
IValidateSchemaTemplateActivity |
Validate business schemas | ValidateSchemaInput |
ValidateSchemaOutput |
IDetermineActionTypeActivity |
Determine processing action | DetermineActionInput |
DetermineActionOutput |
ICreateOrderActivity |
Create new orders | CreateOrderInput |
CreateOrderOutput |
IUpdateOrderActivity |
Update existing orders | UpdateOrderInput |
UpdateOrderOutput |
IApproveOrderActivity |
Approve orders | ApproveOrderInput |
ApproveOrderOutput |
IRejectOrderActivity |
Reject orders | RejectOrderInput |
RejectOrderOutput |
INotifyClientActivity |
Notify clients | NotifyClientInput |
NotifyClientOutput |
IUpdateDbActivity |
Update database | UpdateDbInput |
UpdateDbOutput |
ICallApiGatewayActivity |
Call external APIs | CallApiGatewayInput |
CallApiGatewayOutput |
PT Activities (1)
| Activity | Purpose | Input | Output |
|---|---|---|---|
ITransformPayloadActivity |
Transform data formats | TransformPayloadInput |
TransformPayloadOutput |
Enums
| Enum | Values | Purpose |
|---|---|---|
ActionType |
Create, Update, Approve, Reject | Order processing actions |
BrightRiverStatus |
Pending, Processing, Completed, Failed | Bright River specific statuses |
OrderStatus |
Draft, Submitted, Approved, Rejected | Order lifecycle statuses |
ValidationSeverity |
Info, Warning, Error, Critical | Validation error severity |
DeliveryStatus |
Pending, Delivered, Failed | Delivery operation statuses |
HttpMethod |
GET, POST, PUT, DELETE | HTTP method constants |
NotificationType |
Email, SMS, Push | Notification type definitions |
π― Clean Architecture Benefits
Design Principles
- Separation of Concerns - Clear boundaries between service domains
- Dependency Inversion - Interfaces depend on abstractions, not concretions
- Single Responsibility - Each contract has a single, well-defined purpose
- Open/Closed Principle - Easy to extend without modifying existing contracts
- Interface Segregation - Clients only depend on interfaces they use
Implementation Benefits
- Maintainability - Clear structure makes code easy to understand and modify
- Testability - Interfaces make unit testing straightforward
- Extensibility - New features can be added without breaking existing code
- Reusability - Contracts can be used across different implementations
- Documentation - Clear interfaces serve as living documentation
π Production Readiness
The project follows all specified C# .NET development guidelines:
Code Quality
- β PascalCase naming conventions for all public members
- β Async/await patterns for I/O operations
- β Comprehensive error handling with custom exceptions
- β Dependency injection principles for loose coupling
- β Modern C# features (records, pattern matching, nullable references)
Performance & Security
- β Thread-safe immutable data contracts using records
- β Minimal allocations and optimized async patterns
- β Input validation and secure defaults
- β Comprehensive XML documentation for all public APIs
- β Nullable reference types for better type safety
Testing & Monitoring
- β Full test coverage for all contracts and extensions
- β Built-in audit tracking for workflow execution
- β Error tracking with detailed error information
- β Validation results for debugging and monitoring
π§ Build and Deployment
Single Command Build & Publish
# PowerShell (Recommended)
.\scripts\build-and-publish.ps1 -ApiKey "your-nuget-api-key"
# Windows Batch
.\scripts\build-and-publish.cmd "your-nuget-api-key"
# Dry run (test without publishing)
.\scripts\build-and-publish.ps1 -ApiKey "your-nuget-api-key" -DryRun
Manual Build Process
# Restore packages
dotnet restore
# Build project
dotnet build --configuration Release
# Create NuGet package
dotnet pack --configuration Release --output nupkg
# Publish to NuGet
dotnet nuget push "nupkg\BR.Workflow.Contracts.1.0.17.nupkg" --source "https://api.nuget.org/v3/index.json" --api-key "your-api-key"
CI/CD Integration
The package includes scripts for:
- Azure DevOps - Build and release pipelines
- GitHub Actions - Automated workflows
- Jenkins - Build automation
- Local Development - Quick build and test
π Documentation
API Documentation
- XML Documentation - Complete API documentation for all public members
- IntelliSense Support - Full IntelliSense in Visual Studio and VS Code
- Code Examples - Comprehensive usage examples in this README
Architecture Documentation
- Clean Architecture - Well-organized structure following SOLID principles
- Service Domain Separation - Clear boundaries between REI, REP, and PT services
- Data Flow Diagrams - Understanding of how data flows through the system
Development Guides
- Getting Started - Quick start guide for new developers
- Best Practices - Guidelines for implementing contracts
- Testing Strategies - Approaches for testing workflow contracts
π€ Contributing
When extending these contracts:
Code Standards
- Follow naming conventions (PascalCase for public members)
- Add comprehensive XML documentation for all public APIs
- Use nullable reference types appropriately
- Include data validation attributes where needed
- Ensure immutability using records
- Maintain service domain separation
- Add unit tests for complex validation logic
Pull Request Process
- Create feature branch from main
- Implement changes following existing patterns
- Add tests for new functionality
- Update documentation as needed
- Submit pull request with clear description
Testing Requirements
- Unit tests for all new contracts
- Integration tests for workflow patterns
- Validation tests for data models
- Performance tests for critical paths
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Support
Getting Help
- Documentation - Start with this README and XML documentation
- Issues - Report bugs or request features via GitLab issues
- Team Contact - Contact the RealEstate Platform team for direct support
Community
- GitLab Repository - workflow-platform
- NuGet Package - BR.Workflow.Contracts
- Project URL - GitLab Project
π Version History
Current Version: 1.0.17
- Latest Release - September 2024
- .NET Version - 8.0
- Temporal Version - 1.7.0
- Key Features - Complete workflow contracts, activity interfaces, data models
Previous Versions
- 1.0.16 - Initial release with basic contracts
- 1.0.15 - Development version
Built with β€οΈ by the Bright River RealEstate Platform Team
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- FastEndpoints (>= 5.25.0)
- System.Text.Json (>= 8.0.5)
- Temporalio (>= 1.7.0)
- Temporalio.Extensions.Hosting (>= 1.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.2.40 | 329 | 12/4/2025 |
| 2.2.39 | 255 | 12/4/2025 |
| 2.2.38 | 418 | 11/13/2025 |
| 2.2.37 | 320 | 11/13/2025 |
| 2.2.36 | 316 | 11/10/2025 |
| 2.2.35 | 345 | 11/10/2025 |
| 2.2.30 | 218 | 11/9/2025 |
| 2.2.29 | 354 | 11/8/2025 |
| 2.2.28 | 214 | 11/7/2025 |
| 2.2.27 | 199 | 11/7/2025 |
| 2.2.26 | 268 | 11/4/2025 |
| 2.2.25 | 240 | 11/4/2025 |
| 2.2.24 | 199 | 10/31/2025 |
| 2.2.23 | 213 | 10/31/2025 |
| 2.2.21 | 244 | 10/30/2025 |
| 2.2.3 | 215 | 10/31/2025 |
| 2.2.2 | 324 | 10/30/2025 |
| 2.2.1 | 249 | 10/30/2025 |
| 2.1.35 | 249 | 10/29/2025 |
| 2.1.34 | 223 | 10/29/2025 |