F-Mesh

Flow-Based Programming framework for Go

Links

About

F-Mesh is a Flow-Based Programming (FBP) framework that lets you build applications as a graph of independent, reusable components. Think of it as connecting building blocks with pipes — data flows through your program like water through a network of connected components.

Inspired by J. Paul Morrison's FBP, F-Mesh brings the power of dataflow programming to Go with a clean, type-safe API.

Installation

go get github.com/hovsep/fmesh

Key Features

Component-Based Architecture

Build complex workflows from simple, reusable components. Each component is independent and testable.

Hooks System

Extend behavior at any execution point — mesh lifecycle, cycles, component activations, and port operations.

Concurrency Out of the Box

All components in a single activation cycle run concurrently — no need to manage goroutines yourself.

Chainable API

Fluent interface for building meshes with readable, declarative code.

Quick Example

// Create a mesh that concatenates and uppercases strings
fm := fmesh.New("hello world").
    AddComponents(
        component.New("concat").
            AddInputs("i1", "i2").
            AddOutputs("res").
            WithActivationFunc(func(this *component.Component) error {
                word1 := this.InputByName("i1").Signals().FirstPayloadOrDefault("").(string)
                word2 := this.InputByName("i2").Signals().FirstPayloadOrDefault("").(string)
                this.OutputByName("res").PutSignals(signal.New(word1 + word2))
                return nil
            }),
    )

// Connect, set inputs, and run
fm.ComponentByName("concat").OutputByName("res").
    PipeTo(fm.ComponentByName("uppercase").InputByName("i1"))

_, err := fm.Run()