A generic, extensible workflow engine in Go, supporting state machines, pluggable actions (API calls, message broker, functions, callbacks), and a simple API server with dashboard visualization.
- Register workflows and actions dynamically via HTTP API
- Group workflows by domain
- Visualize workflows and transitions in a web dashboard (Mermaid.js)
- Easily extend with new action types
cd cmd
go run api_server.goThe server will start on http://localhost:8080.
curl -X POST http://localhost:8080/register-workflow \
  -H "Content-Type: application/json" \
  -d '{"domain":"ticket","name":"ticket_flow","initial_state":"open"}'curl -X POST http://localhost:8080/register-action \
  -H "Content-Type: application/json" \
  -d '{"domain":"ticket","workflow":"ticket_flow","state":"open","event":"start_progress","action_type":"function","function_name":"example"}'curl -X POST http://localhost:8080/register-action \
  -H "Content-Type: application/json" \
  -d '{"domain":"ticket","workflow":"ticket_flow","state":"open","event":"start_progress","action_type":"script","script":"result = ticket_id + \\" started by \\\" + user;"}'You can use any parameter passed to the action (e.g., ticket_id, user) in your script. The last evaluated value (e.g., result) will be returned as the action result.
Open your browser and go to:
http://localhost:8080/dashboard
Enter the domain and workflow name, then click Visualize to see the state diagram.
- cmd/api_server.go— API server entry point
- internal/api/— API handlers, dashboard, visualization
- internal/domain/— State machine, types, models
- internal/usecase/— Workflow orchestration
- internal/actions/— Pluggable action implementations
- Add new action types in internal/actions/
- Register new actions via the API
- To add new Go functions for use in function actions, add them to the FunctionRegistryininternal/actions/function_action.go.
- You can register JavaScript code as a workflow action using the scriptaction type. The script will be executed in a sandboxed JS interpreter (otto) with all action parameters available as variables.
MIT