Back to list
aalmada

scaffold-read

by aalmada

Full-stack .NET online book store application with event-sourced backend API and Blazor frontend, orchestrated by Aspire.

13🍴 0📅 Jan 24, 2026

SKILL.md


name: scaffold-read description: Adds a new read operation (query) to the Backend with Marten queries, Projections, Caching, and Pagination. Use this when implementing GET endpoints or query features.

Follow this guide to implement a read-only endpoint in the Backend (ApiService) using strict project standards.

  1. Define the DTO

    • Create a record in src/Shared/BookStore.Shared/Models/.
    • Properties: Guid Id, string Name, etc.
    • Localization (Text): Map localized text to a single string (e.g., string Description), NOT a Dictionary.
    • Data Maps: Use IReadOnlyDictionary<string, T> for non-text maps (e.g., Prices).
  2. Define the Projection

    • Open/Create src/BookStore.ApiService/Projections/{Resource}Projection.cs.
    • Template: templates/Projection.cs
    • Localization Storage: Use Dictionary<string, string> for storing all translations (e.g., Descriptions, Biographies).
    • Reference: See marten-guide for projection patterns.
  3. Expose the Endpoint

    • Open src/BookStore.ApiService/Endpoints/{Resource}Endpoints.cs.
    • Template: templates/Endpoint.cs
  4. Implement Caching (HybridCache)

    • Wrap logic in cache.GetOrCreateLocalizedAsync (auto-appends culture to cache key).
    • Key: Include page, size, sort, order (culture added automatically).
    • Tags: Use CacheTags.{Resource}List or $\"{Resource.ToLower()}:{id}\".
    • Options: Set Expiration (L2/Redis) and LocalCacheExpiration (L1/memory).
    • Reference: See caching-guide for HybridCache patterns.
  5. Implement Query (Marten)

    • Use await using var session = store.QuerySession();.
    • Query: session.Query<Projection>()
    • Filter: .Where(x => !x.Deleted)
    • Paginate: .ToPagedListAsync(page, pageSize, token)
  6. Apply Localization

    • Map from Projection to DTO.
    • Text: Use LocalizationHelper.GetLocalizedValue(proj.Descriptions, culture, defaultCulture, "").
    • Maps: Copy directly (e.g., Prices = proj.Prices).
  7. Client Integration

    • Interface: Create src/Client/BookStore.Client/IGet{Resource}Endpoint.cs manually.
    • Registration: Add to BookStoreClientExtensions.cs.

// turbo 8. Verify

  • Run /verify-feature to ensure build and tests pass.

Prerequisites:

  • /scaffold-write - Ensure write operations exist before adding reads
  • /scaffold-projection - For detailed projection patterns and localization

Next Steps:

  • /scaffold-frontend-feature - Create UI to consume the query
  • /scaffold-test - Create integration tests for the endpoint
  • /verify-feature - Complete verification

Debugging:

  • /debug-cache - If caching issues occur

See Also:

Score

Total Score

75/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 100以上

0/15
最近の活動

1ヶ月以内に更新

+10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

Reviews

💬

Reviews coming soon