Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TicketFlow Platform

Java Spring Boot Apache Kafka MySQL Redis Docker Kubernetes

A production-ready event-driven microservices platform for ticket booking operations

Features • Architecture • Quick Start • API Docs • Tech Stack


Overview

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.

Architecture

System Architecture

┌─────────────┐     ┌─────────────┐     ┌─────────────────────────────────────┐
│   Client    │────▶│    Nginx    │────▶│           API Gateway               │
└─────────────┘     └─────────────┘     └─────────────────────────────────────┘
                                                         │
                    ┌────────────────────────────────────┼────────────────────────────────────┐
                    │                                    │                                    │
                    ▼                                    ▼                                    ▼
           ┌────────────────┐                   ┌────────────────┐                   ┌────────────────┐
           │ Ticket Service │                   │  User Service  │                   │Payment Service │
           │    (CQRS)      │                   │                │                   │                │
           └───────┬────────┘                   └───────┬────────┘                   └───────┬────────┘
                   │                                    │                                    │
                   └────────────────────────────────────┼────────────────────────────────────┘
                                                        │
                                                        ▼
                                        ┌───────────────────────────────┐
                                        │      Apache Kafka             │
                                        │   (Event Backbone)            │
                                        └───────────────────────────────┘
                                                        │
                    ┌───────────────────────────────────┼───────────────────────────────────┐
                    │                                   │                                   │
                    ▼                                   ▼                                   ▼
           ┌────────────────┐                  ┌────────────────┐                  ┌────────────────┐
           │   Inventory    │                  │  Notification  │                  │ Saga           │
           │   Service      │                  │  Service       │                  │ Orchestrator   │
           └────────────────┘                  └────────────────┘                  └────────────────┘

Features

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

Quick Start

Prerequisites

  • Java 21+
  • Maven 3.6+
  • Docker & Docker Compose

1. Clone & Build

git clone https://github.com/GojoSnippet/ticketflow-platform.git
cd ticketflow-platform
mvn clean install -DskipTests

2. Start Services

docker-compose up -d

3. Verify

# Check all services are running
docker-compose ps

# Test API Gateway
curl http://localhost:8080/actuator/health

Services

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

Infrastructure

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

API Documentation

Swagger UI is available for each service:

Project Structure

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

Tech Stack

Core

  • Java 21 - Modern Java features
  • Spring Boot 3.2.0 - Application framework
  • Spring Cloud 2023.0.0 - Microservices patterns

Messaging & Data

  • Apache Kafka - Event streaming
  • MySQL 8.0 - Relational database
  • Redis 7 - Caching & locking
  • Elasticsearch 8.11 - Search engine

Infrastructure

  • Spring Cloud Gateway - API Gateway
  • Consul - Service discovery
  • Resilience4j - Circuit breakers
  • Docker - Containerization
  • Kubernetes - Orchestration

Observability

  • Prometheus - Metrics
  • Grafana - Visualization
  • Spring Actuator - Health checks
  • Micrometer - Metrics abstraction

Event Flow

Ticket Created → Payment Initiated → Payment Completed → Ticket Confirmed
                         │
                         └──→ Payment Failed → Ticket Cancelled (Compensation)

Kafka Topics

  • ticket-created / ticket-confirmed / ticket-cancelled
  • payment-initiated / payment-completed / payment-failed
  • user-created

Kubernetes Deployment

# 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/

Commands Reference

# 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

Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.


Built by GojoSnippet

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages