Skip to content

_πŸ› οΈ Refactor suggestion_Β #106

@gitnasr

Description

@gitnasr

πŸ› οΈ Refactor suggestion

Application layer now imports an Infrastructure-level namespace – breaks clean architecture boundaries

Adding using Dentizone.Infrastructure; couples the Application project to the Infrastructure project. In a layered / clean-architecture setup, dependencies must point outwards (Infrastructure β†’ Application), never the other way around.
This single using will force the compiler to reference the Infrastructure assembly and may create circular-dependency headaches the moment Infrastructure needs types from Application (which it usually does).

Proposed direction (no direct patch here because it spans multiple projects):

  1. Define a lightweight IAppDbContext (or IDbContext) interface in the Application layer exposing only what the services need (Database, Set<TEntity>(), etc.).
  2. Have AppDbContext in Infrastructure implement that interface.
  3. Inject IAppDbContext into services instead of the concrete AppDbContext.
  4. Remove this using Dentizone.Infrastructure; directive; the Application layer should only know the abstraction.
πŸ€– Prompt for AI Agents
In Dentizone.Application/Services/UserService.cs at line 10, remove the using
directive for Dentizone.Infrastructure to avoid breaking clean architecture
boundaries. Instead, define an interface like IAppDbContext in the Application
layer that exposes only the necessary database operations. Modify the
Infrastructure project's AppDbContext to implement this interface. Refactor
UserService to depend on the IAppDbContext abstraction via dependency injection
rather than the concrete AppDbContext, thus eliminating the direct
Infrastructure reference.

Originally posted by @coderabbitai[bot] in #104 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions