{"id":22686452,"url":"https://github.com/zflow-dev/zflow","last_synced_at":"2025-08-07T00:32:52.369Z","repository":{"id":83616063,"uuid":"578318462","full_name":"zflow-dev/zflow","owner":"zflow-dev","description":"Flow Based Low/No Code Workflow and Robotic Process Automation Library","archived":false,"fork":false,"pushed_at":"2024-06-05T10:25:49.000Z","size":29479,"stargazers_count":69,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-02T09:07:38.675Z","etag":null,"topics":["dag","fbp","flowbased","low-code","no-code","rust","visual-programming"],"latest_commit_sha":null,"homepage":"http://zflow.dev","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zflow-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"darmie","patreon":"dami476"}},"created_at":"2022-12-14T19:13:55.000Z","updated_at":"2024-11-30T21:36:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"929fbe36-0222-4417-ac57-b20c9915c885","html_url":"https://github.com/zflow-dev/zflow","commit_stats":null,"previous_names":["zflow-dev/zflow"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zflow-dev%2Fzflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zflow-dev%2Fzflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zflow-dev%2Fzflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zflow-dev%2Fzflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zflow-dev","download_url":"https://codeload.github.com/zflow-dev/zflow/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228976848,"owners_count":18000682,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dag","fbp","flowbased","low-code","no-code","rust","visual-programming"],"created_at":"2024-12-09T23:01:31.522Z","updated_at":"2024-12-09T23:01:51.324Z","avatar_url":"https://github.com/zflow-dev.png","language":"Rust","readme":"\u003c!-- ![Build](https://github.com/darmie/zflow/actions/workflows/build.yml/badge.svg) --\u003e\n![zflow_graph](https://github.com/darmie/zflow/actions/workflows/graph.yml/badge.svg) \n![zflow_untime](https://github.com/darmie/zflow/actions/workflows/runtime.yml/badge.svg)\n![FBP Spec](https://github.com/darmie/zflow/actions/workflows/fbp.yml/badge.svg)\n\n# ZFlow - Flow-Based Programming Library\n\nThis library provides a Rust implementation of a [Flow-Based Programming graphs](https://flow-based.org/) and a runtime for executing the graph. There are two areas covered:\n\n* [Graph](https://github.com/darmie/zflow/blob/main/zflow_graph) - the actual graph library\n* [Journal trait](https://github.com/darmie/zflow/blob/main/zflow_graph/src/journal.rs) - journal system for keeping track of graph changes and undo history\n* [Graph Runtime](https://github.com/darmie/zflow/blob/main/zflow_runtime) - the process runtime to execute graph components\n\n## Graph Usage \n```rust\nlet mut g = Graph::new(\"Foo bar\", true);\n// listen to the graph add_node event\ng.connect(\"add_node\", |this, data|{\n    if let Ok(node) = GraphNode::deserialize(data){\n        assert_eq!(node.id, \"Foo\");\n        assert_eq!(node.component, \"Bar\");\n    }\n}, true);\n// add a node\ng.add_node(\"Foo\", \"Bar\", None);\n\n// listen to the add_edge event\ng.connect(\"add_edge\", |this, data|{\n    if let Ok(edge) = GraphEdge::deserialize(data){\n        assert_eq!(edge.from.node_id, \"Foo\");\n        assert_eq!(edge.to.port, \"In\");\n    }\n});\n\n// add node with ID `Foo` and Component named `foo`\ng.add_node(\"Foo\", \"foo\", None);\n// add node with ID `Bar` and Component named `bar`\ng.add_node(\"Bar\", \"bar\", None);\n// add a connection between `Foo` and `Bar` by their output port and input ports respectively.\ng.add_edge(\"Foo\", \"Out\", \"Bar\", \"In\", None);\n```\nSee [graph_test.rs](https://github.com/darmie/zflow/blob/main/zflow_graph/src/graph_test.rs) for more usage examples\n\n## Journal Usage\n```rs\nlet mut graph = Graph::new(\"\", false);\n// start recording events in the graph to the memory journal\ngraph.start_journal(None);\ngraph.add_node(\"Foo\", \"Bar\", None);\ngraph.add_node(\"Baz\", \"Foo\", None);\ngraph.add_edge(\"Foo\", \"out\", \"Baz\", \"in\", None);\ngraph.add_initial(json!(42), \"Foo\", \"in\", None);\ngraph.remove_node(\"Foo\");\n\n// move to initial state in journal history\ngraph.move_to_revision(0);\n// move to second revision in journal history\ngraph.move_to_revision(2);\n// move to fifth revision in journal history\ngraph.move_to_revision(5);\n```\nSee [journal.rs](https://github.com/darmie/zflow/blob/main/zflow_graph/src/journal.rs#L1013) for more usage examples\n\n## Graph Runtime example \nSome details may be hidden for brevity\n```rs\n// Create a component\nlet mut my_component = Component::new(ComponentOptions {\n    forward_brackets:HashMap::new(),\n    // set input port `in`\n    in_ports: HashMap::from([(\n        \"in\".to_string(),\n        InPort::default(),\n    )]),\n    // set output port `out`\n    out_ports: HashMap::from([(\n        \"out\".to_string(),\n        OutPort::default(),\n    )]),\n    process: Box::new(move |this| {\n        if let Ok(handle) = this.try_lock().as_mut() {\n            // get something from input port\n            if let Some(input_data) = handle.input().get(\"in\") {\n                // \u003cdo stuff\u003e\n            }\n            // send output\n            handle.output().send(\u0026(\"out\", json!(\"Hello World!\")));\n        }\n        Ok(ProcessResult::default())\n    }),\n    ..ComponentOptions::default()\n});\n```\n\nConnect another component to `my_component` and run the network\n\n```rs\n// another component\nlet mut second_component = Component::new(ComponentOptions {...});\n\n// setup the fbp graph\nlet mut graph = Graph::new(\"\", false);\ng.add_node(\"first_component\", \"first_component_process\", None)\n .add_node(\"second_component\", \"second_component_process\", None)\n  // trigger the first component with an initial packet\n .add_initial(json!(\"start\"), \"first_component\", \"in\", None)\n  // send the output of `first_component` to the input of the `second_component`\n .add_edge(\"first_component\", \"out\", \"second_component\", \"in\", None);\n\n// create a network to run this graph\nlet mut network = Network::create(graph.clone(), NetworkOptions {\n    subscribe_graph: false,\n    delay: true,\n    base_dir: \"/\".to_string(),\n    ..Default::default()\n});\n\n// register the components to the node ids\nlet loader = network.get_loader();\nloader.register_component(\"first_component\", \"first_component_process\", my_component).unwrap();\nloader.register_component(\"second_component\", \"second_component_process\", second_component).unwrap();\n\n// sync graph with network\nif let Ok(nw) = network.connect().unwrap().try_lock() {\n    // start the network\n    nw.start().unwrap();\n}\n```\n\nSee [full example](https://github.com/darmie/zflow/blob/main/zflow_runtime/src/component_test.rs#L396) that demonstrates generation of an HTML code using ZFlow.\n","funding_links":["https://github.com/sponsors/darmie","https://patreon.com/dami476"],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzflow-dev%2Fzflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzflow-dev%2Fzflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzflow-dev%2Fzflow/lists"}