{"id":49232184,"url":"https://github.com/alonsoir/distributed-order-system","last_synced_at":"2026-04-24T12:17:27.829Z","repository":{"id":288589045,"uuid":"967395687","full_name":"alonsoir/distributed-order-system","owner":"alonsoir","description":"The Order Processing Service is a robust, reactive microservice designed to handle order creation and processing using a saga pattern. Built with Spring WebFlux, R2DBC, and Redis, it ensures reliable, fault-tolerant, and scalable order management in distributed environments. order-service is pub implementation. pending to build sub implementacion.","archived":false,"fork":false,"pushed_at":"2025-05-29T07:38:01.000Z","size":1177,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-29T07:49:20.385Z","etag":null,"topics":["circuit-breaker","distributed-systems","pubsub","redis","resilience4j","sagas","spring-boot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alonsoir.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-16T11:47:45.000Z","updated_at":"2025-05-29T07:38:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"b68887c5-01b0-4ad4-b94c-20ba3683bad4","html_url":"https://github.com/alonsoir/distributed-order-system","commit_stats":null,"previous_names":["alonsoir/distributed-order-system"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alonsoir/distributed-order-system","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alonsoir%2Fdistributed-order-system","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alonsoir%2Fdistributed-order-system/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alonsoir%2Fdistributed-order-system/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alonsoir%2Fdistributed-order-system/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alonsoir","download_url":"https://codeload.github.com/alonsoir/distributed-order-system/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alonsoir%2Fdistributed-order-system/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32222915,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T10:26:35.452Z","status":"ssl_error","status_checked_at":"2026-04-24T10:25:27.643Z","response_time":64,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["circuit-breaker","distributed-systems","pubsub","redis","resilience4j","sagas","spring-boot"],"created_at":"2026-04-24T12:17:26.975Z","updated_at":"2026-04-24T12:17:27.824Z","avatar_url":"https://github.com/alonsoir.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Order Processing Service\n\n[![Java](https://img.shields.io/badge/Java-17+-orange.svg)](https://openjdk.java.net/)\n[![Spring Boot](https://img.shields.io/badge/Spring%20Boot-3.2+-green.svg)](https://spring.io/projects/spring-boot)\n[![Redis](https://img.shields.io/badge/Redis-7+-red.svg)](https://redis.io/)\n[![MySQL](https://img.shields.io/badge/MySQL-8+-blue.svg)](https://www.mysql.com/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA robust, reactive microservice for order processing using the Saga pattern, built with Spring WebFlux, R2DBC, and Redis. \nDesigned for fault-tolerant, scalable order management in distributed environments.\n\n\u003e **Note**: This project was developed through collaborative human-AI programming using Claude Sonnet, representing an \n\u003e innovative approach to software development that combines human experience and judgment with AI's rapid code generation \n\u003e and optimization capabilities.\n\n## 🚀 Quick Start\n\n### Prerequisites\n- Java 17+ (tested with Java 21 and 23)\n- Maven 3.8+\n- Docker Desktop\n- MySQL 8+ and Redis 7+ (or use TestContainers)\n\n### Installation \u0026 Running\n\n```bash\n# Clone repository\ngit clone https://github.com/yourusername/distributed-order-system.git\ncd distributed-order-system\n\n# Build project\nmvn clean install\n\n# Run tests\nmvn test\n\n# Start application\nmvn spring-boot:run\n```\n\n### Docker Setup\n```bash\n# Start dependencies\ndocker-compose up -d mysql redis\n\n# Run application\n./scripts/run-local.sh\n```\n\n## 🏗️ Architecture Overview\n\n```\n┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐\n│   Order API     │───▶│ Saga Orchestr.  │───▶│  Event Publisher│\n└─────────────────┘    └─────────────────┘    └─────────────────┘\n         │                       │                       │\n         ▼                       ▼                       ▼\n┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐\n│   MySQL R2DBC   │    │ Compensation    │    │  Redis Streams  │\n│   (Orders)      │    │   Manager       │    │   + Outbox      │\n└─────────────────┘    └─────────────────┘    └─────────────────┘\n```\n\n### Key Components\n- **OrderService**: High-level facade with circuit breaker patterns\n- **SagaOrchestrator**: Core saga execution flow management\n- **CompensationManager**: Handles compensating transactions for failed steps\n- **EventPublisher**: Manages event publication with fallback mechanisms\n\n## ✨ Key Features\n\n### 🛡️ Resilience Patterns\n- **Circuit Breakers**: Per-step failure isolation\n- **Bulkheads**: Resource isolation for concurrent executions\n- **Retry Mechanisms**: Configurable back-off strategies\n- **Compensation**: Automatic rollback of partial transactions\n- **Event Outbox**: Guaranteed event delivery during Redis outages\n\n### 📊 Observability\n- **Enhanced Diagnostics**: Rich context using MDC for correlated logging\n- **Detailed Metrics**: Latency, success/failure rates, retry counters\n- **Health Checks**: Comprehensive health endpoints for monitoring\n\n### 🎯 Quality Standards\n- **Clean Architecture**: Clear separation of concerns\n- **Interface-Based Design**: Testable and maintainable code\n- **Comprehensive Testing**: Unit and integration tests with TestContainers\n- **Production-Ready**: Designed for easy troubleshooting and monitoring\n\n## 📋 Order Processing Flow\n\n```\nOrder Created → Validation → Payment → Stock Check → Shipping → Delivery → Completed\n     ↓             ↓           ↓          ↓           ↓          ↓         ↓\nCompensation  ←────────────────────────────────────────────────────────────┘\n  (if needed)\n```\n\n### State Transitions\n- **Happy Path**: `ORDER_CREATED` → `VALIDATED` → `PAYMENT_CONFIRMED` → `DELIVERED` → `COMPLETED`\n- **Failure Handling**: Automatic compensation with detailed error tracking\n- **Manual Review**: Complex failures escalated for human intervention\n\n## 🔧 Configuration\n\n### Application Profiles\n- `default`: Local development\n- `prod`: Production optimizations\n- `integration`: Integration testing with TestContainers\n- `stress`: Stress testing configuration\n\n### Environment Variables\n```bash\n# Database\nSPRING_R2DBC_URL=r2dbc:mysql://localhost:3306/orders\nSPRING_R2DBC_USERNAME=root\nSPRING_R2DBC_PASSWORD=root\n\n# Redis\nSPRING_REDIS_HOST=localhost\nSPRING_REDIS_PORT=6379\n\n# Monitoring\nMANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE=health,metrics,prometheus\n```\n\n## 📡 API Examples\n\n### Create Order\n```bash\ncurl -X POST http://localhost:8080/api/orders \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"customerId\": 12345,\n    \"items\": [{\"productId\": \"PROD-001\", \"quantity\": 2}],\n    \"totalAmount\": 99.99\n  }'\n```\n\n### Check Order Status\n```bash\ncurl http://localhost:8080/api/orders/{orderId}/status\n```\n\n### Health Check\n```bash\ncurl http://localhost:8080/actuator/health\n```\n\n## 🧪 Testing\n\n```bash\n# Unit tests\nmvn test\n\n# Integration tests with TestContainers\nmvn test -Pintegration\n\n# SonarQube analysis\nmvn clean verify sonar:sonar -Dsonar.token=YOUR_TOKEN\n\n# Stress testing\nmvn test -Pstress\n```\n\n## 📊 Monitoring \u0026 Metrics\n\n- **Health Endpoints**: `/actuator/health`\n- **Metrics**: `/actuator/metrics`\n- **Prometheus**: `/actuator/prometheus`\n\n### Key Metrics\n- `saga.execution.duration`: Saga execution time\n- `compensation.triggered.count`: Compensation events\n- `circuit.breaker.state`: Circuit breaker states\n- `event.publishing.success.rate`: Event delivery success rate\n\n## 🚨 Troubleshooting\n\n### Common Issues\n\n**Database Connection Issues**\n```bash\n# Check connectivity\ndocker exec -it mysql-container mysql -u root -p -e \"SELECT 1\"\n```\n\n**Redis Connection Issues**\n```bash\n# Check Redis\ndocker exec -it redis-container redis-cli ping\n```\n\n**Application Won't Start**\n- Verify Java version: `java --version`\n- Check port availability: `netstat -tulpn | grep 8080`\n- Review logs: `tail -f logs/application.log`\n\n## 🛣️ Roadmap\n\n- [ ] Subscriber (SUB) component implementation\n- [ ] Performance optimization for high-throughput scenarios\n- [ ] Multi-region deployment support\n- [ ] Advanced monitoring dashboards\n- [ ] Stored procedures for database operations\n\n## 🤝 Contributing\n\nWe welcome contributions! Please see [CONTRIBUTING.md](docs/CONTRIBUTING.md) for guidelines.\n\n### Development Setup\n1. Fork the repository\n2. Create a feature branch: `git checkout -b feature/amazing-feature`\n3. Make changes and add tests\n4. Run quality checks: `mvn clean verify`\n5. Submit a pull request\n\n## 📚 Documentation\n\n- [Architecture Deep Dive](docs/ARCHITECTURE.md)\n- [Deployment Guide](docs/DEPLOYMENT.md)\n- [API Documentation](docs/API.md)\n- [Performance Tuning](docs/PERFORMANCE.md)\n- [Migration Guide](docs/MIGRATION.md)\n\n## 👥 Authors\n\n- **Alonso Isidoro Roman** - *Lead Developer \u0026 Architect* - [alonsoir@gmail.com](mailto:alonsoir@gmail.com)\n- **Claude Sonnet (Anthropic)** - *AI Co-Developer* - Collaborative programming partner\n\n\u003e This project demonstrates the power of human-AI collaboration in software development, combining human experience, \n\u003e domain knowledge, and strategic thinking with AI's rapid code generation, optimization suggestions, and comprehensive \n\u003e testing capabilities.\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🙏 Acknowledgments\n\n- Spring Team for the excellent reactive framework\n- TestContainers team for simplified integration testing\n- The open-source community for inspiration and best practices\n- Anthropic for Claude Sonnet, an exceptional AI programming partner\n\n---\n\n**⭐ If this project helps you, please give it a star!**\n\nFor questions or feedback, please contact [alonsoir@gmail.com](mailto:alonsoir@gmail.com)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falonsoir%2Fdistributed-order-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falonsoir%2Fdistributed-order-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falonsoir%2Fdistributed-order-system/lists"}