A minimal, fast and flexible State Machine Engine built with ASP.NET Core.
This API allows creating workflows, defining states and actions, and managing state transitions with history tracking.
- Define custom workflows with multiple states and actions.
- Start workflow instances and track transitions.
- Transition validation with customizable logic.
- Minimal API-based routing.
- In-memory data store.
- Modular folder structure (Models, Routes, Utils, Validators).
- .NET 7 or 8 SDK
- macOS / Linux / Windows
- Visual Studio Code / Rider / Visual Studio
git clone <your-repo-url>
cd STATE_MACHINE_API
dotnet restore
dotnet runSwagger will launch at:
http://localhost:5206/swagger or https://localhost:7179/swagger
STATE_MACHINE_API/
STATE_MACHINE_API/
├── Data/ # In-memory data store
│ └── WorkflowDataStore.cs
├── Models/ # POCOs for your domain
│ ├── Action.cs
│ ├── Instance.cs
│ ├── State.cs
│ └── WorkFlow.cs
├── Routes/ # All your endpoints
│ └── RouteDefinitions.cs
├── Utils/ # Validation and helpers
│ └── Validators.cs
├── Properties/
│ └── launchSettings.json
├── Program.cs # Entry point (Minimal API)
├── appsettings.json # Configuration
└── .gitignore # Git ignored files/folders
{
"name": "OrderFlow",
"states": [
{ "name": "Placed", "isInitial": true, "isFinal": false, "isEnabled": true },
{ "name": "Delivered", "isInitial": false, "isFinal": true, "isEnabled": true }
],
"actions": [
{
"name": "Deliver",
"fromStates": ["Placed"],
"toState": "Delivered",
"enabled": true
}
]
}| Method | Route | Description |
|---|---|---|
| POST | /api/workflow |
Create a new workflow definition |
| GET | /api/workflow/{name} |
Get workflow by name |
| POST | /api/workflow/{name}/start |
Start a new instance |
| POST | /api/workflow/{workflowName}/action/{actionName} |
Perform an action on an instance |
| GET | /api/workflow/instance/{workflowName} |
Get instance details |
| GET | /api/workflows |
List all workflows |
| GET | /api/workflow/{workflowName}/states |
List state names in a workflow |
| GET | /api/workflow/{workflowName}/actions |
List action names in a workflow |
| GET | /api/instances |
List all running instance names |
| GET | /api/instances/{workflowName} |
List instances of a specific workflow |
| DELETE | /api/instance/{id} |
Delete an instance (only if final) |
Use Swagger UI, Postman, or cURL to test APIs.
Swagger: http://localhost:5206/swagger
MIT
Built by Arnab Jena.