Skip to content

Extract shared contracts to common module and configure OpenAPI#9

Merged
Satlykovs merged 1 commit intomainfrom
satlykovs/feat/shared-contracts
Mar 20, 2026
Merged

Extract shared contracts to common module and configure OpenAPI#9
Satlykovs merged 1 commit intomainfrom
satlykovs/feat/shared-contracts

Conversation

@Satlykovs
Copy link
Owner

Цель изменений

Синхронизация протоколов обмена данными между модулями smartjam-api и smartjam-analyzer. Внедрение общего контракта для предотвращения рассинхрона моделей данных; настройка интерактивной документации.

Что сделано

Common (smartjam-common):

  • Создан новый модуль-библиотека для хранения общих контрактов.
  • AudioProcessingStatus: Единый Enum для управления жизненным циклом обработки аудио (AWAITING_UPLOAD, UPLOADED, ANALYZING, COMPLETED, FAILED).
  • FeedbackEvent: Общий рекорд для музыкального отчета. Структура ошибок (таймкоды, тип, тяжесть) теперь зафиксирована для всех слоев системы.
  • FeedbackType: Типизация ошибок (WRONG_NOTE, WRONG_RHYTHM) через Enum вместо магических строк.
  • S3EventDto: Перенесен в общий модуль для унификации обработки событий от хранилища MinIO на стороне API и Анализатора.

Infrastructure & Documentation (smartjam-api):

  • Настроена спецификация OpenAPI 3.0 (Swagger).
  • Добавлена поддержка JWT Bearer авторизации прямо в интерфейсе Swagger UI для удобства тестирования защищенных ручек.

@Satlykovs Satlykovs self-assigned this Mar 20, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 20, 2026

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added OpenAPI documentation configuration with comprehensive API metadata and JWT security scheme support for improved API discoverability.
    • Enhanced feedback system with structured feedback types for more granular audio analysis results.
  • Chores

    • Refactored internal module dependencies and created a shared common library for improved code organization.

Walkthrough

This PR introduces a new smartjam-common module to centralize shared DTOs and model enums (S3EventDto, FeedbackEvent, FeedbackType, AudioProcessingStatus) used across multiple backend services. Both smartjam-analyzer and smartjam-api are updated to depend on this module, and analyzer code is refactored to use the common types instead of local definitions.

Changes

Cohort / File(s) Summary
Gradle Configuration
backend/settings.gradle, backend/smartjam-analyzer/build.gradle, backend/smartjam-api/build.gradle
Added subproject inclusion for smartjam-common and updated both analyzer and API modules to declare dependency on the new common project.
smartjam-common Module Setup
backend/smartjam-common/build.gradle
Introduced new Gradle build configuration with java-library plugin, Jackson dependencies, and project metadata.
smartjam-common DTOs & Models
backend/smartjam-common/src/main/java/com/smartjam/common/dto/FeedbackEvent.java, backend/smartjam-common/src/main/java/com/smartjam/common/dto/s3/S3EventDto.java, backend/smartjam-common/src/main/java/com/smartjam/common/model/FeedbackType.java, backend/smartjam-common/src/main/java/com/smartjam/common/model/AudioProcessingStatus.java
Created new shared data types: FeedbackEvent record with timing and FeedbackType, S3EventDto moved from analyzer package, and two new enums (FeedbackType: WRONG_NOTE/WRONG_RHYTHM; AudioProcessingStatus: five lifecycle states).
smartjam-analyzer Type Migrations
backend/smartjam-analyzer/src/main/java/com/smartjam/smartjamanalyzer/api/kafka/S3StorageListener.java, backend/smartjam-analyzer/src/main/java/com/smartjam/smartjamanalyzer/domain/model/AnalysisResult.java, backend/smartjam-analyzer/src/main/java/com/smartjam/smartjamanalyzer/domain/service/DtwPerformanceEvaluator.java
Updated to import and use shared types from smartjam-common; removed nested FeedbackEvent record from AnalysisResult; refactored ErrorState to use FeedbackType enum instead of message strings.
smartjam-analyzer Test Updates
backend/smartjam-analyzer/src/test/java/com/smartjam/smartjamanalyzer/api/listener/S3StorageListenerTest.java, backend/smartjam-analyzer/src/test/java/com/smartjam/smartjamanalyzer/application/AudioAnalysisIntegrationTest.java, backend/smartjam-analyzer/src/test/java/com/smartjam/smartjamanalyzer/domain/service/DtwPerformanceEvaluatorTest.java, backend/smartjam-common/src/test/java/common/dto/s3/S3EventDtoTest.java
Updated imports to reference common module types; changed test assertions to filter by FeedbackType enum values instead of message text strings; updated test output formatting to use type() instead of message().
smartjam-api OpenAPI Configuration
backend/smartjam-api/src/main/java/com/smartjam/smartjamapi/infrastructure/openapi/OpenApiConfig.java
Added new Spring configuration class that customizes OpenAPI metadata (title, version, description, contact) and registers HTTP bearer JWT security scheme globally.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • ParovozikThomas
  • men229

Poem

🐰 A rabbit hops through gradle files with glee,
Extracting common types for all to see!
DTOs and enums, neatly arranged,
From analyzer to common—beautifully changed! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: extracting shared contracts to a common module and configuring OpenAPI documentation.
Description check ✅ Passed The description is well-related to the changeset, providing detailed context about the new common module, shared contracts, and OpenAPI configuration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch satlykovs/feat/shared-contracts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can generate a title for your PR based on the changes with custom instructions.

Set the reviews.auto_title_instructions setting to generate a title for your PR based on the changes in the PR with custom instructions.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@backend/smartjam-api/src/main/java/com/smartjam/smartjamapi/infrastructure/openapi/OpenApiConfig.java`:
- Around line 29-31: The OpenAPI bean customOpenAPI() wrongly advertises JWT
security via SECURITY_SCHEME_NAME and createSecurityScheme() while no runtime
security exists; either remove the .addSecurityItem(...) and .components(...)
calls from customOpenAPI() so docs no longer claim protected endpoints, or
implement real Spring Security: add a SecurityFilterChain `@Bean`, configure
authentication/authorization rules for your endpoints, and register a JWT
validation filter/AuthenticationProvider so the documented SECURITY_SCHEME_NAME
is actually enforced at runtime. Ensure the chosen approach updates or removes
the createSecurityScheme() usage accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b3eb679b-34cd-4687-9cfd-6f986cdc0694

📥 Commits

Reviewing files that changed from the base of the PR and between 086d41a and 330f26a.

📒 Files selected for processing (17)
  • backend/settings.gradle
  • backend/smartjam-analyzer/build.gradle
  • backend/smartjam-analyzer/src/main/java/com/smartjam/smartjamanalyzer/api/kafka/S3StorageListener.java
  • backend/smartjam-analyzer/src/main/java/com/smartjam/smartjamanalyzer/domain/model/AnalysisResult.java
  • backend/smartjam-analyzer/src/main/java/com/smartjam/smartjamanalyzer/domain/service/DtwPerformanceEvaluator.java
  • backend/smartjam-analyzer/src/test/java/com/smartjam/smartjamanalyzer/api/listener/S3StorageListenerTest.java
  • backend/smartjam-analyzer/src/test/java/com/smartjam/smartjamanalyzer/application/AudioAnalysisIntegrationTest.java
  • backend/smartjam-analyzer/src/test/java/com/smartjam/smartjamanalyzer/domain/service/DtwPerformanceEvaluatorTest.java
  • backend/smartjam-api/build.gradle
  • backend/smartjam-api/src/main/java/com/smartjam/smartjamapi/infrastructure/openapi/OpenApiConfig.java
  • backend/smartjam-api/src/main/resources/application.yaml
  • backend/smartjam-common/build.gradle
  • backend/smartjam-common/src/main/java/com/smartjam/common/dto/FeedbackEvent.java
  • backend/smartjam-common/src/main/java/com/smartjam/common/dto/s3/S3EventDto.java
  • backend/smartjam-common/src/main/java/com/smartjam/common/model/AudioProcessingStatus.java
  • backend/smartjam-common/src/main/java/com/smartjam/common/model/FeedbackType.java
  • backend/smartjam-common/src/test/java/common/dto/s3/S3EventDtoTest.java

Copy link
Collaborator

@men229 men229 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ну норм

@Satlykovs Satlykovs merged commit 3a88d07 into main Mar 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants