chore: Refactor Mandatorymodule controller to 3 tier structure #2283
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a layered architecture for the mandatory module controller, aiming to improve the maintainability and scalability of the KLM (Kyma Lifecycle Manager) codebase. This serves as an example for team discussions on refining the overall reconciliation logic and guiding future refactoring efforts.
Proposed Architecture
1. Reconciliation Controller Tier
This layer acts as the entry point for the reconciliation process and is responsible for handling all reconcile related logic.
ctrl.Result
directly—this ensures clear separation and avoids tight coupling between reconciliation flow and business processing.2. Business Logic Tier
The business logic layer is structured based on Domain-Driven Design (DDD) principles.
3. Data Tier
The data tier is strictly responsible for data access and persistence, ensuring domain models remain independent of direct API interactions.
Key Benefits of This Approach
Maintainability – Changes in one layer do not impact others directly.
Scalability – Easier to introduce new features and extend domain logic.
Testability – Each tier can be tested independently, improving reliability.
Clarity & Separation of Concerns – Avoids tightly coupled logic between reconciliation, business rules, and data access.