{"id":17810757,"url":"https://github.com/favourdaniel/messaging-system","last_synced_at":"2025-07-31T09:37:35.776Z","repository":{"id":248138793,"uuid":"827867348","full_name":"FavourDaniel/messaging-system","owner":"FavourDaniel","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-13T19:17:32.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T06:43:57.225Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/FavourDaniel.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-12T14:51:01.000Z","updated_at":"2024-07-13T19:17:34.000Z","dependencies_parsed_at":"2024-10-27T16:12:35.565Z","dependency_job_id":"ff401560-70b0-40ad-afcc-0f2ee62b509f","html_url":"https://github.com/FavourDaniel/messaging-system","commit_stats":null,"previous_names":["favourdaniel/messaging-system"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/FavourDaniel/messaging-system","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FavourDaniel%2Fmessaging-system","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FavourDaniel%2Fmessaging-system/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FavourDaniel%2Fmessaging-system/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FavourDaniel%2Fmessaging-system/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FavourDaniel","download_url":"https://codeload.github.com/FavourDaniel/messaging-system/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FavourDaniel%2Fmessaging-system/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268017357,"owners_count":24181669,"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-07-31T02:00:08.723Z","response_time":66,"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":[],"created_at":"2024-10-27T15:40:15.850Z","updated_at":"2025-07-31T09:37:35.751Z","avatar_url":"https://github.com/FavourDaniel.png","language":"Python","readme":"# Messaging System with RabbitMQ/Celery and Python Application behind Nginx\n\nThis deploys a Python application behind Nginx that interacts with RabbitMQ/Celery for email sending and logging functionality. The below architecture diagram visualizes the process:\n![app-architecture](https://github.com/user-attachments/assets/7c964cc8-27ed-47b0-9119-cde2c41d5ec8)\n\n\n## Set up RabbitMQ Locally\n\n- Install RabbitMQ:\n```\nbrew install rabbitmq ##for macOS users\n```\n- Start RabbitMQ:\n```\n# starts a local RabbitMQ node\nbrew services start rabbitmq\n```\n- Access RabbitMQ on http://localhost:15672/\n\n\u003cimg width=\"1675\" alt=\"Screenshot 2024-07-12 at 20 29 55\" src=\"https://github.com/user-attachments/assets/a4c5a5c3-a2b1-4e02-8d9b-a5613829a77d\"\u003e\n\n\nThe default login credential for both the username and password is \"guest\".\n\n\n## Set up Celery\n\nCelery is an asynchronous task queue/job queue system for Python, designed to handle real-time operations. It can be used to schedule tasks that run in the background, allowing for concurrency and parallel execution of code.\n\nCelery is a Python package so it will be installed with pip. This will be done in a virtual environment.\n\n- Create and activate a Python virtual environment\n```\npython3 -m venv myenv\nsource myenv/bin/activate\n```\n\n- Install Celery and other requirements from the requirements.txt file\n```\npip install -r requirements.txt\n```\n\n## Setup and Start the Python application\nThe provided Python application creates a simple web application that does two things:\n\n1. Sends Emails: It allows you to trigger the sending of an email by visiting a specific URL in your web browser. The email sending itself happens in the background through Celery. Celery is configured to use RabbitMQ as its message broker (where it keeps track of tasks). It creates an email message, connects to a Gmail SMTP server, logs in, and sends the email.\n\n2. Logs Time: It also has a feature to log the current time to a file when you visit another specific URL.\n\n\n### Email setup\nYou can use an existing email address or create a new one. Configure 2FA for whichever.\nIn the email settings, search \"App Password\" and create an App password. Be sure to copy the password somewhere.\n\n\u003cimg width=\"1040\" alt=\"Screenshot 2024-07-13 at 08 01 24\" src=\"https://github.com/user-attachments/assets/d75fc657-ccb6-47af-9767-0932bfa7afb0\"\u003e\n\n\u003cimg width=\"1333\" alt=\"Screenshot 2024-07-13 at 08 02 16\" src=\"https://github.com/user-attachments/assets/cc4ca3f5-e095-450b-b55c-4a7e34b93d12\"\u003e\n\nA `.env.template` file has been provided in this repo. Change the name to `.env` and replace the email and app password env variables.\n\n## Set Up Log Directory\nThe time logs should be logged at `/var/log/messaging_system.log`. This path has already been set in the app to be created if it doesn't exist but you can configure it manually using the below commands:\n```\nsudo touch /var/log/messaging_system.log\nsudo chmod a+rw /var/log/messaging_system.log\n```\nThe code has already been written to do this, but you can run these commands if you want a manual approach.\n\n### Install Nginx\nInstall Nginx on your local and replace the default `nginx.conf` file with the one provided in this repo. This allows Nginx to route requests from localhost:5000 where the flask app will be running.\n\n### Start the Application\n- In your terminal, run:\n```\npython app.py  --port 5000\n```\n\n- In another terminal, run:\n```\ncelery -A app.celery worker --loglevel=info\n```\n\n- Access the app at `localhost`\n\u003cimg width=\"1680\" alt=\"Screenshot 2024-07-13 at 13 45 51\" src=\"https://github.com/user-attachments/assets/0c93e172-ec4c-4e52-8b72-ceb05ffcbd77\"\u003e\n\n  \n- In another tab, load `http://localhost:5000/?talktome=true` to generate time logs\n\n\u003cimg width=\"736\" alt=\"Screenshot 2024-07-12 at 21 55 28\" src=\"https://github.com/user-attachments/assets/1775c5fe-00d5-485d-83a2-64d5dee0f8c1\"\u003e\n\n- In another tab, load `http://localhost:5000/?sendmail=kuberneteslinux@gmail.com`\n\u003cimg width=\"737\" alt=\"Screenshot 2024-07-12 at 21 56 22\" src=\"https://github.com/user-attachments/assets/93da44a2-cd1e-4065-9b4c-a1d6730f79e7\"\u003e\n\n- Check RabbitMQ to be sure it was queued successfully\n\u003cimg width=\"1680\" alt=\"Screenshot 2024-07-13 at 13 56 38\" src=\"https://github.com/user-attachments/assets/149662c3-822e-4680-b3aa-11d74ceb93ec\"\u003e\n\nAfter some seconds, it should change to ready\n\u003cimg width=\"1680\" alt=\"Screenshot 2024-07-13 at 13 56 47\" src=\"https://github.com/user-attachments/assets/906b8595-20ac-46aa-bade-9aaa0e52b5c6\"\u003e\n\nIf you check the terminal where Celery is running, you should see the below:\n\n\u003cimg width=\"1334\" alt=\"Screenshot 2024-07-12 at 21 58 24\" src=\"https://github.com/user-attachments/assets/b06898ae-36c0-4263-b07e-b3f839ba4a6a\"\u003e\n\nThis indicates that the email-sending task was received, processed by a specific Celery worker (ForkPoolWorker-8), and completed successfully.\n\n- Check your email address for the mail sent\n\n\u003cimg width=\"1402\" alt=\"Screenshot 2024-07-12 at 22 04 06\" src=\"https://github.com/user-attachments/assets/174edfe6-db12-4d2d-8f21-7a7733d8fafc\"\u003e\n\n## Setup Ngrok\n\n- Install ngrok via Homebrew with the following command:\n```\nbrew install ngrok/ngrok/ngrok\n```\n- Connect your account\nNext, connect your ngrok agent to your ngrok account. If you haven't already, sign up for an ngrok account. Copy your ngrok authtoken from your ngrok dashboard.\nRun the following command in your terminal to install the authtoken and connect the ngrok agent to your account.\n\n```\nngrok config add-authtoken \u003cTOKEN\u003e\n```\n- Create a static domain\n\nYou can create a free one on your ngrok dashboard under the setup and installation tab.\n\n\u003cimg width=\"948\" alt=\"Screenshot 2024-07-12 at 21 52 40\" src=\"https://github.com/user-attachments/assets/7d19b1cf-f354-4de9-9e5b-9d2ea2c511c7\"\u003e\n\nCopy and paste command displayed\n```\nngrok http --domain=\u003cunique-domain.ngrok-free.app\u003e 80\n```\n\u003cimg width=\"1440\" alt=\"Screenshot 2024-07-12 at 21 47 32\" src=\"https://github.com/user-attachments/assets/81d108e6-fb6f-4833-8319-bb930b714935\"\u003e\n\n- Copy and open the URL in your browser\n\u003cimg width=\"1677\" alt=\"Screenshot 2024-07-12 at 20 54 12\" src=\"https://github.com/user-attachments/assets/64a1215e-fe10-4f80-b41e-1b189fbd5fed\"\u003e\n\n- Click on the `Visit Site` button to access your website\n\u003cimg width=\"1680\" alt=\"Screenshot 2024-07-13 at 13 45 28\" src=\"https://github.com/user-attachments/assets/32b0cadc-6112-4cbf-a6bf-be60b33dab57\"\u003e\n\n- Access the time logs using the url\n\u003cimg width=\"1012\" alt=\"Screenshot 2024-07-13 at 13 50 16\" src=\"https://github.com/user-attachments/assets/f4977c87-5693-4cd4-a90d-f8b207dff98a\"\u003e\n\n- Send an email\n\u003cimg width=\"1012\" alt=\"Screenshot 2024-07-13 at 13 50 40\" src=\"https://github.com/user-attachments/assets/5bc8f8cf-d634-4693-b3cc-ce00ba4436b1\"\u003e\n\n- You can also access your Ngrok dashboard at `localhost:4040`\n\u003cimg width=\"1680\" alt=\"Screenshot 2024-07-13 at 13 52 13\" src=\"https://github.com/user-attachments/assets/6a753170-773a-4acc-b145-1b1987339d27\"\u003e\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffavourdaniel%2Fmessaging-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffavourdaniel%2Fmessaging-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffavourdaniel%2Fmessaging-system/lists"}