Skip to content

Team DoD: Challenge 10 BullMQ Valkey checkout integration#1

Open
Vasanthadithya-mundrathi wants to merge 3 commits into
opensource-for-valkey:mainfrom
Vasanthadithya-mundrathi:codex/team-dod-challenge-10-bullmq-valkey-checkout
Open

Team DoD: Challenge 10 BullMQ Valkey checkout integration#1
Vasanthadithya-mundrathi wants to merge 3 commits into
opensource-for-valkey:mainfrom
Vasanthadithya-mundrathi:codex/team-dod-challenge-10-bullmq-valkey-checkout

Conversation

@Vasanthadithya-mundrathi

Copy link
Copy Markdown

Challenge

Challenge 10: Checkout with Inventory Tracking

Integration

BullMQ + Valkey checkout backend for the Valkey e-commerce demo.

What changed

  • Adds a focused TypeScript checkout service under backend/checkout.
  • Uses BullMQ queues backed by Valkey for inventory reservation, payment processing, order confirmation, reservation release, and delivery dispatch.
  • Adds atomic Valkey Lua scripts for reserve/confirm/release inventory mutations.
  • Adds idempotency keys, order persistence, order stream events, seed fixtures, docs, and focused tests.
  • Keeps the existing frontend intact, with only test-environment fixes needed for reliable validation.

Validation

  • cd backend/checkout && npm run build
  • cd backend/checkout && npm test: 10 tests passed
  • cd frontend && CI=true npm test -- --watchAll=false
  • cd frontend && npm run build
  • Chrome browser verification: storefront rendered at 127.0.0.1:3000 and checkout API E2E passed through the browser.

Browser E2E edge cases covered

  • Missing auth returns 401 unauthorized.
  • Missing Idempotency-Key returns 400 missing_idempotency_key.
  • Insufficient stock returns 409 insufficient_stock without completing checkout.
  • Start checkout reserves inventory and returns pending_payment.
  • Idempotency replay returns the same order.
  • Confirm before payment returns 409 invalid_order_state.
  • Payment authorization transitions to payment_authorized.
  • Confirm transitions to confirmed.
  • Payment decline returns 402 payment_failed.
  • Cancel declined order transitions to cancelled and releases reservation.
  • Order listing returns the browser-created orders.

Copilot AI review requested due to automatic review settings May 24, 2026 08:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new backend/checkout service that implements a BullMQ-powered checkout workflow backed by Valkey, and updates docs/tests to support and validate it.

Changes:

  • Introduces a standalone TypeScript checkout backend (Express + BullMQ + ioredis) with inventory reservation/commit via Lua + Valkey JSON.
  • Adds unit/integration test suites (Vitest) for Valkey connection parsing, idempotency, auth, and end-to-end checkout flows.
  • Updates frontend test setup and repository docs to accommodate the new demo backend.

Reviewed changes

Copilot reviewed 24 out of 26 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
frontend/src/setupTests.js Adds window.matchMedia shim for Jest DOM usage.
frontend/src/App.test.js Reworks App render test using mocks for route-level components.
backend/checkout/vitest.config.ts Adds Vitest configuration for the checkout backend.
backend/checkout/tsconfig.json TypeScript compiler settings for backend build output.
backend/checkout/test/unit/connection.test.ts Unit tests for env-based Valkey connection construction.
backend/checkout/test/integration/checkout.test.ts Integration tests for checkout flow, idempotency, auth, and inventory correctness.
backend/checkout/src/types.ts Defines shared types for products, orders, and events.
backend/checkout/src/store.ts Implements Valkey JSON persistence, order creation, listing, and stream event emission.
backend/checkout/src/server.ts Express API endpoints for checkout, orders, and SSE order events.
backend/checkout/src/seed.ts Seeds Valkey with product fixtures.
backend/checkout/src/runtime.ts Wires config, Valkey connection, scripts, queues, and server lifecycle.
backend/checkout/src/queues.ts Defines BullMQ queues/workers for reserve/payment/confirm/release/dispatch.
backend/checkout/src/payment.ts Stub deterministic payment processor logic.
backend/checkout/src/inventoryScripts.ts Lua scripts wrapper for atomic reserve/commit/release inventory mutations.
backend/checkout/src/index.ts Service entrypoint with startup/shutdown and logging.
backend/checkout/src/ids.ts Order ID + sortable timestamp helpers (uuidv7).
backend/checkout/src/idempotency.ts Idempotency replay + locking using Valkey keys.
backend/checkout/src/fixtures.ts Product fixtures for seeding/integration tests.
backend/checkout/src/errors.ts API error type and normalization helpers.
backend/checkout/src/connection.ts Valkey connection parsing (URL vs discrete env vars) + reachability check.
backend/checkout/src/config.ts Loads service config (port, concurrency, TTL, queue prefix) from env.
backend/checkout/package.json Adds backend package scripts/deps for build/dev/test/seed.
backend/checkout/README.md Documents backend run steps, env vars, and API endpoints.
README.md Documents optional backend usage and adds repository structure/commands.
.gitignore Adds ignore rules for node_modules, dist, coverage, env files, etc.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/checkout/src/queues.ts Outdated
Comment thread backend/checkout/src/idempotency.ts
Comment thread backend/checkout/src/runtime.ts Outdated
Comment thread frontend/src/setupTests.js Outdated
Comment thread frontend/src/App.test.js
Vasanthadithya-mundrathi and others added 2 commits May 24, 2026 13:59
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

2 participants