Development Guide
This guide provides detailed information for developers who want to contribute to the DevoxxGenie plugin's codebase.
Project Architecture
DevoxxGenie follows a modular architecture with clear separation of concerns:
src/main/java/com/devoxx/genie/
├── action/ # Action classes for menu actions
├── chatmodel/ # LLM provider implementations
│ ├── cloud/ # Cloud LLM providers (OpenAI, Anthropic, etc.)
│ └── local/ # Local LLM providers (Ollama, GPT4All, etc.)
├── controller/ # Controllers for coordinating behavior
├── error/ # Error handling mechanisms
├── model/ # Data models and DTOs
├── service/ # Business logic services
│ ├── chromadb/ # ChromaDB integration for RAG
│ ├── mcp/ # MCP implementation
│ ├── prompt/ # Prompt handling services
│ ├── rag/ # RAG implementation
│ └── websearch/ # Web search functionality
└── ui/ # User interface components
├── component/ # Reusable UI components
├── dialog/ # Dialog windows
├── panel/ # UI panels
├── renderer/ # Custom UI renderers
├── settings/ # Settings UI
└── util/ # UI utilities
Key Components
LLM Provider Integration
The chatmodel package contains implementations for different LLM providers. To add a new provider:
- Create a new package under
chatmodel/cloud/orchatmodel/local/ - Implement a factory class that extends
ChatModelFactory - Register the factory in
ChatModelFactoryProvider - Add UI components to configure the provider in settings
Example factory class:
public class NewProviderChatModelFactory implements ChatModelFactory {
@Override
public ChatLanguageModel createChatModel(ChatModel model) {
// Implementation...
}
@Override
public List<ChatModel> getModels() {
// Return available models...
}
}
Prompt Execution
The prompt execution flow is managed through:
- PromptExecutionController: Entry point for prompt execution
- PromptExecutionService: Orchestrates the execution process
- ChatPromptExecutor: Handles the actual interaction with the LLM
- Strategy classes: Different execution strategies based on requirements
See Prompt Structure for more details on the prompt architecture.
User Interface
The UI is built using IntelliJ's Swing-based component system. Key UI components include:
- DevoxxGenieToolWindowFactory: Creates the main tool window
- DevoxxGenieToolWindowContent: Main content for the tool window
- ChatResponsePanel: Displays LLM responses
- UserPromptPanel: Handles user input
- Settings UI: Various configurable components
Build System
DevoxxGenie uses Gradle with the IntelliJ Plugin Gradle plugin:
plugins {
id 'org.jetbrains.intellij' version '1.13.3'
id 'java'
}
Important Gradle tasks:
./gradlew build: Builds the project./gradlew test: Runs tests./gradlew buildPlugin: Creates a deployable plugin ZIP./gradlew runIde: Launches a development instance of IntelliJ with the plugin
Testing
Unit Testing
Unit tests are in the src/test directory, mirroring the structure of src/main. We use JUnit 5 and Mockito for testing.
Example test class:
@ExtendWith(MockitoExtension.class)
public class ChatPromptExecutorTest {
@Mock
private ChatLanguageModel chatLanguageModel;
@InjectMocks
private ChatPromptExecutor executor;
@Test
public void testExecutePrompt() {
// Test implementation...
}
}
Integration Testing
Integration tests with the IT suffix validate integration between components. These may require additional setup:
public class PromptExecutionServiceIT extends AbstractLightPlatformTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
// Setup code...
}
public void testEndToEndPromptExecution() {
// Test implementation...
}
}
Debugging
Plugin Debugging
To debug the plugin:
- Run
./gradlew runIde --debug-jvm - Connect your IDE's remote debugger to port 5005
- Set breakpoints in your code
LLM Integration Debugging
For debugging LLM provider integration:
- Enable debug logging in
logback.xml - Add appropriate logging in your code
- Check the IDE's log files for detailed information
Example logging configuration:
<logger name="com.devoxx.genie.chatmodel" level="DEBUG"/>
Common Development Tasks
Adding a New Feature
- Identify the Components: Determine which parts of the codebase need modification
- Design the Feature: Plan the implementation, considering architecture and user experience
- Implement Backend: Add necessary services, models, and controllers
- Implement UI: Add or modify UI components
- Add Tests: Write unit and integration tests
- Document: Update documentation
Fixing a Bug
- Reproduce the Bug: Understand the steps to consistently reproduce
- Investigate: Find the root cause in the code
- Fix: Make the minimal necessary changes to fix the issue
- Test: Add regression tests to prevent recurrence
- Document: Add comments explaining the fix if necessary
Working with Dependencies
DevoxxGenie uses several key dependencies:
- Langchain4j: For interacting with LLM providers
- LLM Provider Libraries: OpenAI, Anthropic, etc.
- IntelliJ Platform SDK: For IDE integration
When adding or updating dependencies, make sure to:
- Use appropriate version constraints
- Consider compatibility with different IDE versions
- Be mindful of transitive dependencies
Best Practices
- Follow IDEA Patterns: Align with IntelliJ platform patterns and conventions
- Error Handling: Use appropriate error handling for LLM interactions
- Thread Safety: Be mindful of threading in UI and background operations
- Resource Management: Properly manage resources like API connections
- User Experience: Focus on making the plugin intuitive and responsive
- Performance: Consider token usage, latency, and memory footprint
Common Issues and Solutions
Plugin Loading Issues
If your plugin isn't loading correctly:
- Check the IDE log for errors
- Verify plugin.xml configuration
- Ensure IntelliJ version compatibility
LLM Provider Connection Problems
If LLM providers aren't connecting:
- Verify API keys and endpoints
- Check network connectivity
- Look for rate limiting or permission issues
UI Rendering Issues
For UI problems:
- Use IntelliJ UI Inspector to debug component hierarchy
- Check threading (UI updates must be on EDT)
- Verify component initialization order
Additional Resources
By following this guide, you'll be well-equipped to contribute effectively to the DevoxxGenie plugin.