A chat application built with Spring Boot, Thymeleaf, HTMX, and Tailwind CSS that integrates with the Groq API using GroqClient4J.
git clone https://github.com/yourusername/GroqChat4J.git
cd GroqChat4J
Add your Groq API key as an environment variable:
# Linux/macOS
export GROQ_API_KEY=your_api_key_here
# Windows (Command Prompt)
set GROQ_API_KEY=your_api_key_here
# Windows (PowerShell)
$env:GROQ_API_KEY="your_api_key_here"
Alternatively, you can add it to application.properties
(not recommended for production):
groq.api.key=your_api_key_here
mvn clean install
mvn spring-boot:run
The application will be available at http://localhost:8080
GroqChat4J/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── gazapps/
│ │ │ └── groqchat4j/
│ │ │ ├── GroqChat4JApplication.java
│ │ │ ├── config/
│ │ │ │ └── AppConfig.java
│ │ │ ├── controller/
│ │ │ │ └── ChatController.java
│ │ │ ├── service/
│ │ │ │ └── ChatService.java
│ │ │ └── model/
│ │ │ └── ChatMessage.java
│ │ └── resources/
│ │ ├── application.properties
│ │ ├── static/
│ │ │ └── css/
│ │ │ └── main.css
│ │ └── templates/
│ │ ├── index.html
│ │ ├── chat-response.html
│ │ └── chat-response-clear.html
│ └── test/
│ └── java/
│ └── com/
│ └── gazapps/
│ └── groqchat4j/
│ └── GroqChat4JApplicationTests.java
└── pom.xml
You can customize the application by modifying the following properties in application.properties
:
# Server configuration
server.port=8080
# Groq API configuration
groq.api.key=${GROQ_API_KEY}
groq.model=llama-3.2-70b
# Application settings
app.system.message=You are a helpful, friendly, and concise assistant.
Handles HTTP requests and manages the chat interface using Thymeleaf fragments and HTMX.
Manages communication with the Groq API using GroqClient4J.
index.html
: Main chat interface with HTMX for dynamic interactionschat-response.html
: Thymeleaf fragment for rendering chat messageschat-response-clear.html
: Thymeleaf fragment for clearing chat historyTo add user authentication to the chat:
To persist chat history:
mvn clean package
This will create a deployable JAR file in the target
directory.
java -jar target/GroqChat4J-0.0.1-SNAPSHOT.jar
# Build Docker image
docker build -t groqchat4j .
# Run Docker container
docker run -p 8080:8080 -e GROQ_API_KEY=your_api_key_here groqchat4j
Created with ❤️ by Me