{"id":23651318,"url":"https://github.com/damiancipolat/redis_pubsub_node","last_synced_at":"2026-02-26T03:50:42.797Z","repository":{"id":40720559,"uuid":"259087803","full_name":"damiancipolat/Redis_PUBSUB_node","owner":"damiancipolat","description":"A complete example of event sourcing using redis pub/sub features with docker and nodejs + Typescript. In this situation we will create a SMS send distributed service.","archived":false,"fork":false,"pushed_at":"2023-01-06T04:28:02.000Z","size":175,"stargazers_count":2,"open_issues_count":7,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-21T11:54:18.086Z","etag":null,"topics":["docker","nodejs","pubsub","redis","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"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":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-26T17:09:35.000Z","updated_at":"2021-01-11T17:10:07.000Z","dependencies_parsed_at":"2023-02-05T07:31:21.934Z","dependency_job_id":null,"html_url":"https://github.com/damiancipolat/Redis_PUBSUB_node","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/damiancipolat/Redis_PUBSUB_node","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damiancipolat%2FRedis_PUBSUB_node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damiancipolat%2FRedis_PUBSUB_node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damiancipolat%2FRedis_PUBSUB_node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damiancipolat%2FRedis_PUBSUB_node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/damiancipolat","download_url":"https://codeload.github.com/damiancipolat/Redis_PUBSUB_node/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damiancipolat%2FRedis_PUBSUB_node/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29848654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T22:37:40.667Z","status":"online","status_checked_at":"2026-02-26T02:00:06.774Z","response_time":89,"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":["docker","nodejs","pubsub","redis","typescript"],"created_at":"2024-12-28T16:37:04.909Z","updated_at":"2026-02-26T03:50:42.760Z","avatar_url":"https://github.com/damiancipolat.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://github.com/damiancipolat/Redis_PUBSUB_node/blob/master/doc/logo.png?raw=true\" width=\"150px\" align=\"right\" /\u003e\n\n# SMS distributed services using redis PUB/SUB\nAn example of event sourcing using redis pub/sub features with docker and nodejs + Typescript. In this situation we will create a SMS send distributed service.\n\n## Stack:\nOur stack will be:\n- Node.js v12.0\n- Express\n- Docker + docker-compose\n- TypeScript\n- redis native client.\n- redis tools.\n- Mocks: mocky.io to simulate sms provider integration in a real example we can use aws/sns to send real sms or twilio.\n\n## Architecture:\nThere are two differents blocks.\n- **Api rest**: Receive sms message send request and pubslish into the redis queue.\n- **Workers**: Differents instances of a same nodejs docker image running in parralel, in this part we are working with mocked rest services rest services.\n\n### Pub - sub design:\nAll the server and workers run into a docker container, in the workers we user docker-compouse in scale mode.\n\n\u003cimg src=\"https://github.com/damiancipolat/Redis_PUBSUB_node/blob/master/doc/pub-sub-redis.png?raw=true\" align=\"center\" /\u003e\n\nIn this diagram, we are focusing the events architecture to create a async flow using events, I'm using the pub/sub **channels** as event queue.\n\n### Channels:\n- **SMS**: Used to publish a sms to be sent.\n- **SMS_OK**: Is published when the sms was sent succefull.\n- **SMS_FAIL**: Is published when the provider fail sending the sms, we can use this to make retries.\n\n### Events diagram:\n\u003cimg src=\"https://github.com/damiancipolat/Redis_PUBSUB_node/blob/master/doc/pub-sub-redis-events.png?raw=true\" align=\"center\" /\u003e\n\n## Environment:\nTo run the projec follow the next commands.\n\n```sh\n#To run, using a scaling group as a daemon.\ndocker-compose up --scale workers=3 -d\n```\n- Api server: **port 8000**.\n- Redir: **port 6379**.\n- Workers: **port range 8000-9000**.\n\n## Request:\n\n### **Send a SMS**:\n```sh\ncurl --location --request POST 'http://127.0.0.1:8000/sms' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n\t\"number\":\"+541166587382\",\n\t\"text\":\"hello damian\"\n}'\n```\n\nReponse, the response have this format is an asyncronic process, so you have to make polling to detected when success.\n```json\n{\n    \"uuid\": \"sms-1588048730269\",\n    \"number\": \"+541166587382\",\n    \"text\": \"hello damian\"\n}\n```\n\n### **Get sms send status by uuid**:\n```sh\ncurl --location --request GET 'http://127.0.0.1:8000/key/{uuid}'\n\n#Example:\ncurl --location --request GET 'http://127.0.0.1:8000/key/sms-1588048730269'\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdamiancipolat%2Fredis_pubsub_node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdamiancipolat%2Fredis_pubsub_node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdamiancipolat%2Fredis_pubsub_node/lists"}