Skip to main content

Web UI & API

Workflows4s includes an experimental UI that lets you inspect and interact with workflows. It is powered by an HTTP API that can also be used on its own. Check the demo to see how it works in practice.

warning

Neither the UI nor the API provides authentication or authorization. Until this changes, we advise protecting it through external means.

warning

These modules should be treated as early developer preview. They are safe to use, but their quality may be lower than the rest of the project.

Getting Started

// the same runtime that is used for running the workflows
val myRuntime: WorkflowRuntime[IO, MyWorkflowCtx] = ???

// each runtime needs to be enriched with information required by the UI
val myApiEntry: WorkflowEntry[IO, MyWorkflowCtx] =
WorkflowEntry(
name = "My Workflow",
description = None,
runtime = myRuntime,
stateEncoder = ??? : Encoder[WCState[MyWorkflowCtx]],
signalSupport = SignalSupport.NoSupport,
)

// tapir endpoints for serving the API, we dont configure search for now
val apiEndpoints = WorkflowServerEndpoints.get(List(myApiEntry), search = None)
// tapir endpoints for service the UI assets
val uiEndpoints = UiEndpoints.get[IO](UIConfig(Uri.unsafeParse("http://localhost:8080")))

// example tapir interpretation, this part is orthogonal to workflows4s
val routes = Http4sServerInterpreter[IO]().toRoutes(apiEndpoints ++ uiEndpoints)
for {
_ <- EmberServerBuilder
.default[IO]
.withHost(ipv4"0.0.0.0")
.withPort(port"8080")
.withHttpApp(routes.orNotFound)
.build
.use { server =>
IO.println(s"Server with UI running at http://${server.address}") *>
IO.never
}
} yield ()