Skip to content

shekarnode/AI-Spring-context-Analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Context Service

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.


Features

  • 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

Tech Stack

  • Java 21
  • Spring Boot
  • Spring AI
  • Spring WebFlux
  • Spring Actuator
  • WebClient
  • Google Gemini API

How It Works

1. Fetch Actuator Metadata

The service collects:

  • Bean information
  • Environment variables
  • Application context metadata

from Spring Boot Actuator endpoints.

Example endpoints:

/actuator/beans
/actuator/env

2. Process Context Data

Fetched metadata is processed and structured into AI-readable prompts.

Example:

ORDER SERVICE BEANS: ...

ORDER SERVICE ENV: ...

PAYMENT SERVICE BEANS: ...


3. Generate AI Prompt

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

4. Generate AI Response

The prompt is sent to Google Gemini using Spring AI ChatClient.

Example:

return chatClient.prompt()
        .user(prompt)
        .call()
        .content();

Sample Questions

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.

Configuration

Google Gemini Configuration

  ai:
    google:
      genai:
        api-key: ${GOOGLE_API_KEY}
        chat:
          options:
            model: gemini-2.5-flash

Required Actuator Configuration

Target Spring Boot applications must expose the following Actuator endpoints:

  endpoints:
    web:
      exposure:
        include: beans,env

Running the Service

./mvnw spring-boot:run

Future Improvements

  • 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors