A minimal, configurable workflow engine (state-machine API) built with ASP.NET Core (.NET 8).
- Define workflows as state machines (states + actions)
- Start workflow instances from definitions
- Execute actions to move instances between states (with validation)
- Inspect/list states, actions, definitions, and running instances
- In-memory persistence (no database required)
- .NET 8 SDK installed (download here)
cd WorkflowEngine
dotnet runThe API will start (by default on http://localhost:5173).
POST /workflows
{
"id": "leave-approval",
"name": "Leave Approval",
"states": [
{ "id": "draft", "name": "Draft", "isInitial": true, "isFinal": false, "enabled": true },
{ "id": "approved", "name": "Approved", "isInitial": false, "isFinal": true, "enabled": true },
{ "id": "rejected", "name": "Rejected", "isInitial": false, "isFinal": true, "enabled": true }
],
"actions": [
{ "id": "submit", "name": "Submit", "enabled": true, "fromStates": ["draft"], "toState": "approved" },
{ "id": "reject", "name": "Reject", "enabled": true, "fromStates": ["draft"], "toState": "rejected" }
]
}GET /workflows
POST /workflows/leave-approval/instances
GET /instances
POST /instances/{instanceId}/actions/submit
GET /instances/{instanceId}
- All data is stored in-memory; restarting the app will clear all workflows/instances.
- No authentication or authorization is implemented.
- Validation is enforced for state-machine rules (see code comments).
- API is minimal and designed for clarity and extensibility.
- Error messages are returned in a consistent
{ "error": "..." }format.
- No persistent storage (can be added via file or DB if needed)
- No OpenAPI/Swagger UI (can be added easily)
- No unit tests (add if needed for production)
- Add file or database persistence by updating the services.
- Add more attributes to states/actions as needed.
- Add authentication/authorization for production use.
Author: Rohan