A sample ticketing system demonstrating microservice architecture with Spring Boot and gRPC.
graph TD
Client -->|HTTP| Gateway[API Gateway]
Gateway -->|JWT Auth| Auth[Auth Service]
Gateway -->|REST| Catalog[Catalog Service]
Gateway -->|REST| Booking[Booking Service]
Booking <-->|gRPC| Inventory[Inventory Service]
Auth -->|JPA| AuthDB[(Auth DB)]
Catalog -->|JPA| CatalogDB[(Catalog DB)]
Inventory -->|JPA| InventoryDB[(Inventory DB)]
Booking -->|JPA| BookingDB[(Booking DB)]
- Each service's data is isolated in its own PostgreSQL database (
auth,catalog,inventory,booking).
Each service runs independently on its own port:
| Service | Port | Description |
|---|---|---|
| Gateway | 8080 | Routes external requests and performs coarse-grained auth |
| Catalog | 8081 | Events, venues and price tiers |
| Inventory | 8082 (gRPC 9090) | Seat availability and locking |
| Booking | 8083 | Orchestrates booking workflow |
| Auth | 8084 | User registration and token issuance |
- The
ticketing-shared-libmodule holds protobuf definitions used by inventory and booking.
- Authenticate
Users register and log in via the Auth Service to obtain a JWT. - Browse catalog
Clients call the Gateway which forwards requests to the Catalog Service for events and seating info. - Start a booking
The Booking Service initiates a booking through the Gateway and asks the Inventory Service (via gRPC) to lock seats. - Confirm or cancel
After payment confirmation the Booking Service finalizes the order and tells Inventory to sell seats. Cancellation releases the locks.
├─ ticketing-auth-service # JWT issuance and user management
├─ ticketing-catalog-service # Event and venue data
├─ ticketing-inventory-service # Seat management exposed over gRPC
├─ ticketing-booking-service # Booking orchestration
├─ ticketing-gateway-service # API gateway / edge service
├─ ticketing-shared-lib # Protobuf definitions shared across services
└─ ticketing-platform.postman_collection.json # Example API requests
To build and start all services along with PostgreSQL, ensure Docker is running and execute:
docker compose up --buildThe stack exposes the gateway at http://localhost:8080.
- JDK 21
- Maven
- Docker (for PostgreSQL)
JWT_SECRETenvironment variable (same for all services)
-
Clone the repository
git clone <repo-url> cd microservices-based-ticketing-platform
-
Build shared protobuf library
cd ticketing-shared-lib ./mvnw install cd ..
-
Start PostgreSQL
docker run --name ticketing-postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres
Create databases
catalog,inventory, andbookinginside the container. -
Run each service (in separate terminals)
export JWT_SECRET=supersecret cd ticketing-catalog-service && ./mvnw spring-boot:run cd ticketing-inventory-service && ./mvnw spring-boot:run cd ticketing-booking-service && ./mvnw spring-boot:run cd ticketing-auth-service && ./mvnw spring-boot:run cd ticketing-gateway-service && ./mvnw spring-boot:run
-
Use the platform
Access APIs through the gateway at
http://localhost:8080/api/...
A Postman collectionticketing-platform.postman_collection.jsonis provided for example requests.
All services use a shared HMAC secret to sign and validate JWT tokens. The auth service signs tokens while the gateway and downstream services re-validate them using the same secret.
Configure the secret via the JWT_SECRET environment variable or the jwt.secret property in each service's application.properties. The value must be identical across all services to ensure validation succeeds.
- Provide a new value for
JWT_SECRETand redeploy all services so they can validate tokens signed with the new secret. - Restart the auth service last to begin issuing tokens with the new secret.
- After previously issued tokens expire, remove the old secret value from your configuration.
This project is licensed under the MIT License.