Skip to content

Decouple repository interfaces from transport DTOs and make database operations asynchronous #8

Open

Description

@666mxvbee

Problem

Repository interfaces depend on HTTP/Kafka contracts from LinkTracker.Shared:

Repositories currently return LinkResponse and TagResponse, which are transport DTOs.

Repository operations are also synchronous, causing ASP.NET worker threads to block while waiting for PostgreSQL.

Proposed solution

  • Introduce domain models or application projections for links, tags, and scheduled links.
  • Move mapping to HTTP responses into the API layer.
  • Convert repository methods to async methods.
  • Add CancellationToken to all database operations.
  • Preserve both SQL and EF Core implementations.
  • Handle concurrent inserts safely in the ORM implementation.

Acceptance criteria

  • Repository interfaces do not reference LinkTracker.Shared.Models.
  • Repository implementations return domain/application models.
  • All database operations use async Npgsql or EF Core APIs.
  • All operations accept a CancellationToken.
  • Concurrent link and tag creation does not cause an unhandled unique-constraint exception.
  • The same repository contract tests pass for SQL and ORM implementations.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions