How wsn22/speakbuddy works
Main components
• API/Web Layer (Controller): Represented by the controller packages under “api/src/main/java/com/speakbuddy/api/controller/v1/”. There are separate controllers for user management and audio/phrase processing.
• Service Layer: This contains business logic. For example, the “service/audio/phrase” and “service/user” packages show that each functionality (audio processing and user handling) is encapsulated in dedicated services.
• Database Access Layer: Found in the “database” package that includes managers, repositories (e.g., PhraseManager, UserManager, and their corresponding Repository classes), and entity definitions. This package shows how the system interacts with PostgreSQL.
• Audio Processing Utilities: Under “utility” and “utility/audio_processor” there are components like AudioProcessor, AiffConverter, and WavConverter, which handle file conversion and processing.
• Exception and Configuration Handling: There is a ControllerAdvisor and several custom Exception classes that manage error flows.
• Deployment Infrastructure: The Dockerfile and docker-compose.yml indicate that the system is containerized. Docker Compose configures both the API app and the PostgreSQL database, exposing necessary ports and connection information.
Relationships and interactions
• Client (or external system) → API Controllers: Incoming HTTP requests (including file uploads and user creation) are handled by the appropriate controller (e.g., UserController, PhraseController).
• Controllers → Service Layer: The controllers delegate tasks to services (like UserService and PhraseService) which implement business logic.
• Service Layer → Repository/Manager: Services work with Database Managers and/or Repositories to fetch, persist, or update data in the PostgreSQL database.
• Audio Processing Flow: When audio files are received, a utility component (such as AudioProcessor) calls specific converters (AiffConverter, WavConverter) to process incoming or outgoing audio files.
• Exception Handling: Exceptions thrown in any layer are intercepted by the ControllerAdvisor, which formats error messages (using classes like ErrorMessage).
• Deployment: The Docker compose configuration ensures that the API server and the PostgreSQL database are deployed together and can interact seamlessly.
Important architectural patterns/design principles
• Layered Architecture: Each layer is neatly separated (controller, service, data access, and utility).
• Modular Design: Different functionalities such as audio processing, user management, and database management are split into dedicated modules or packages.
• Exception Handling: Global exception management is provided through ControllerAdvisor.
• Containerization: The use of Docker & Docker Compose isolates the environment and simplifies deployment.
• Testability: Tests are split by feature (controllers, services, utilities) that indicate emphasis on integration and unit testing.
Relevant technologies/frameworks
• Java 21, Spring Boot (implied by structure and Gradle bootJar), and Gradle as the build tool.
• PostgreSQL as the database.
• Docker and Docker Compose for deployment.
• Audio processing libraries (likely custom-built converters for aiff and wav) and possibly file utilities that manage local file processing.