- Introduction
- Getting Started
- System Components
- Using the Application
- API Reference
- Troubleshooting
- FAQ
Email-LLM Integration is a system that integrates an email server with local Large Language Models (LLM) using Apache Camel and Groovy. The main purpose of the system is to automatically process incoming email messages, analyze their content using LLM models, and generate appropriate responses.
Before you begin, ensure you have the following installed on your system:
- Docker and Docker Compose
- PowerShell (for Windows) or Bash (for Linux/macOS)
- Clone the repository to your local machine
- Navigate to the project directory
- Create a
.envfile based on the providedenv.example - Run the start script:
# Windows
.\start.ps1
# Linux/macOS
./start.shAfter starting the application, you can verify that everything is working correctly by running the diagnostic script:
.\diagnostyka.ps1This will check that all required components are running and properly configured.
The Email-LLM Integration system consists of the following main components:
- Apache Camel - Integration engine that manages data flows and business logic
- Groovy - Programming language used to implement business logic
- Spring Boot - Framework for rapid Java/Groovy application development
- Ollama - Local LLM server for text analysis
- SQLite - Lightweight database for storing messages and their analysis
- MailHog - Test SMTP/IMAP server for development purposes
- Adminer - Administrative tool for the database
All components are run as Docker containers and managed using Docker Compose.
The application provides several web interfaces for interaction:
-
MailHog UI: http://localhost:8026
- View and test emails sent by the application
- Send test emails for processing
-
Adminer: http://localhost:8081
- Manage the SQLite database
- View processed emails and their analysis
The system automatically processes emails received by the configured IMAP server. To test this functionality:
- Send an email to the configured email address
- The system will process the email and analyze it using the LLM
- View the processed email and its analysis in the database through Adminer
- If configured, the system can automatically generate and send a response
You can directly analyze text using the LLM through the API:
curl -X POST -H "Content-Type: application/json" \
-d '{"text":"Please schedule a meeting for tomorrow at 2 PM.", "context":"Project planning"}' \
http://localhost:8083/api/llm/direct-analyzeThe system provides the following REST API endpoints:
| Endpoint | Method | Description | Example Request |
|---|---|---|---|
/api/health |
GET | Check application status | curl http://localhost:8083/api/health |
/api/emails |
GET | Get list of processed emails | curl http://localhost:8083/api/emails |
/api/llm/direct-analyze |
POST | Direct text analysis using LLM | curl -X POST -H "Content-Type: application/json" -d '{"text":"Message content", "context":"Context"}' http://localhost:8083/api/llm/direct-analyze |
/api/api-doc |
GET | API documentation in JSON format | curl http://localhost:8083/api/api-doc |
/api/ollama/analyze |
POST | Alternative endpoint for text analysis | curl -X POST -H "Content-Type: application/json" -d '{"text":"Message content", "model":"mistral"}' http://localhost:8083/api/ollama/analyze |
Problem: Docker containers fail to start
Solution:
- Check if Docker is running:
docker ps - Check container logs:
docker logs camel-groovy-email-llm - Restart Docker and try again
- Run the diagnostic script:
.\diagnostyka.ps1
Problem: API endpoints return errors
Solution:
- Check if all containers are running:
docker ps - Check application logs:
docker logs camel-groovy-email-llm - Verify the configuration in the
.envfile - Restart the application:
.\start.ps1
Problem: Emails are not being processed
Solution:
- Check the email server configuration in the
.envfile - Verify that the email server is accessible
- Check the application logs for connection errors
- Try sending a test email through MailHog
To view application logs, use the following commands:
# View Camel application logs
docker logs camel-groovy-email-llm
# View Ollama logs
docker logs ollama
# View MailHog logs
docker logs mailserverTo change the LLM model used by the application:
- Edit the
.envfile and change theOLLAMA_MODELvariable - Restart the application:
.\start.ps1
The SQLite database is stored in the ./data directory. To backup the database:
- Stop the application:
.\stop.ps1 - Copy the
./data/emails.dbfile to a safe location - Restart the application:
.\start.ps1
To add custom email processing logic:
- Modify the
EmailProcessingRoute.groovyfile in thecamel-groovy/src/main/groovy/com/example/emailllmdirectory - Rebuild and restart the application
The application provides health endpoints that can be used for monitoring:
- Check the health endpoint:
curl http://localhost:8083/api/health - Use the diagnostic script:
.\diagnostyka.ps1 - Monitor container resource usage:
docker stats