How quarkusio/quarkus-super-heroes works
Purpose and Topology
This repository is a Quarkus microservices sample for superhero battles, demonstrating synchronous REST/gRPC calls, Kafka eventing, persistence, resilience, OpenTelemetry, and multiple deployment targets. It is a collection of independently built and run Maven projects, not a single multi-module build. Root orientation and system documentation: README.md, pom.xml, images/plantuml/application-architecture.puml.
User Entry Point
The user-facing application is a React SPA packaged and served by Quarkus Quinoa. Its frontend calls the fight API to choose fighters, initiate battles, and show fight history. Key boundaries: ui-super-heroes/src/main/webui/src/app/App.js, ui-super-heroes/src/main/webui/src/app/shared/api/fight-service.js, ui-super-heroes/src/main/java/io/quarkus/sample/superheroes/ui/EnvResource.java.
Fight Orchestrator
rest-fights is the central reactive REST service and primary backend entry point. FightResource accepts fight requests; FightService coordinates downstream hero, villain, location, and narration services, maps their DTOs into fight domain records, persists fights in MongoDB, and publishes Avro fight events to Kafka. It also owns health checks, configuration, OpenAPI contract, and fault-tolerance boundary for dependency failures. Paths: rest-fights/src/main/java/io/quarkus/sample/superheroes/fight/rest/FightResource.java, rest-fights/src/main/java/io/quarkus/sample/superheroes/fight/service/FightService.java, rest-fights/src/main/avro/fight.avsc.
Character Catalog Services
Heroes and villains are independent HTTP CRUD services backed by relational persistence through Panache, exposing resource/service/data-access layers. Heroes use Hibernate Reactive repository style; villains use Hibernate ORM active record style. The fight orchestrator reaches them through REST clients rather than sharing persistence models. Paths: rest-heroes/src/main/java/io/quarkus/sample/superheroes/hero/rest/HeroResource.java, rest-heroes/src/main/java/io/quarkus/sample/superheroes/hero/repository/HeroRepository.java, rest-villains/src/main/java/io/quarkus/sample/superheroes/villain/rest/VillainResource.java.
Location and Narration Dependencies
Location is a Kotlin gRPC service with a protobuf contract and relational repository; rest-fights consumes it through LocationClient. Narration is a REST service that converts completed fight data into text and optional imagery, delegating AI work to OpenAI through LangChain4J. These are distinct protocol and external-provider boundaries. Paths: grpc-locations/src/main/proto/locationservice-v1.proto, grpc-locations/src/main/kotlin/io/quarkus/sample/superheroes/location/grpc/LocationGrpcService.kt, rest-narration/src/main/java/io/quarkus/sample/superheroes/narration/service/NarrationService.java.
Event Statistics Pipeline
After orchestration, fight events flow asynchronously from Kafka into event-statistics. Listener components derive rankings, aggregate hero/villain/team statistics, and push updates over WebSockets to dashboard/browser clients. The Avro event schema is duplicated locally as the consumer contract. Paths: event-statistics/src/main/avro/fight.avsc, event-statistics/src/main/java/io/quarkus/sample/superheroes/statistics/listener/SuperStats.java, event-statistics/src/main/java/io/quarkus/sample/superheroes/statistics/endpoint/EventStatsWebSocket.java.
Runtime, Infrastructure, and Delivery
Services target Java 25 on Quarkus, with JVM and native container variants. Local Compose definitions provision service dependencies; deployments support Kubernetes, OpenShift, Minikube, and Knative via Helm or generated manifests. Relational databases serve catalogs/locations, MongoDB stores fights, Kafka transports events, OpenAI supplies narration, and Grafana LGTM receives OTLP traces, metrics, and logs. Paths: deploy/docker-compose/java25.yml, monitoring/docker-compose/monitoring.yml, rest-fights/deploy/helm/kubernetes/Chart.yaml.
Main entry points: FightService.java Fight coordinator · App.js React SPA + Quinoa · LocationGrpcService.kt Locations gRPC service · FightResource.java Fight REST API
Components 23
User interface
- Browser user
- React SPA + Quinoa · Chooses fighters, starts battles, and shows history.
ui-super-heroes/src/main/webui/src/app/App.js - Fight API client
ui-super-heroes/src/main/webui/src/app/shared/api/fight-service.js - UI environment endpoint
ui-super-heroes/src/main/java/io/quarkus/sample/superheroes/ui/EnvResource.java
Fight orchestration
- Fight REST API
rest-fights/src/main/java/io/quarkus/sample/superheroes/fight/rest/FightResource.java - Fight coordinator · Coordinates dependencies, persistence, resilience, and event publication.
rest-fights/src/main/java/io/quarkus/sample/superheroes/fight/service/FightService.java - Fight history
- Fight event contract
rest-fights/src/main/avro/fight.avsc
Catalog services
- Heroes service
rest-heroes/src/main/java/io/quarkus/sample/superheroes/hero/rest/HeroResource.java - Hero repository
rest-heroes/src/main/java/io/quarkus/sample/superheroes/hero/repository/HeroRepository.java - Villains service · Uses Hibernate ORM active record persistence.
rest-villains/src/main/java/io/quarkus/sample/superheroes/villain/rest/VillainResource.java - Catalog database
Remote dependencies
- Locations gRPC service
grpc-locations/src/main/kotlin/io/quarkus/sample/superheroes/location/grpc/LocationGrpcService.kt - Location contract
grpc-locations/src/main/proto/locationservice-v1.proto - Location database
- Narration service · Produces text and optional imagery for completed fights.
rest-narration/src/main/java/io/quarkus/sample/superheroes/narration/service/NarrationService.java - OpenAI
Event statistics
- Kafka
- Statistics processor · Derives rankings and aggregate hero, villain, and team statistics.
event-statistics/src/main/java/io/quarkus/sample/superheroes/statistics/listener/SuperStats.java - Statistics event contract · Local consumer copy of the fight event contract.
event-statistics/src/main/avro/fight.avsc - Statistics WebSocket
event-statistics/src/main/java/io/quarkus/sample/superheroes/statistics/endpoint/EventStatsWebSocket.java
Runtime platform
- Containers and deployments · Supports JVM/native containers and Kubernetes-family targets.
deploy/docker-compose/java25.yml - Grafana LGTM · Receives traces, metrics, and logs.
monitoring/docker-compose/monitoring.yml
Connections 24
- Browser user → React SPA + Quinoa: uses
- React SPA + Quinoa → Fight API client: calls through
- React SPA + Quinoa → UI environment endpoint: reads environment
- Fight API client → Fight REST API: REST
- Fight REST API → Fight coordinator: delegates
- Fight coordinator → Heroes service: REST client
- Fight coordinator → Villains service: REST client
- Fight coordinator → Locations gRPC service: gRPC client
- Fight coordinator → Narration service: REST client
- Fight coordinator → Fight history: persists fights
- Fight coordinator → Fight event contract: serializes
- Fight coordinator → Kafka: publishes fight events
- Heroes service → Hero repository: uses
- Hero repository → Catalog database: persists
- Villains service → Catalog database: persists
- Locations gRPC service → Location contract: implements
- Locations gRPC service → Location database: persists
- Narration service → OpenAI: LangChain4J
- Kafka → Statistics processor: consumes events
- Statistics event contract → Statistics processor: deserializes
- Statistics processor → Statistics WebSocket: pushes updates
- Browser user → Statistics WebSocket: receives live stats
- Containers and deployments → Fight REST API: deploys
- Grafana LGTM → Fight coordinator: receives OTLP