Skip to content

API Gateway Manifest

Java Spring Boot Gateway

📁 java-api-gateway/

Project Configuration

📄 pom.xml

  • Maven configuration
  • Spring Boot 3.2.3
  • Java 17
  • Dependencies: spring-boot-starter-web, spring-boot-starter-webflux, lombok

Application Entry Point

src/main/java/com/example/gateway/GatewayApplication.java

  • Spring Boot application class
  • RestTemplate and WebClient beans

REST Controller

src/main/java/com/example/gateway/controller/TrafficController.java

  • GET /api/traffic/health - Health check
  • GET /api/traffic/action - Action with auto-generated observations
  • POST /api/traffic/action - Action with custom observations
  • Helper methods for observation generation and action mapping

Service Client

src/main/java/com/example/gateway/service/RlInferenceClient.java

  • HTTP client for Python FastAPI service
  • predictAction() method
  • Health check functionality
  • Error handling with RlInferenceException
  • Inner classes: PredictionResponse, HealthResponse

Configuration

📄 src/main/resources/application.properties

  • Server configuration
  • RL service URL and timeout
  • Logging levels

Deployment

📄 Dockerfile

  • Multi-stage Java container
  • Maven builder stage
  • Eclipse Temurin 17 JRE runtime
  • Exposes port 8080