AI Context Service is a Spring AI powered service that analyses Spring Boot application context and environment metadata to provide AI-generated insights for debugging and dependency analysis.
The service fetches Spring Actuator metadata from multiple microservices, processes the information, and generates contextual explanations using Google Gemini through Spring AI.
- Fetch Spring Actuator metadata
- Analyse bean relationships
- Analyse environment configurations
- Generate AI-based explanations
- Process multi-service application context
- Spring AI + Gemini integration
- Reactive communication using WebClient
- Java 21
- Spring Boot
- Spring AI
- Spring WebFlux
- Spring Actuator
- WebClient
- Google Gemini API
The service collects:
- Bean information
- Environment variables
- Application context metadata
from Spring Boot Actuator endpoints.
Example endpoints:
/actuator/beans
/actuator/env
Fetched metadata is processed and structured into AI-readable prompts.
Example:
ORDER SERVICE BEANS: ...
ORDER SERVICE ENV: ...
PAYMENT SERVICE BEANS: ...
The processed metadata and user query are combined to create contextual prompts for the AI model.
Example prompt tasks:
- Explain bean dependencies
- Analyse service interaction
- Identify configuration issues
- Suggest possible fixes
The prompt is sent to Google Gemini using Spring AI ChatClient.
Example:
return chatClient.prompt()
.user(prompt)
.call()
.content();Analyze the Spring application context and identify important bean dependencies.
Identify possible configuration issues in the current environment setup.
Explain the interaction flow between Order Service and Payment Service.
ai:
google:
genai:
api-key: ${GOOGLE_API_KEY}
chat:
options:
model: gemini-2.5-flashTarget Spring Boot applications must expose the following Actuator endpoints:
endpoints:
web:
exposure:
include: beans,env./mvnw spring-boot:run
- Circular dependency detection
- Runtime context monitoring
- Multi-service dependency visualization
- AI-generated remediation suggestions
- Kubernetes-aware analysis
- Challenges Faced
- Handling large Actuator payloads
- Structuring metadata into meaningful prompts
- Managing AI response consistency
- Processing multi-service context information