Event ticketing system built with Spring Boot microservices architecture, featuring event-driven communication via Kafka and secure API gateway with OAuth2 authentication.
┌─────────────┐
│ API Gateway │ :8090 - Entry point with OAuth2 + Circuit Breaker
└──────┬──────┘
│
├──────► Inventory Service :8080 - Event & venue inventory management
│
└──────► Booking Service :8081 - Ticket booking + Kafka producer
│
│ Kafka (BOOKING_TOPIC)
▼
Order Service :8082 - Order processing + Kafka consumer
- Java 21
- Spring Boot 3.5.7
- MySQL 8.0
- Apache Kafka
- Keycloak (OAuth2)
- Flyway (DB Migration)
- Resilience4j (Circuit Breaker)
- JDK 21
- Maven 3.6+
- MySQL 8.0
- Apache Kafka 3.0+
- Keycloak 21+ (optional, for API Gateway)
CREATE DATABASE ticketing;Each service needs a .env file. Copy from examples:
cp inventory-service/.env.example inventory-service/.env
cp booking-service/.env.example booking-service/.env
cp order-service/.env.example order-service/.env
cp api-gateway/.env.example api-gateway/.envUpdate database credentials in each .env:
DB_USERNAME=root
DB_PASSWORD=your_passwordStart each service in separate terminals:
# Terminal 1
cd inventory-service && mvn spring-boot:run
# Terminal 2
cd booking-service && mvn spring-boot:run
# Terminal 3
cd order-service && mvn spring-boot:run
# Terminal 4
cd api-gateway && mvn spring-boot:run| Service | Port | API Docs |
|---|---|---|
| API Gateway | 8090 | http://localhost:8090/swagger-ui.html |
| Inventory Service | 8080 | http://localhost:8080/swagger-ui.html |
| Booking Service | 8081 | - |
| Order Service | 8082 | - |
-
Get available events (via API Gateway)
GET http://localhost:8090/api/v1/inventory/events
-
Book tickets (via API Gateway)
POST http://localhost:8090/api/v1/booking/book { "userId": 1, "eventId": 1, "ticketCount": 2 } -
Booking service publishes event to Kafka topic
BOOKING_TOPIC -
Order service consumes event and creates order in database
-
Order service updates inventory via REST call to Inventory Service
ticket-book-microservices/
├── inventory-service/ # Event & venue management
├── booking-service/ # Ticket booking + Kafka producer
├── order-service/ # Order processing + Kafka consumer
├── api-gateway/ # API Gateway with OAuth2
Inventory Service
- Event and venue CRUD operations
- Real-time capacity tracking
- REST API for inventory queries
Booking Service
- Ticket booking validation
- Kafka event producer
- Inventory availability check
Order Service
- Kafka event consumer
- Order persistence
- Inventory update via REST client
API Gateway
- OAuth2 authentication (Keycloak)
- Circuit breaker pattern
- Request routing to downstream services
- Aggregated API documentation
# From root directory
for dir in inventory-service booking-service order-service api-gateway; do
cd $dir && mvn clean install && cd ..
donecd <service-name>
mvn testFlyway migrations run automatically on application startup. Migration files located in src/main/resources/db/migration/.
- API Gateway enforces OAuth2 authentication via Keycloak
- Database credentials stored in
.envfiles (not committed to git) - Public endpoints configurable via
SECURITY_EXCLUDED_URLS
API Gateway exposes Circuit Breaker health metrics:
GET http://localhost:8090/actuator/health