The Problem Space
Imagine implementing a typical Leave Request Workflow:
- Employee submits a request (notify the direct manager).
- Direct Manager approves or rejects (if rejected, notify the employee).
- If approved and the leave duration exceeds 15 days, the Section Head must approve (send notification).
- Regardless of previous outcomes, the request is sent to the HR department.
- If approved by HR, the request is processed; if rejected, the employee is notified.
- Audit logs are written at each step.
While this logic can be implemented using plain C#, as complexity increasesโdue to branching, retries, compensation, async callsโit becomes difficult to manage, maintain, and test. This is where workflow engines prove their value.
A workflow engine provides a structured, reusable way to model, execute, and manage business processes. Instead of hardcoding logic into services or controllers, workflow engines allow you to:
- ๐ Define states (e.g., Submitted, Approved, Rejected)
- ๐ Configure transitions between states through actions or rules
- ๐ค Handle human-driven steps, such as approvals or reviews
- ๐พ Persist long-running workflows and resume execution later
- ๐ Record audit logs for traceability and compliance
Workflow engines are ideal for scenarios like business approvals, employee onboarding, document lifecycles, and other multi-step decision-based processes.
Some engines are designed as general-purpose orchestrators. Others, like Meridian Workflow, are purpose-built for stateful, user-interactive workflows with strongly-typed fluent definitions.
You can either build your own workflow engine or use an existing open-source solution tailored to your needs.
Existing Workflow Engines at a Glance (Open Source)
A quick survey of popular open-source workflow engines yields several solid candidates:
Letโs explore the strengths and trade-offs of each, to help choose the right one.
Workflow Core
- โ Lightweight and C#-first.
- โ JSON-serialized persistence, lacking type safety during deserialization.
- โ No fluent API; workflows are defined by implementing interfaces.
- โ Refactoring is error-prone โ issues appear at runtime rather than compile-time.
Elsa Workflows
- โ Rich feature set, visual designer, multiple persistence providers.
- โ Heavyweight โ significant dependencies and steep learning curve.
- โ Workflow definitions use verbose JSON or C# models.
- โ Often overkill for simple state-based business logic.
Meridian Workflow
Meridian Workflow is designed specifically to fill the gap between simplicity and power:
- ๐ Pure C# DSL โ workflows are defined entirely in C#, without JSON or visual designers.
- โ Compile-time safety โ all input and output types are enforced by the compiler.
- โ๏ธ Fluent API โ simple chaining with
.State(...),.Action(...),.When(...),.AddHook(...), etc. - โก Minimal overhead โ no required UI, database, or service bus.
- ๐ Easy testing โ workflows can be executed in-memory and fully unit tested.
Feature Comparison Table
| Feature | Meridian | Workflow Core | Elsa Workflows |
|---|---|---|---|
| Workflow Type | State-machine, approval-focused | Step-based, flow-oriented | Activity-based orchestration |
| Designer UI | โ None | โ None | โ Visual Designer |
| DSL | โ Fluent C# DSL | Fluent + JSON | JSON or verbose C# |
| Use Case Focus | Business approvals, human interactions | General-purpose workflows | Long-running orchestration, integrations |
| Task Handling | โ Built-in (roles/users/groups) | โ Requires custom logic | โ ๏ธ Activity-based (not approval-centric) |
| Authorization | โ Role/group/user-level authorization | โ None built-in | โ ๏ธ Not natively supported |
| Persistence Model | Built-in (lightweight) | Implicit persistence | Required |
| Approval Model | โ Native support for actions, tasks, roles | โ Not supported | โ ๏ธ Requires workarounds |
| Extensibility | Hooks, templates, pluggable features | Middleware, step extensions | Extendable via activities/extensions |
| Developer Experience | โ Zero-config, developer-first | โ More boilerplate | โ Heavy setup, advanced tooling required |
| Best Suited For | Leave requests, ticketing, approvals | General orchestrations | Workflow automation with integration needs |
| Attachment Handling | โ
Built-in file/attachment processing via pluggable IWorkflowFileStorageProvider
|
โ Requires full custom implementation | โ ๏ธ Supported via activities but not native |
Conclusion
Itโs clear that for state-machine, human-centric, or approval-based workflows, Meridian Workflow is the ideal choice.
It offers:
- Clear, strongly-typed definitions
- Built-in support for approvals and roles
- Easy testing and minimal overhead
- A developer-first experience
๐ Bookmark-worthy?
If you ever revisit a workflow engine deep dive, this post might be one of those. Having it saved for when you're building approval flows could come in handy.
๐ฌ Your turn
Whatโs been your toughest workflow challenge? Seeing your own use cases reflected here would help inform Partโฏ2โand maybe spark ideas for others in the comments.
๐ Coming soon: Partโฏ2
Weโll be diving into setting up a Leave Request flow in Meridian Workflowโcovering state definitions, approval actions, and transitions, step by step.
See you there!
Top comments (0)