A production-ready event-driven microservices platform for ticket booking operations
Features • Architecture • Quick Start • API Docs • Tech Stack
TicketFlow is a distributed ticketing system built with modern microservices architecture. It demonstrates real-world patterns like Event-Driven Architecture, Saga Pattern for distributed transactions, and CQRS for optimized read/write operations.
The platform handles the complete ticket booking lifecycle - from user registration to payment processing and notifications - with built-in resilience, monitoring, and scalability.
┌─────────────┐ ┌─────────────┐ ┌─────────────────────────────────────┐
│ Client │────▶│ Nginx │────▶│ API Gateway │
└─────────────┘ └─────────────┘ └─────────────────────────────────────┘
│
┌────────────────────────────────────┼────────────────────────────────────┐
│ │ │
▼ ▼ ▼
┌────────────────┐ ┌────────────────┐ ┌────────────────┐
│ Ticket Service │ │ User Service │ │Payment Service │
│ (CQRS) │ │ │ │ │
└───────┬────────┘ └───────┬────────┘ └───────┬────────┘
│ │ │
└────────────────────────────────────┼────────────────────────────────────┘
│
▼
┌───────────────────────────────┐
│ Apache Kafka │
│ (Event Backbone) │
└───────────────────────────────┘
│
┌───────────────────────────────────┼───────────────────────────────────┐
│ │ │
▼ ▼ ▼
┌────────────────┐ ┌────────────────┐ ┌────────────────┐
│ Inventory │ │ Notification │ │ Saga │
│ Service │ │ Service │ │ Orchestrator │
└────────────────┘ └────────────────┘ └────────────────┘
| Feature | Description |
|---|---|
| Microservices | 7 independent services with clear domain boundaries |
| Event-Driven | Asynchronous communication via Apache Kafka |
| Saga Pattern | Distributed transaction orchestration with compensation |
| CQRS | Command Query Responsibility Segregation in Ticket Service |
| Service Discovery | Consul-based registration and discovery |
| Resilience | Circuit breakers, retries, distributed locking (Resilience4j) |
| Caching | Redis for performance optimization |
| Monitoring | Prometheus metrics + Grafana dashboards |
| Search | Elasticsearch integration for advanced queries |
| API Gateway | Single entry point with routing and load balancing |
| Containerized | Docker Compose + Kubernetes ready |
- Java 21+
- Maven 3.6+
- Docker & Docker Compose
git clone https://github.com/GojoSnippet/ticketflow-platform.git
cd ticketflow-platform
mvn clean install -DskipTestsdocker-compose up -d# Check all services are running
docker-compose ps
# Test API Gateway
curl http://localhost:8080/actuator/health| Service | Port | Description |
|---|---|---|
| API Gateway | 8080 | Entry point, routing, load balancing |
| Ticket Service | 8081 | Ticket management (CQRS pattern) |
| User Service | 8082 | User registration & authentication |
| Payment Service | 8083 | Payment processing |
| Notification Service | 8084 | Email/SMS notifications |
| Inventory Service | 8085 | Seat inventory & reservations |
| Saga Orchestrator | 8086 | Distributed transaction coordination |
| Component | Port | Purpose |
|---|---|---|
| Consul | 8500 | Service discovery |
| Kafka | 9092 | Event streaming |
| MySQL | 3306 | Primary database |
| Redis | 6379 | Caching & distributed locks |
| Elasticsearch | 9200 | Search & analytics |
| Prometheus | 9090 | Metrics collection |
| Grafana | 3000 | Dashboards (admin/admin) |
| Kibana | 5601 | Elasticsearch UI |
Swagger UI is available for each service:
- Ticket Service: http://localhost:8081/swagger-ui.html
- User Service: http://localhost:8082/swagger-ui.html
- Payment Service: http://localhost:8083/swagger-ui.html
ticketflow-platform/
├── api-gateway/ # Spring Cloud Gateway
├── ticket-service/ # Ticket management (CQRS)
├── user-service/ # User management
├── payment-service/ # Payment processing
├── notification-service/ # Notifications
├── inventory-service/ # Inventory management
├── saga-orchestrator-service/ # Saga coordination
├── common-event-library/ # Shared events & DTOs
├── k8s/ # Kubernetes manifests
├── nginx/ # Nginx configuration
├── grafana/ # Grafana provisioning
├── docker-compose.yml # Docker Compose config
└── prometheus.yml # Prometheus config
- Java 21 - Modern Java features
- Spring Boot 3.2.0 - Application framework
- Spring Cloud 2023.0.0 - Microservices patterns
- Apache Kafka - Event streaming
- MySQL 8.0 - Relational database
- Redis 7 - Caching & locking
- Elasticsearch 8.11 - Search engine
- Spring Cloud Gateway - API Gateway
- Consul - Service discovery
- Resilience4j - Circuit breakers
- Docker - Containerization
- Kubernetes - Orchestration
- Prometheus - Metrics
- Grafana - Visualization
- Spring Actuator - Health checks
- Micrometer - Metrics abstraction
Ticket Created → Payment Initiated → Payment Completed → Ticket Confirmed
│
└──→ Payment Failed → Ticket Cancelled (Compensation)
ticket-created/ticket-confirmed/ticket-cancelledpayment-initiated/payment-completed/payment-faileduser-created
# Create namespace
kubectl apply -f k8s/namespace.yaml
# Deploy services
kubectl apply -f k8s/deployments/
kubectl apply -f k8s/services/
kubectl apply -f k8s/ingress/
# Enable autoscaling (optional)
kubectl apply -f k8s/autoscaling/# Build
mvn clean install
# Run tests
mvn test
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f <service-name>
# Stop services
docker-compose down
# Health check
curl http://localhost:8080/actuator/health
# Check registered services
curl http://localhost:8500/v1/agent/services- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Built by GojoSnippet