Skip to content

perf(catalog): remove repeated catalog work and align frontend catalog contracts #250

Description

@khaira777

Summary

Catalog rendering and API contracts contain avoidable scaling and integration risks: category listing performs one child query per category, ProductGrid scans the cart once per product, and frontend catalog types disagree with raw API ID/flag representations.

Current behavior

  • main/routes/categories.ts:26-32 performs an N+1 child query pattern.
  • frontend/src/components/pos/ProductGrid.tsx:130-133 recalculates cart quantity with a filter/reduce inside every product render.
  • frontend/src/lib/types.ts:26-37,51-74,80-100,119-141,226-234 mixes numeric/string IDs and boolean/SQLite integer flags.

Expected behavior

Catalog reads and renders should scale with catalog/cart size, and frontend declarations should match the API contract.

Acceptance criteria

  • Batch category children and add query-count/performance coverage.
  • Build a memoized product-quantity lookup map before rendering products.
  • Normalize catalog IDs/flags at the API boundary and align TypeScript declarations.
  • Add contract tests for catalog IDs and SQLite boolean fields.

Relevant files

main/routes/categories.ts, frontend/src/components/pos/ProductGrid.tsx, frontend/src/lib/types.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions