Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 25, 2025

Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Phase 1] Cache Tags & ProductSummary Denormalization Strategy</issue_title>
<issue_description>## Priority: P0 (Critical)
Phase: 1 - E-Commerce Core
Estimate: 2 days
Type: Story

Context

Implement targeted cache invalidation using Next.js cache tags plus a denormalized ProductSummary record to accelerate listing, cart, and merchandising queries.

Scope

  • Denormalized table: ProductSummary (id, productId, storeId, title, price, active, inventoryAvailable, primaryImageUrl, updatedAt)
  • Populate/refresh on product change, inventory change, price change
  • Cache tags: product:{id}, store:{storeId}:products, inventory:{productId}
  • Server components query ProductSummary for list views instead of full Product joins
  • Invalidation function: revalidateProduct(productId) triggers relevant tags
  • Background reconciliation job (daily) to ensure summary consistency

Acceptance Criteria

  • Product create/update triggers ProductSummary mutation & cache tag revalidation
  • Inventory change updates ProductSummary.inventoryAvailable within < 500ms
  • Listing pages use ProductSummary only (no N+1 full product fetch)
  • Stale reads after update < 5s (eventual consistency window)
  • Reconciliation job logs discrepancies count (should trend to 0)

Data Model (Draft)

model ProductSummary {
  id                 String   @id @default(cuid())
  productId          String   @unique
  storeId            String
  title              String
  price              Int
  active             Boolean  @default(true)
  inventoryAvailable Int       @default(0)
  primaryImageUrl    String?
  updatedAt          DateTime  @updatedAt

  @@index([storeId])
}

Dependencies

Metrics

  • Product list query latency reduction > 30%
  • Consistency discrepancy rate < 0.1%

Testing Checklist

  • Product update reflected in ProductSummary & listing
  • Inventory adjustment updates summary
  • Cache tag revalidation removes stale page

Risk

Performance & correctness impact (score: 15). Enables scalable product browsing.

References

  • docs/GITHUB_ISSUES_COMPARISON_ANALYSIS.md (cache tag gap section)
    </issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link

vercel bot commented Nov 25, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
stormcomui Ready Ready Preview Comment Nov 25, 2025 2:39am

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

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[Phase 1] Cache Tags & ProductSummary Denormalization Strategy

2 participants