Skip to content

hovsep/fmesh-examples

Repository files navigation

F-Mesh Examples

Real-world examples of Flow-Based Programming with F-Mesh

F-Mesh Go Version Go Report Card License: MIT

GitHub stars GitHub issues GitHub last commit GitHub contributors


About

This repository contains practical examples demonstrating F-Mesh - a Flow-Based Programming framework for Go. Each example shows how to model real-world systems as computational graphs with interconnected components.

What is F-Mesh?

F-Mesh is an FBP-inspired framework that lets you express your program as a mesh of components connected by pipes. Instead of writing imperative code, you describe how data flows through your system, making complex interactions more natural and maintainable. Learn more in the wiki.


Examples

Example Description
Async Input Handling asynchronous data sources
Electric Circuit Simulating electrical components
Fibonacci Recursive computation with cyclic pipes
Filter Data filtering and routing
Graphviz Visualizing mesh topology
Load Balancer Distributing work across components
Nesting Composing meshes within meshes
Pipeline Sequential data processing
String Processing Text transformation pipeline
Basic CAN Bus Simple automotive network simulation
Advanced CAN Bus Full CAN protocol with ISO-TP

Quick Start

Prerequisites

  • Go 1.24 or later
  • Git

Running Examples

# Clone and setup
git clone https://github.com/hovsep/fmesh-examples.git
cd fmesh-examples
go mod tidy

# Run any example
go run ./fibonacci
go run ./electric_circuit

# Build all examples
make build

# Generate visualization graphs
make graph

Project Structure

fmesh-examples/
├── fibonacci/
│   ├── main.go      # Example code
│   ├── graph.dot    # Graphviz source (generated)
│   └── graph.svg    # Visual diagram (generated)
├── electric_circuit/
│   └── main.go
└── can_bus/
    ├── basic/main.go
    └── advanced/
        ├── main.go
        └── can/     # Reusable CAN components

Each example is a standalone Go program. Visualization files (graph.dot and graph.svg) are generated using make graph.


Contributing

We welcome new examples from any domain: simulations, data processing, protocols, algorithms, or real-world systems.

How to Contribute

  1. Fork this repository

  2. Create a new directory for your example:

    mkdir my_example
    cd my_example
  3. Write your example in main.go:

    • Follow existing patterns
    • Add comments explaining the scenario and concepts
    • Keep it focused on one concept
  4. Generate visualization (optional):

    cd my_example
    go run . --graph
  5. Test your example:

    go run .
  6. Update README.md:

    • Add your example to the Examples table with a brief description
  7. Submit a pull request

Example Template

package main

import (
    "fmt"
    "github.com/hovsep/fmesh"
    "github.com/hovsep/fmesh/component"
    "github.com/hovsep/fmesh/signal"
)

// Description of what this example demonstrates.
// Run: go run .

func main() {
    fm := fmesh.New("example").
        AddComponents(
            component.New("processor").
                AddInputs("in").
                AddOutputs("out").
                WithActivationFunc(func(c *component.Component) error {
                    // Your logic here
                    return nil
                }),
        )
    
    // Connect, initialize, run, and display results
}

Guidelines

  • One concept per example
  • Well-commented code explaining the "why"
  • Real-world scenarios preferred
  • Self-contained and tested

Resources


License

MIT License - see LICENSE file for details.


Built with F-Mesh v1.4.0

Questions? Open an issue or check the wiki

About

Examples of fmesh library usage

Resources

License

Stars

Watchers

Forks

Packages

No packages published