A high-performance, event-driven distributed system for event management (as in events that people attend) and ticket processing built with Java 21 and Spring Boot 4.0.1.
- API Gateway: Acts as the single entry point. It handles routing to different services and manages security.
- Inventory Service: Acts as the source of truth for event and venue data. It offers an endpoint to update event available capacity.
- Booking Service: Receives the initial user request. It does a quick check to see if the event exists before passing the task to the next service via Kafka.
- Order Service: It listens for messages from Kafka and communicates with the Inventory Service to finalize the event available capacity.
- Spring Cloud Gateway: Manages all incoming traffic and directs it to the right service.
- Spring Security: Protects the application (OAuth2/JWT ready).
- Keycloak: For authentication and authorization.
- Spring Data JPA: ORM layer (Hibernate) for database interactions.
- MySQL 8.0: Relational database for persistent storage.
- Flyway: Handles database migrations and versioning.
- Apache Kafka (KRaft mode): The event bus used for communication between services.
- Resilience4j: Provides Circuit Breakers for system stability.
- Spring Actuator: Monitors application health checks.
- Docker & Compose: Multi-stage, layered builds for optimized deployment.
- SonarQube: Used for maintaining code quality.
This project uses Multi-stage Docker Builds to optimize deployment speed and image sizes. By splitting the Spring Boot application into layers, the system only needs to rebuild the code you actually changed. It does not need to re-download or re-process heavy libraries and dependencies every time, making builds significantly faster.
- Docker & Docker Compose
- JDK 21 (only needed for local development)
- Clone the repository:
git clone https://github.com/ivfrost/spring-ticketing-microservices.git
cd spring-ticketing-microservices
cp .env.example .env
- Spin up the infrastructure and services:
docker-compose up -d
- Test the API Endpoints:
Step 1: Access Keycloak
- URL:
http://localhost:KEYCLOAK_PORT_EXT - User:
KC_BOOTSTRAP_ADMIN_USERNAME - Pass:
KC_BOOTSTRAP_ADMIN_PASSWORD - Note: The
ticketing-securityrealm is automatically imported on startup.
Step 2: Create a Test User
- Select the ticketing-security realm from the top-left menu.
- Go to Users -> Add user to create your local test account.
- In the Credentials tab, set a password and turn Temporary to Off.
Step 3: API Gateway Swagger UI
-
URL:
http://localhost:API_GATEWAY_PORT/swagger-ui.html -
Click Authorize and enter the following details:
- Client ID:
ticketing-client-id - Client Secret: the secret displayed in the Keycloak admin console under Clients -> ticketing-client-id -> Credentials tab.
- Client ID:
-
You can now test the protected endpoints:
- Inventory:
http://localhost:API_GATEWAY_PORT/api/v1/inventory - Bookings:
http://localhost:API_GATEWAY_PORT/api/v1/bookings
- Inventory:
-
Alternatively, you can use Postman to test the endpoints via OAuth2 authentication.
- Use SAGA pattern to ensure data consistency across services.
- Use HashiCorp Vault for managing secrets.