Skip to content

feat: refactor page components for improved readability and structure#23

Open
saikumarjetti wants to merge 1 commit into
opensource-for-valkey:mainfrom
saikumarjetti:team-kanyaraasi
Open

feat: refactor page components for improved readability and structure#23
saikumarjetti wants to merge 1 commit into
opensource-for-valkey:mainfrom
saikumarjetti:team-kanyaraasi

Conversation

@saikumarjetti

Copy link
Copy Markdown

Title: Polish demo: clear chat, expanded catalog, agent guardrails

Description:

Tightens the shopping demo across three surfaces and ships an architecture brief that puts Valkey front and center.

What changed
Clear chat history from the assistant panel. New DELETE /api/agent/messages route, optimistic frontend store action, and a chat.cleared SSE event so all open tabs reset together.
Catalog expansion. ~24 new products across every leaf category with deliberately spread ratings (3.8 to 4.8) and real image URLs wired to the bundled theme thumbnails.
Agent clarification rule. Vague single-word queries ("phones", "laptops") now trigger a short follow-up with concrete options instead of an arbitrary search.
GotoTop removed from 18 page components and
Animation.jsx
; react-scroll-to-top dependency dropped.
ARCHITECTURE.md
— short brief on pub/sub, SSE, vector embeddings, similarity search, and the WebMCP-style action layer.
Valkey features showcased
This demo leans on Valkey for two load-bearing roles:

Feature Where What it does
Pub/Sub
bus.js
,
valkey.js
Per-user channel user::events carries cart.updated, chat.*, and ui.command. Two connections (cmd + sub) per the Redis protocol. Sub-millisecond fanout drives the multi-device sync and the AI's virtual cursor.
Vector store
vectorStore.js
, seedEmbeddings.js embeddings:vectors HASH (productId → base64 Float32) + embeddings:meta HASH (model, dim, count, builtAt). Atomic single-key HSET for the full index, in-process cache invalidated by meta.builtAt.
Semantic similarity
semanticSearch.js
Cosine over L2-normalized 384-d vectors collapses to a dot product. Powers the agent's semantic_search tool for descriptive queries ("something to keep my coffee warm"). Drop-in path to FT.SEARCH KNN when Valkey Search is enabled.
Pub/Sub → SSE bridge
stream.js
,
stream.js
One EventSource per signed-in user. Hello snapshot on connect, 25s heartbeat, refcounted subscriptions so multiple tabs share one Valkey subscriber.
Graceful degradation
bus.js
Falls back to an in-process EventEmitter if Valkey is unreachable, so the dev server never hard-fails.

- Updated HomePageTwo, ProductDetailsPageOne, ProductDetailsPageTwo, ShopPage, VendorDetailsPage, VendorPage, VendorTwoDetailsPage, VendorTwoPage, and WishlistPage to enhance code organization by removing unnecessary imports and comments.
- Introduced Zustand stores for authentication, cart management, chat functionality, cursor state, and server-sent events to streamline state management across the application.
- Implemented error handling and loading states in the cart and chat stores to improve user experience during asynchronous operations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant