Chd.Workflow
1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Chd.Workflow --version 1.0.0
NuGet\Install-Package Chd.Workflow -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Chd.Workflow" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Chd.Workflow" Version="1.0.0" />
<PackageReference Include="Chd.Workflow" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Chd.Workflow --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Chd.Workflow, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Chd.Workflow@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Chd.Workflow&version=1.0.0
#tool nuget:?package=Chd.Workflow&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Chd.Workflow 🚀
Chd.Workflow is a lightweight, tree-based workflow engine for .NET. Define workflows with nodes, transitions, rules, and dynamic forms. Backend-driven UI support with headless architecture.
🎯 Features
- Tree-based workflow structure - Recursive node hierarchy
- Dynamic forms - Fields defined per node with 15+ field types
- Rule engine - Validation, auto-transition, and calculations
- Multi-tenant - Built-in tenant support
- Backend-driven UI - Pairs with
@mehmetyoldas/chd-workflow-corenpm package - Minimal API - REST endpoints auto-registered
- In-memory + extensible - Implement
IWorkflowRepositoryfor any database
📦 Installation
dotnet add package Chd.Workflow
🚀 Quick Start
1. Register Services
// Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddWorkflow();
var app = builder.Build();
app.UseWorkflow(); // Maps /api/workflow/* endpoints
app.Run();
2. Create a Workflow Definition
var definition = new WorkflowDefinition
{
Name = "leave-request",
Description = "Employee leave request workflow",
RootNode = new Node
{
Id = "start",
Name = "start",
Type = NodeType.Start,
Children = new List<Node>
{
new Node
{
Id = "employee-form",
Name = "employee-form",
Title = "Leave Request Form",
Type = NodeType.Task,
Fields = new List<Field>
{
new Field { Name = "leaveType", Label = "Leave Type", Type = FieldType.Dropdown, Required = true },
new Field { Name = "startDate", Label = "Start Date", Type = FieldType.Date, Required = true },
new Field { Name = "endDate", Label = "End Date", Type = FieldType.Date, Required = true },
new Field { Name = "reason", Label = "Reason", Type = FieldType.TextArea }
},
Transitions = new List<Transition>
{
new Transition { Action = "submit", Label = "Submit", TargetNodeId = "manager-approval", ButtonStyle = "primary" }
}
},
new Node
{
Id = "manager-approval",
Name = "manager-approval",
Title = "Manager Approval",
Type = NodeType.Task,
AllowedRoles = new List<string> { "Manager" },
Transitions = new List<Transition>
{
new Transition { Action = "approve", Label = "Approve", TargetNodeId = "end", ButtonStyle = "success" },
new Transition { Action = "reject", Label = "Reject", TargetNodeId = "end", ButtonStyle = "danger", RequiresComment = true }
}
},
new Node
{
Id = "end",
Name = "end",
Type = NodeType.End
}
}
}
};
3. Use the Engine
// Create instance
var instance = await engine.CreateInstanceAsync("leave-request", initialData, userId);
// Get state for UI
var state = await engine.GetStateAsync(instance.Id);
// Execute transition
var updated = await engine.TransitionAsync(instance.Id, "submit", formData, userId);
🌐 REST API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/workflow/definitions |
List all definitions |
| GET | /api/workflow/definitions/{id} |
Get definition by ID |
| POST | /api/workflow/definitions |
Create definition |
| PUT | /api/workflow/definitions/{id} |
Update definition |
| DELETE | /api/workflow/definitions/{id} |
Delete definition |
| GET | /api/workflow/instances/{id} |
Get instance by ID |
| GET | /api/workflow/instances/{id}/state |
Get current state for UI |
| POST | /api/workflow/instances |
Create new instance |
| POST | /api/workflow/instances/{id}/transition |
Execute transition |
| POST | /api/workflow/instances/{id}/validate |
Validate data |
| POST | /api/workflow/instances/{id}/cancel |
Cancel instance |
📊 Models
Node Types
Start- Entry pointTask- User action requiredDecision- Conditional branchingEnd- Workflow completionSubWorkflow- Nested workflow
Field Types
Text, TextArea, Number, Decimal, Date, DateTime, Time, Checkbox, Radio, Dropdown, MultiSelect, File, Image, RichText, Hidden
Workflow Status
Draft, Running, Completed, Cancelled, Suspended
🔧 Custom Repository
public class EfWorkflowRepository : IWorkflowRepository
{
private readonly MyDbContext _db;
// Implement interface methods...
}
// Register
builder.Services.AddWorkflow<EfWorkflowRepository>();
🎨 Frontend Integration
Use with @mehmetyoldas/chd-workflow-core npm package:
import { WorkflowClient } from '@mehmetyoldas/chd-workflow-core';
const client = new WorkflowClient({ apiUrl: '/api/workflow' });
const state = await client.getState(instanceId);
// Render form from state.fields
// Show actions from state.availableActions
📚 Related Packages
| Package | Description |
|---|---|
@mehmetyoldas/chd-workflow-core |
TypeScript client + React/Vue helpers |
Chd.AutoUI |
Attribute-driven UI metadata |
Chd.Caching |
Redis caching with AOP |
License
MIT License - Free and open source.
Made with ❤️ by the CHD 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 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- System.Text.Json (>= 9.0.0)
-
net9.0
- System.Text.Json (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.