{"id":23651353,"url":"https://github.com/damiancipolat/node-event-saga","last_synced_at":"2025-09-01T02:32:06.884Z","repository":{"id":40727430,"uuid":"242657301","full_name":"damiancipolat/Node-event-saga","owner":"damiancipolat","description":"An implementation of the SAGA pattern using event driven architecture, created within a single nodejs process.","archived":false,"fork":false,"pushed_at":"2023-03-02T18:32:57.000Z","size":204,"stargazers_count":11,"open_issues_count":4,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T07:11:46.856Z","etag":null,"topics":["architecture","event-driven-architecture","nodejs","patterns-design","saga","saga-pattern"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/damiancipolat.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2020-02-24T05:52:12.000Z","updated_at":"2024-01-29T11:15:35.000Z","dependencies_parsed_at":"2023-02-07T12:16:19.513Z","dependency_job_id":null,"html_url":"https://github.com/damiancipolat/Node-event-saga","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/damiancipolat/Node-event-saga","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damiancipolat%2FNode-event-saga","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damiancipolat%2FNode-event-saga/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damiancipolat%2FNode-event-saga/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damiancipolat%2FNode-event-saga/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/damiancipolat","download_url":"https://codeload.github.com/damiancipolat/Node-event-saga/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damiancipolat%2FNode-event-saga/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273065036,"owners_count":25039274,"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","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["architecture","event-driven-architecture","nodejs","patterns-design","saga","saga-pattern"],"created_at":"2024-12-28T16:37:14.302Z","updated_at":"2025-09-01T02:32:06.540Z","avatar_url":"https://github.com/damiancipolat.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node-event-saga\nA custom implementation of the **SAGA** pattern using event driven architecture, created within a single nodejs process.\n\nIn this scenario the event bus is a **Event Emitter** into a nodejs process, in more complex project the bus will be sqs or sns in AWS.\nThis project are only node.js **modules** and a **scaffolding** for more realistics scenarios will be necesary to add an api rest interface.\n\nThe Fail feature or the saga is only present in some events, in a real situation all the request should have it.\n\n### **Events diagram**\nIn this diagram I show how a transaction is done through different messages. For each operation two types of SUCCESS and FAIL messages are issued, in the case of FAIL status updates are applied to maintain consistency.\n\n\u003cimg src=\"https://github.com/damiancipolat/Node-event-saga/blob/master/doc/Saga%20payment-Architecture.png?raw=true\" width=\"800px\"/\u003e\n\n#### Note:\nFor this example, I will use for mock the Order, Notification and Payment service the web mocky.io to make fake but real request.\n\n### Events dictionary\nEvents name with description.\n\n- **ORDER_CREATED**: Initial event of the payment flow.\n- **ORDER_CREATED_SUCCESS**: Sucess order creation event.\n- **ORDER_CREATED_FAIL**: Order creaation error.\n- **PAYMENT_FAIL**: Error in process payment.\n- **PAYMENT_SUCCESS**: Payment succeffull.\n- **FLOW_END**: Send email with the bill and finish the flow.\n\n#### To run:\n\n```sh\nnpm install\nnode app.js\n```\n\n#### Readings:\n- https://microservices.io/patterns/data/saga.html\n- https://itnext.io/effectively-communicate-between-microservices-de7252ba2f3c\n- https://developers.redhat.com/blog/2018/10/01/patterns-for-distributed-transactions-within-a-microservices-architecture/\n- https://blog.couchbase.com/saga-pattern-implement-business-transactions-using-microservices-part/\n- https://medium.com/@ijayakantha/microservices-the-saga-pattern-for-distributed-transactions-c489d0ac0247\n- https://itnext.io/microservices-architecture-an-implementation-of-saga-pattern-dbbe5d881c78\n- https://dzone.com/articles/distributed-sagas-for-microservices\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdamiancipolat%2Fnode-event-saga","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdamiancipolat%2Fnode-event-saga","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdamiancipolat%2Fnode-event-saga/lists"}