{"id":16656621,"url":"https://github.com/sheharyarn/ztd","last_synced_at":"2025-04-09T18:21:59.455Z","repository":{"id":70981794,"uuid":"136794586","full_name":"sheharyarn/ztd","owner":"sheharyarn","description":"Distributed real-time Todo App over RabbitMQ in Elixir 🐰⚡️🌐💧💻","archived":false,"fork":false,"pushed_at":"2018-06-16T06:57:07.000Z","size":101,"stargazers_count":24,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T20:22:21.111Z","etag":null,"topics":["distributed-systems","elixir","phoenix","rabbitmq","real-time","websockets"],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/sheharyarn.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-10T09:11:59.000Z","updated_at":"2023-10-16T22:35:13.000Z","dependencies_parsed_at":"2023-05-02T16:01:35.843Z","dependency_job_id":null,"html_url":"https://github.com/sheharyarn/ztd","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/sheharyarn%2Fztd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheharyarn%2Fztd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheharyarn%2Fztd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheharyarn%2Fztd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sheharyarn","download_url":"https://codeload.github.com/sheharyarn/ztd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085637,"owners_count":21045191,"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":["distributed-systems","elixir","phoenix","rabbitmq","real-time","websockets"],"created_at":"2024-10-12T09:57:58.681Z","updated_at":"2025-04-09T18:21:59.446Z","avatar_url":"https://github.com/sheharyarn.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"ZTD\n===\n\n[![Build Status][shield-travis]][travis-ci]\n[![License][shield-license]][github]\n\n\u003e Todo App written in Elixir/Phoenix using RabbitMQ\n\nThis is a small experiment using RabbitMQ. The app is designed to be run in\none of two modes; `Engine` and `Worker`. When run in Engine mode, the app\nstores and reads items from disk. When run in Worker mode, the app doesn't\nhave it's own state, instead it listens to events from the engine and\ndispatches events to it when actions are performed.\n\n**Demo:**\n\n[![ZTD Demo Video][demo-thumb]][demo-video]\n\n\u003cbr\u003e\n\n\n\n\n## Setup\n\nFollowing dependencies are required:\n\n - Erlang 20+\n - Elixir 1.6+\n - Postgres\n - RabbitMQ\n\nCompile Application and Assets:\n\n```bash\n$ mix do deps.get, compile\n$ mix do ecto.create, ecto.migrate\n$ cd assets \u0026\u0026 npm install\n```\n\n\u003cbr\u003e\n\n\n\n\n## Running the App\n\nTo start the app in `Engine` mode:\n\n```bash\n$ PORT=4000 APP_MODE=engine mix phx.server\n```\n\nTo start it in `Worker` mode:\n\n```bash\n$ PORT=5000 APP_MODE=worker mix phx.server\n```\n\nYou can also use [`foreman`][foreman] to run multiple instances easily.\nThis will start the engine on port `4000` and 4 workers on ports `5001`,\n`5002`, `5003` \u0026 `5004`:\n\n```bash\n$ gem install foreman\n$ foreman start\n```\n\n\u003cbr\u003e\n\n\n\n\n## Implementation Details\n\nThe application exports one main module `Todo`, whose implementation is\nfurther organized into two adapters `Engine` and `Worker`. Depending on\nthe mode the application is started in, the supervisor only boots those\nprocesses, and the Todo module delegates the function calls to the\nappropriate adapter. Since the Web UI only directly interacts with the\n`Todo` module, so it does not concern itself with the implementation.\n\nWhen the application is running in the Engine mode, it stores and reads\nitems from the Postgres database. Actions performed via the Todo\ninterface are wrapped in an `Event` struct, and when successful, are\nbroadcasted both on all open Phoenix channels as well as on a RabbitMQ\nfanout exchange.\n\nWhen run in Worker mode, the app does not have its own state, volatile\nor non-volatile. This is by design. It gets initial list of items via\nan RPC call implmented over RabbitMQ and listens for events on the\nfanout exchange. When actions are performed, they are again wrapped as\nevents and dispatched to the Engine where when successfully performed,\nare broadcasted and received backed by all workers. This also acts as\nan acknowledgement.\n\nAdmittedly, the app is not \"truly distributed\" since each worker does\nnot have its own state, and does not have any kind of partition\ntolerance. Other than that, something like CQRS would be a great way\nto ensure consistency.\n\n\u003cbr\u003e\n\n\n\n\n## Testing and Contributing\n\nThe app consists of a very modest test suite. You can run them with mix:\n\n```bash\n$ mix test\n```\n\nYou can also help by contributing to the project:\n\n - [Fork][github-fork], Enhance, Send PR\n - Lock issues with any bugs or feature requests\n - Implement something from Roadmap\n - Spread the word :heart:\n\n\u003cbr\u003e\n\n\n\n\n## License\n\nThe code is available as open source under the terms of the [MIT License][license].\n\n\u003cbr\u003e\n\n\n\n\n  [shield-license]:   https://img.shields.io/github/license/sheharyarn/ztd.svg\n  [shield-travis]:    https://img.shields.io/travis/sheharyarn/ztd/master.svg\n  [travis-ci]:        https://travis-ci.org/sheharyarn/ztd\n\n  [license]:          https://opensource.org/licenses/MIT\n  [foreman]:          https://github.com/ddollar/foreman\n  [github]:           https://github.com/sheharyarn/ztd/\n  [github-fork]:      https://github.com/sheharyarn/ztd/fork\n\n  [demo-thumb]:       https://i.imgur.com/wfYayRul.png\n  [demo-video]:       https://to.shyr.io/2tebNiP\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsheharyarn%2Fztd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsheharyarn%2Fztd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsheharyarn%2Fztd/lists"}