A financial transaction management API built with Spring Boot and Spring AI, integrating Artificial Intelligence capabilities for processing voice commands.
This project was developed as part of the Spring AI final challenge from DIO, using the project presented during the lessons as a foundation and adding my own improvements in implementation, documentation and code quality.
The application allows users to create and retrieve financial transactions through a REST API, as well as use Artificial Intelligence to interpret voice commands.
The main AI-powered workflow is:
ποΈ Audio uploaded by the client
β
π Speech-to-Text
β
π€ Spring AI / LLM
β
π§ Tool Calling
β
πΌ Application Use Case
β
ποΈ Data Persistence / Query
β
π¬ AI-generated response
β
π Text-to-Speech
β
π§ MP3 audio returned to the client
The architecture maintains a clear separation between domain, application and infrastructure layers, preventing the AI integration from bypassing the application's business rules.
- Create new financial transactions.
- Retrieve transactions by category.
- Persist data using Spring Data JPA.
- Validate incoming API data.
- Return appropriate HTTP responses.
- Speech-to-text transcription.
- Large Language Model integration using Spring AI.
- Function/Tool Calling, allowing the AI to execute real application use cases.
- Text-to-speech synthesis.
- Return the final AI response as an MP3 file.
In addition to the base implementation presented during the challenge, I introduced several improvements to make the project closer to a professional application:
- π Custom project documentation.
- π Structured logging across key operations.
- π‘οΈ Request validation using Jakarta Bean Validation.
β οΈ Global exception handling structure.- π API documentation using OpenAPI/Swagger.
- π§± Clear separation between application layers.
- π§ͺ Application validation through Gradle tests.
- π³ MySQL integration using Docker Compose.
The project follows a layered architecture inspired by Clean Architecture and Domain-Driven Design (DDD) principles.
src/main/java/dio/budgeting
βββ domain
β βββ Transaction
β βββ Category
β βββ TransactionRepository
β
βββ application
β βββ input
β βββ output
β βββ PersistTransactionUseCase
β βββ ListTransactionsByCategoryUseCase
β
βββ infrastructure
βββ http
β βββ request
β βββ response
β βββ exception
β
βββ persistence
The application layer contains the business use cases, which can be consumed by both REST endpoints and Spring AI Tool Calling.
- β Java
- π± Spring Boot
- π€ Spring AI
- π Spring Web
- ποΈ Spring Data JPA
- π¬ MySQL
- π³ Docker / Docker Compose
- π OpenAPI / Swagger
- β Jakarta Bean Validation
- π§ͺ JUnit / Spring Boot Test
- π¦ Gradle
- π SLF4J / Logback
- π§° Lombok
Make sure you have the following installed:
- Java
- Docker Desktop
- Git
- An OpenAI API key for the AI-powered features
git clone https://github.com/PinchiSZ/spring-ai-budgeting.git
cd spring-ai-budgeting/05-spring-aiSet the following environment variable.
$env:OPENAI_API_KEY="your-api-key-here"export OPENAI_API_KEY="your-api-key-here"Never add your API key directly to the source code or commit it to Git.
The project is configured to start MySQL through Docker Compose.
./gradlew bootRunOn Windows:
.\gradlew.bat bootRunThe API will be available at:
http://localhost:8080
Once the application is running, the interactive API documentation is available through Swagger UI:
http://localhost:8080/swagger-ui/index.html
Swagger UI can be used to explore and execute the available endpoints directly from the browser.
POST /transactionsExample request:
{
"description": "Grocery shopping",
"category": "GROCERIES",
"amount": 8500
}Expected response:
201 CreatedGET /transactions/{category}Example:
GET /transactions/GROCERIESPOST /transactions/aiThe endpoint accepts an audio file through multipart/form-data.
The audio is:
- Transcribed into text.
- Sent to the language model.
- Interpreted by the AI.
- Routed to the appropriate available Tool.
- Processed by the application use case.
- Converted back into audio.
- Returned as an MP3 file.
This endpoint requires a valid API key and access to the configured AI provider.
Run the automated tests with:
.\gradlew.bat testTo perform a complete build:
.\gradlew.bat buildDuring development, the main application flow was also validated through Swagger UI.
The following flows were tested:
POST /transactionsβ successfully created a transaction.GET /transactions/GROCERIESβ successfully retrieved transactions by category.POST /transactions/aiβ verified the audio processing and AI integration flow.
The AI endpoint requires valid provider credentials. The remaining API functionality can be tested without an AI API key.
The project uses MySQL, running through Docker Compose.
To check whether the database container is running:
docker psThe container should report a status similar to:
Up ... (healthy)
The application uses the following port mapping:
3307 β 3306
Throughout the development of this project, I gained practical experience with:
- Integrating Spring Boot applications with AI models.
- Using Spring AI.
- Speech-to-text and text-to-speech technologies.
- Tool Calling to connect LLMs with real application functionality.
- Building REST APIs.
- Request validation with Jakarta Bean Validation.
- API documentation with OpenAPI/Swagger.
- Implementing application logging with SLF4J.
- Global exception handling.
- Clean Architecture and DDD concepts.
- Data persistence with Spring Data JPA.
- MySQL integration.
- Docker Compose for local development.
- Testing and validation with Gradle.
- Version control and conventional Git commits.
- Improving an existing educational codebase with production-oriented practices.
This project was developed from the base project presented during the DIO Spring AI challenge, taught by Thiago Poiani.
The repository contains my own version of the project, based on the implementation presented during the course and extended with additional improvements, including documentation, logging, request validation, exception handling, API documentation and other software engineering practices.
I would like to thank Thiago Poiani and DIO for the course content and the challenge, which provided the foundation for putting the concepts covered in the module into practice.
This project was developed for educational purposes as part of my learning journey in Java, Spring Boot, Spring AI, REST APIs and Artificial Intelligence integration.
The project may continue to evolve as I apply additional software engineering practices and improvements.