{"id":26028597,"url":"https://github.com/jerems/flow","last_synced_at":"2026-05-29T06:31:05.661Z","repository":{"id":57713749,"uuid":"97833316","full_name":"JeremS/flow","owner":"JeremS","description":"Barebones dataflow in clojure(script)","archived":false,"fork":false,"pushed_at":"2017-07-20T23:17:02.000Z","size":19,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-06T17:18:48.684Z","etag":null,"topics":["clojure","clojurescript"],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JeremS.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-20T12:34:56.000Z","updated_at":"2024-12-20T02:30:54.000Z","dependencies_parsed_at":"2022-08-25T12:51:41.415Z","dependency_job_id":null,"html_url":"https://github.com/JeremS/flow","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JeremS%2Fflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JeremS%2Fflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JeremS%2Fflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JeremS%2Fflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JeremS","download_url":"https://codeload.github.com/JeremS/flow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242250943,"owners_count":20096898,"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":["clojure","clojurescript"],"created_at":"2025-03-06T17:18:51.573Z","updated_at":"2025-12-08T06:02:01.749Z","avatar_url":"https://github.com/JeremS.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flow\n\n\n[![Clojars Project](https://img.shields.io/clojars/v/jeremys/flow.svg)](https://clojars.org/jeremys/flow)\n\nThis library provides a simple dataflow engine. It is created with\nom-next's default db format in mind. However since this db format is\njust Clojure data...\n\n\n## Usage\n\nHere is part of the example used in the devcards.\n\nYou have a db that looks like this:\n```clojure\n(def init-data\n  {:parameters {:turnover 1000}\n   :charges [[:charges/by-id 1]]\n   :charges/by-id {1 {:id 1 :name \"Marketing\" :cost 100}}})\n```\n\nYou want to have reactions that add the charges and compute what is\nleft of the turnover after these charges.\n\nYou start by defining reactions:\n\n```clojure\n(defn compute-total-charges\n  [{:keys [charges-table]}]\n  (transduce (map :cost)\n             +\n             (vals charges-table)))\n\n(def total-charges\n  {:name :total-charges\n   :srcs {[:charges/by-id] :charges-table}\n   :dest [:computed :total-charges]\n   :fn compute-total-charges})\n\n\n(defn compute-result\n  [{:keys [t cs]}]\n  (- t cs))\n\n(def result\n  {:name :result\n   :srcs {[:computed :total-charges] :cs\n          [:parameters :turnover] :t}\n   :dest [:computed :result]\n   :fn compute-result})\n```\n\nThen you build a dataflow system:\n\n```clojure\n(require '[flow.core :as flow]\n\n(def system\n  (-\u003e flow/empty-system\n      (flow/add-reactions [total-charges  result])\n      (flow/ready-system)))\n```\n\nand use it\n\n```clojure\n(def db (flow/execute-system init-data system #{flow/whole-db}))\n\ndb\n;=\u003e\n{:parameters {:turnover 1000},\n :charges [[:charges/by-id 1]],\n :charges/by-id {1 {:id 1, :name \"Marketing\", :cost 100}},\n :computed {:total-charges 100, :result 900}}\n\n(def db2\n  (-\u003e db\n      (assoc-in [:charges/by-id 2] {:id 2 :name \"travel expenses\" :cost 200})\n      (flow/execute-system system #{[:charges/by-id 2]})))\n\ndb2\n;=\u003e\n{:parameters {:turnover 1000},\n :charges [[:charges/by-id 1]],\n :charges/by-id\n {1 {:id 1, :name \"Marketing\", :cost 100},\n  2 {:id 2, :name \"travel expenses\", :cost 200}},\n :computed {:total-charges 300, :result 700}}\n```\n\n\nThe `execute-system` function takes 3 arguments:\n- a db\n- a system\n- a set of paths indicating where the change happened so that only\nthe relevant reactions are run.\n\nThere is more information in the devcards.\n\n## Running devcards\nClone this repo then:\n\n```\nlein run -m clojure.main scripts/repl.clj\n```\n\nOpen [this link](http://localhost:3449/devcards.html).\n\n\n## License\n\nCopyright © 2017 Jérémy Schoffen\n\nDistributed under the Eclipse Public License (see LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjerems%2Fflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjerems%2Fflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjerems%2Fflow/lists"}