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)