This project is an AI-powered reporting service built with Quarkus and Ollama, designed for educational purposes. It demonstrates the integration of AI capabilities into a modern, cloud-native Java application.
The service uses natural language processing to generate SQL queries based on user input, providing an intuitive interface for data retrieval. It also includes security features to protect sensitive information.
- Natural language to SQL query conversion
- User and Order management
- Security-aware context removal
- Integration with OpenAI and Ollama AI models
- Java 21
- Maven 3.8.6+
- Quarkus 3.15.1
- PostgreSQL database
- OpenAI API key (for GPT-4 model)
- Ollama (optional, for local AI model)
The project consists of several key components:
- User and Order domain models
- UserRepository for data access
- UsersApi for RESTful endpoints
- SqlGeneratorService for AI-powered SQL generation
- SecurityService for removing sensitive data
The project uses the following main configuration files:
startLine: 1
endLine: 36
-
Set up your PostgreSQL database and update the connection details in
application.properties
. -
Set your OpenAI API key as an environment variable:
export QUARKUS_LANGCHAIN4J_OPENAI_API_KEY=your_api_key_here
-
Run the application in development mode:
./mvnw quarkus:dev
-
The application will be available at
http://localhost:8080
.
The main endpoint for querying data is:
GET /api/users?query=your_natural_language_query_here
Replace your_natural_language_query_here
with your desired query in plain English.
The application includes a security layer that removes sensitive information from the query results. This is implemented in the SecurityService
and SecurityAwareContextRemovalServiceInterceptor
.
To create a production build:
./mvnw package -Pnative
This will create a native executable optimized for your operating system.