A minimalistic AI chat template using Spring Boot + Spring AI (OpenAI) for the backend and modern React (Vite + shadcn/ui) for the frontend.
- Backend: Spring Boot 3.5 + Spring AI (OpenAI)
- Frontend: Vite + React 18 + TypeScript + shadcn/ui
- Features:
- Chat with AI (OpenAI, with conversation history)
- Clear chat history
- Light/Dark theme toggle
- Modern UI/UX
git clone <this-repo-url>
cd hello-spring-aiCreate a .env file or set the variables in your system (see below).
SPRING_AI_OPENAI_API-KEY=sk-... # your OpenAI API key
SPRING_AI_OPENAI_BASE-URL=https://api.openai.com
SPRING_AI_OPENAI_CHAT_OPTIONS_MODEL=gpt-4o./gradlew bootRun
# or on Windows:
gradlew.bat bootRunBackend will be available at http://localhost:8080
cd client
npm install
npm run devFrontend will be available at http://localhost:9000 (API requests are automatically proxied to the backend)
All endpoints are available under the /api/v1 prefix:
| Method | URL | Description |
|---|---|---|
| POST | /call |
Send a prompt to the AI, get reply |
| GET | /history |
Get chat message history |
| DELETE | /history/clear |
Clear chat message history |
curl -X POST 'http://localhost:8080/api/v1/call' -d 'prompt=Hello, who are you?'curl 'http://localhost:8080/api/v1/history'curl -X DELETE 'http://localhost:8080/api/v1/history/clear'