{"id":26794655,"url":"https://github.com/kacemmathlouthi/rabbitmq-tp2","last_synced_at":"2026-05-04T02:32:00.733Z","repository":{"id":281749925,"uuid":"946223592","full_name":"KacemMathlouthi/RabbitMQ-TP2","owner":"KacemMathlouthi","description":"This project implements a Distributed Sales Synchronization System using RabbitMQ and MySQL to synchronize sales data from multiple branch databases to a central head office database.","archived":false,"fork":false,"pushed_at":"2025-03-10T23:50:23.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-11T00:28:37.342Z","etag":null,"topics":["distributed-systems","mysql","pika","python","rabbitmq"],"latest_commit_sha":null,"homepage":"","language":"Python","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/KacemMathlouthi.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":"2025-03-10T20:04:22.000Z","updated_at":"2025-03-10T23:50:26.000Z","dependencies_parsed_at":"2025-03-11T00:38:41.407Z","dependency_job_id":null,"html_url":"https://github.com/KacemMathlouthi/RabbitMQ-TP2","commit_stats":null,"previous_names":["kacemmathlouthi/rabbitmq-tp2"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KacemMathlouthi%2FRabbitMQ-TP2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KacemMathlouthi%2FRabbitMQ-TP2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KacemMathlouthi%2FRabbitMQ-TP2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KacemMathlouthi%2FRabbitMQ-TP2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KacemMathlouthi","download_url":"https://codeload.github.com/KacemMathlouthi/RabbitMQ-TP2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246218503,"owners_count":20742386,"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","mysql","pika","python","rabbitmq"],"created_at":"2025-03-29T17:28:24.314Z","updated_at":"2026-05-04T02:32:00.703Z","avatar_url":"https://github.com/KacemMathlouthi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Distributed Database Synchronization System\n\nThis project implements a **Distributed Sales Synchronization System** using **RabbitMQ and MySQL** to synchronize sales data from multiple branch databases to a central head office database.\n\n## **Project Overview**\n\nThe system consists of:\n- **Branch Databases (branch1, branch2)**: Each branch stores sales data independently.\n- **Head Office Database**: Aggregates all sales from branches.\n- **RabbitMQ Broker**: Facilitates message-based communication between branches and the head office.\n- **Producers (Branch Sync)**: Reads sales data from branch databases and publishes them to RabbitMQ.\n- **Consumer (Head Office Sync)**: Listens to RabbitMQ and stores sales data in the head office database.\n- **Web UI (Gradio-based Dashboard)**: Provides real-time monitoring and control of synchronization.\n\n## **Project Structure**\n\n```bash\n.\n├── Dockerfile\n├── docker-compose.yml\n├── app\n│   ├── main.py\n│   ├── config.py\n│   ├── consumer.py\n│   ├── db_connector.py\n│   ├── producer.py\n│   ├── requirements.txt\n├── db_init\n│   ├── branch1.sql\n│   ├── branch2.sql\n│   ├── head_office.sql\n└── README.md\n```\n\n## **Installation \u0026 Setup**\n\n### **1. Prerequisites**\n- **Docker \u0026 Docker Compose** installed.\n- **RabbitMQ** should be running as a container.\n- **MySQL** installed for local testing (or use a MySQL container).\n\n### **2. Clone the Repository**\n```bash\ngit clone https://github.com/KacemMathlouthi/RabbitMQ-TP2.git\ncd RabbitMQ-TP2\n```\n\n### **3. Run the Application**\n```bash\ndocker-compose up --build\n```\nThis will start **RabbitMQ, MySQL, and the application containers**.\n\n## **Configuration**\n\nAll configurations are stored in **`app/config.py`**:\n\n## **How It Works**\n\n### **1. Producers (Branch Sync)**\n- Each branch has a **producer** that reads sales data and sends it to RabbitMQ.\n- Runs **automatically or manually** via the Gradio UI.\n\n### **2. Consumer (Head Office Sync)**\n- Listens to RabbitMQ queues and inserts sales into the head office database.\n- Prevents duplicate sales using **`original_sale_id` and `source_branch`**.\n\n### **3. UI Dashboard**\n- Provides options to **start/stop consumers, sync branches manually, and monitor sales**.\n- Built with **Gradio** for a user-friendly interface.\n- Access via **http://localhost:7860** (or the configured port).\n\n## **Future Enhancements**\n- ✅ Implement **batch processing** for better performance.\n- ✅ Add **asynchronous RabbitMQ handling**.\n- ✅ Implement **retry mechanisms for failed syncs**.\n\n## **License**\nThis project is licensed under the **MIT License**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkacemmathlouthi%2Frabbitmq-tp2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkacemmathlouthi%2Frabbitmq-tp2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkacemmathlouthi%2Frabbitmq-tp2/lists"}