Skip to content

octorohan/Configurable-Workflow-Engine

Repository files navigation

WorkflowEngine

A minimal, configurable workflow engine (state-machine API) built with ASP.NET Core (.NET 8).

Features

  • 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)

Quick Start

Prerequisites

Run the API

cd WorkflowEngine
 dotnet run

The API will start (by default on http://localhost:5173).

Example API Usage (with Postman or curl)

1. Create a Workflow Definition

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" }
  ]
}

2. List Workflow Definitions

GET /workflows

3. Start a Workflow Instance

POST /workflows/leave-approval/instances

4. List Instances

GET /instances

5. Execute an Action on an Instance

POST /instances/{instanceId}/actions/submit

6. Inspect Instance State & History

GET /instances/{instanceId}


Assumptions & Notes

  • 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.

Known Limitations

  • 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)

Extending

  • 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

About

A minimal, configurable workflow engine (state-machine API) built with ASP.NET Core (.NET 8). Supports defining workflows, starting instances, executing actions, and inspecting state—all with in-memory persistence.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages