Skip to content

Conversation

@jairo-litman
Copy link
Contributor

@jairo-litman jairo-litman commented Nov 18, 2025

closes #376


This pull request focuses on a significant cleanup and refactoring of the application's architecture, primarily impacting database management, automation features, and API structure.

Key changes include:

  • Database Migration Consolidation: Replaced numerous incremental database migration files with a single "baseline" migration (1763402134271-baseline.ts) that defines the current complete schema. A separate migration (1763403030146-indexes.ts) was added to explicitly create critical database indexes concurrently, improving performance and simplifying future schema management.
  • Automated Database Setup for Development: Enhanced docker-compose configurations (docker-compose.dev.yml, docker-compose.dev.small.yml) to include a dedicated migrator service. This service ensures all database migrations and seeding are successfully completed before the main application service starts, making the development environment more robust.
  • Streamlined API and Use Case Management:
    • Removed Organization-Level Automations: The entire feature set for organization-level automations, including related use cases, services, repositories, entities, and API endpoints, has been removed.
    • Refactored Team-Level Automations: Many specific team automation use cases and their corresponding API endpoints (e.g., for communication and project management automations, listing all automations, running automations) have been removed or consolidated.
    • Simplified Integration Management: Removed specific API endpoints and use cases for retrieving platform integrations, workspace IDs, and managing integration configurations.
    • Consolidated Code Management Integrations: Eliminated numerous specific API endpoints and use cases related to GitHub/GitLab/Azure Repos (e.g., getting organizations, repositories, webhooks, PAT tokens, workflows, code review status, and PR review initiation), indicating a move towards more generic or higher-level services.
    • Refactored Kody Rules and Issues Management: Removed specific API endpoints and use cases for filtering, deleting, and resynchronizing Kody rules, as well as for filtering issues and managing issues-related parameters.
    • Streamlined User and Team Management: Removed several specific API endpoints and use cases for user and team CRUD operations, user status logs, and team member invitations.
    • Deprecated Debugging/Migration Features: Removed the ModelTestController and several one-time migration use cases (e.g., for code review parameters and pull request messages).
  • Module Structure Optimization: Extensive refactoring of module imports, including the increased use of forwardRef, to resolve circular dependencies and improve the overall modularity and maintainability of the codebase.
  • Database Host Configuration Simplification: Standardized the PostgreSQL host configuration to consistently use the API_PG_DB_HOST environment variable across all environments.

@kodus-ai
Copy link

kodus-ai bot commented Nov 18, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the `@kody start-review` command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Breaking Changes
Cross File
Kody Rules
Code Style
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization

Access your configuration settings here.

@kodus-ai
Copy link

kodus-ai bot commented Nov 18, 2025

kody code-review Kody Rules critical

Changes related to environment variables were detected in docker-compose.dev.small.yml, docker-compose.dev.yml, and src/config/database/typeorm/ormconfig.ts. These files now reference or modify variables such as API_PG_DB_HOST and use env_file. Please have @Wellington01 review these changes to ensure they are correctly applied to self-hosted environments. Kody Rule violation: Verificar atualizações de variáveis de ambiente

@kodus-ai
Copy link

kodus-ai bot commented Nov 18, 2025

kody code-review Kody Rules critical

The pull request body is empty. It should include a reference to the issue it addresses, such as 'Closes #123' or 'Fixes #456', to ensure proper issue tracking. Kody Rule violation: Ensure PR closes referenced issues

Comment on lines 7 to 10
constructor(
private readonly createTeamUseCase: CreateTeamUseCase,
private readonly updateTeamUseCase: UpdateTeamUseCase,
private readonly listTeamsUseCase: ListTeamsUseCase,
private readonly findFirstCreatedTeamUseCase: FindFirstCreatedTeamUseCase,
private readonly getByIdUseCase: GetByIdUseCase,
private readonly deleteTeamUseCase: DeleteTeamUseCase,
private readonly listTeamsWithIntegrationsUseCase: ListTeamsWithIntegrationsUseCase,
) {}
Copy link

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

    constructor(
        @Inject(LIST_TEAMS_USE_CASE_TOKEN)
        private readonly listTeamsUseCase: ListTeamsUseCase,
        @Inject(LIST_TEAMS_WITH_INTEGRATIONS_USE_CASE_TOKEN)
        private readonly listTeamsWithIntegrationsUseCase: ListTeamsWithIntegrationsUseCase,
    ) {}

The ListTeamsUseCase and ListTeamsWithIntegrationsUseCase services are injected directly by their class names. According to our Kody Rules, services should be injected using symbolic tokens and the @Inject decorator to reduce coupling.

Please update the constructor to use injection tokens. You will also need to import Inject from @nestjs/common and ensure the tokens are defined and provided in the relevant module.

Kody Rule violation: Injeção de dependências via tokens

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

...UseCases,
...OrganizationAutomationUseCases,
...SaveCodeReviewFeedbackUseCase,
PromptService,
Copy link

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

{
    provide: PROMPT_SERVICE_TOKEN, // This token needs to be created and exported
    useClass: PromptService,
},

The PromptService is provided directly by its class. According to our dependency injection standards, services should be provided using symbolic tokens to improve decoupling and maintain consistency. Please define a token for PromptService and use the { provide: YOUR_TOKEN, useClass: PromptService } syntax.

Kody Rule violation: Injeção de dependências via tokens

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

...OrganizationAutomationUseCases,
...SaveCodeReviewFeedbackUseCase,
PromptService,
RunCodeReviewAutomationUseCase,
Copy link

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

{
    provide: RUN_CODE_REVIEW_AUTOMATION_USE_CASE_TOKEN, // This token needs to be created and exported
    useClass: RunCodeReviewAutomationUseCase,
},

The RunCodeReviewAutomationUseCase is provided directly by its class. According to our dependency injection standards, use cases and services must be provided using symbolic tokens to improve decoupling and maintain consistency. Please define a token for this use case and use the { provide: YOUR_TOKEN, useClass: RunCodeReviewAutomationUseCase } syntax.

Kody Rule violation: Injeção de dependências via tokens

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

GetCodeReviewFeedbackByOrganizationUseCase,
SaveCodeReviewFeedbackUseCase,
] as const;
const UseCases = [GetReactionsUseCase, SaveCodeReviewFeedbackUseCase] as const;
Copy link

Choose a reason for hiding this comment

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

kody code-review Bug critical

import { CodeReviewFeedbackController } from '@/core/infrastructure/http/controllers/codeReviewFeedback.controller';
import { GetCodeReviewFeedbackByOrganizationUseCase } from '@/core/application/use-cases/codeReviewFeedback/get-feedback-by-organization.use-case';

const UseCases = [
    GetReactionsUseCase,
    GetCodeReviewFeedbackByOrganizationUseCase,
    SaveCodeReviewFeedbackUseCase,
] as const;

@Module({
    imports: [
        MongooseModule.forFeature([CodeReviewFeedbackModelInstance]),
        forwardRef(() => TeamsModule),
        forwardRef(() => OrganizationModule),
        forwardRef(() => UsersModule),
        forwardRef(() => PlatformIntegrationModule),
        forwardRef(() => IntegrationModule),
        forwardRef(() => IntegrationConfigModule),
        forwardRef(() => ParametersModule),
        forwardRef(() => GithubModule),
        forwardRef(() => GitlabModule),
        forwardRef(() => PullRequestsModule),
    ],
    providers: [
        ...UseCases,
        PromptService,
        {
            provide: CODE_REVIEW_FEEDBACK_REPOSITORY_TOKEN,
            useClass: CodeReviewFeedbackRepository,
        },
        {
            provide: CODE_REVIEW_FEEDBACK_SERVICE_TOKEN,
            useClass: CodeReviewFeedbackService,
        },
    ],
    exports: [
        CODE_REVIEW_FEEDBACK_REPOSITORY_TOKEN,
        CODE_REVIEW_FEEDBACK_SERVICE_TOKEN,
        ...UseCases,
    ],
    controllers: [CodeReviewFeedbackController],
})

The CodeReviewFeedbackController has been removed from the module's controllers array, and its corresponding GetCodeReviewFeedbackByOrganizationUseCase has been removed from the UseCases provider list. This is a critical bug as it de-registers the module's entire HTTP API surface from the application.

Execution Analysis:

  1. At application startup, NestJS processes the CodeReviewFeedbackModule.
  2. It inspects the controllers array, which is now empty ([]).
  3. Consequently, no routes from CodeReviewFeedbackController are mapped.
  4. Any API call from a client (e.g., a frontend application) to endpoints previously handled by this controller will now fail with a 404 Not Found error.

This change effectively disables all features of this module that were exposed via HTTP, which will break any dependent services. To fix this, the controller and use case must be restored to the module definition, and their corresponding imports must be added back to the file.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

import { UseCases } from '@/core/application/use-cases/teamAutomation';
import { Module, forwardRef } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ActiveCodeManagementTeamAutomationsUseCase } from '@/core/application/use-cases/teamAutomation/active-code-manegement-automations.use-case';
Copy link

Choose a reason for hiding this comment

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

kody code-review Bug critical

import { ActiveCodeManagementTeamAutomationsUseCase } from '@/core/application/use-cases/teamAutomation/active-code-management-automations.use-case';

The import path for ActiveCodeManagementTeamAutomationsUseCase contains a typo: 'manegement' should be 'management'. This will cause the module resolution to fail during the build process, resulting in a 'Module not found' error and preventing the application from starting. The build will break because it cannot locate the file specified in the import statement, assuming the actual filename uses the correct spelling.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

@kodus-ai
Copy link

kodus-ai bot commented Nov 19, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the `@kody start-review` command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Breaking Changes
Cross File
Kody Rules
Code Style
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization

Access your configuration settings here.

@kodus-ai
Copy link

kodus-ai bot commented Nov 19, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the `@kody start-review` command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Breaking Changes
Cross File
Kody Rules
Code Style
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization

Access your configuration settings here.

@kodus-ai
Copy link

kodus-ai bot commented Nov 19, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the `@kody start-review` command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Breaking Changes
Cross File
Kody Rules
Code Style
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization

Access your configuration settings here.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
48.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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.

Reset and improve database migrations

2 participants