How thiago-nsampaio/budgeting works
Purpose and Startup
This is a Gradle-built Java service centered on speech generation and audio transcription, with additional chat-facing controller surfaces. The application entry point is src/main/java/dio/budgeting/BudgetingApplication.java; runtime behavior and service configuration are expected in src/main/resources/application.properties.
HTTP/API Boundary
Controllers form the inbound API boundary:
• src/main/java/dio/budgeting/SpeechController.java
• src/main/java/dio/budgeting/TranscriptionController.java
• src/main/java/dio/budgeting/ChatClientController.java
• src/main/java/dio/budgeting/ChatModelController.java
Speech and transcription requests should enter through their dedicated controllers, while the two chat controllers expose separate client- and model-oriented interaction endpoints. Controller responsibilities should remain request validation, delegation, and HTTP response construction.
Speech Synthesis Stage
Text-to-speech is implemented behind src/main/java/dio/budgeting/service/PiperTtsService.java, with its request contract defined by src/main/java/dio/budgeting/domain/dto/SpeechRequest.java.
The service name indicates an integration boundary with Piper TTS, likely requiring a locally available Piper executable/model or another Piper-hosted runtime. This dependency is materially separate from the web/API process and should be treated as an external process or infrastructure concern.
Transcription Stage
Audio transcription is mediated by:
• src/main/java/dio/budgeting/service/TranscriptionService.java
• src/main/java/dio/budgeting/domain/dto/TranscriptionResponse.java
• src/main/java/dio/budgeting/TranscriptionController.java
The primary flow is audio input → controller → transcription service → normalized transcription response. The service is the correct boundary for any transcription engine, remote API, file handling, or model invocation, keeping those concerns out of controllers and DTOs.
Data Contracts and Error Boundary
DTOs define externally meaningful payloads rather than exposing service internals:
• src/main/java/dio/budgeting/domain/dto/SpeechRequest.java
• src/main/java/dio/budgeting/domain/dto/TranscriptionResponse.java
Failures are represented through domain-specific exceptions:
• src/main/java/dio/budgeting/exception/PiperException.java
• src/main/java/dio/budgeting/exception/TranscriptionException.java
src/main/java/dio/budgeting/controller/GlobalExceptionHandler.java is the cross-cutting HTTP error boundary, converting those failures into the shared src/main/java/dio/budgeting/exception/ErrorResponse.java contract.
Runtime and Build
The service uses the Gradle wrapper (gradlew, gradle/wrapper/gradle-wrapper.properties) and is configured by build.gradle. The Java application runtime is started from BudgetingApplication.java; deployment must also provide whatever speech and transcription backends the service adapters require, especially the Piper TTS dependency implied by PiperTtsService.
Main entry points: BudgetingApplication.java Application runtime · TranscriptionService.java Transcription service · SpeechController.java Speech controller · PiperTtsService.java Piper TTS service
Components 17
HTTP API
- Speech controller
src/main/java/dio/budgeting/SpeechController.java - Transcription controller
src/main/java/dio/budgeting/TranscriptionController.java - Chat client controller · Exposes client-oriented chat endpoints.
src/main/java/dio/budgeting/ChatClientController.java - Chat model controller · Exposes model-oriented chat endpoints.
src/main/java/dio/budgeting/ChatModelController.java
Speech synthesis
- Speech request
src/main/java/dio/budgeting/domain/dto/SpeechRequest.java - Piper TTS service · Isolates Piper text-to-speech invocation.
src/main/java/dio/budgeting/service/PiperTtsService.java - Piper runtime · Locally available Piper executable, model, or hosted runtime.
Transcription
- Transcription service · Owns audio handling and transcription-engine invocation.
src/main/java/dio/budgeting/service/TranscriptionService.java - Transcription response
src/main/java/dio/budgeting/domain/dto/TranscriptionResponse.java - Transcription backend · Required engine, API, or model runtime.
Error handling
- Global exception handler · Converts domain failures into HTTP error responses.
src/main/java/dio/budgeting/controller/GlobalExceptionHandler.java - Piper exception
src/main/java/dio/budgeting/exception/PiperException.java - Transcription exception
src/main/java/dio/budgeting/exception/TranscriptionException.java - Error response
src/main/java/dio/budgeting/exception/ErrorResponse.java
Other components
- Application runtime · Starts the Java HTTP service.
src/main/java/dio/budgeting/BudgetingApplication.java - Runtime configuration
src/main/resources/application.properties - Gradle build
build.gradle
Connections 17
- Gradle build → Application runtime: builds
- Runtime configuration → Application runtime: configures
- Application runtime → Speech controller: serves
- Application runtime → Transcription controller: serves
- Application runtime → Chat client controller: serves
- Application runtime → Chat model controller: serves
- Speech controller → Speech request: accepts
- Speech controller → Piper TTS service: delegates
- Piper TTS service → Piper runtime: invokes
- Transcription controller → Transcription service: delegates
- Transcription service → Transcription backend: invokes
- Transcription service → Transcription response: returns
- Piper TTS service → Piper exception: raises
- Transcription service → Transcription exception: raises
- Piper exception → Global exception handler: handled by
- Transcription exception → Global exception handler: handled by
- Global exception handler → Error response: produces