Skip to content

Scrum 234 ai shopping assistant query foundations#17

Merged
Giabaongo merged 27 commits into
devfrom
SCRUM-234-ai-shopping-assistant-query-foundations
Jun 30, 2026
Merged

Scrum 234 ai shopping assistant query foundations#17
Giabaongo merged 27 commits into
devfrom
SCRUM-234-ai-shopping-assistant-query-foundations

Conversation

@Giabaongo

@Giabaongo Giabaongo commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Launched an AI shopping assistant chat endpoint with tool-driven product search, draft-order creation, and a two-phase order confirmation (preview then confirm).
    • Added order confirmation preview via GET /api/v1/orders/{orderId}/confirm-preview.
    • Implemented cursor-based, market-scoped product search with optional “in stock only”.
  • Bug Fixes
    • Enforced safer confirmation gating and improved session ownership protections for assistant chat.
    • Added assistant endpoint rate limiting with consistent error responses.
  • Documentation
    • Updated architecture and feature working docs, including assistant/order flow diagrams.
  • Tests
    • Added integration and unit tests covering assistant chat, confirmation preview/gating, and product search.

Giabaongo added 22 commits June 20, 2026 16:06
Move dated feature working docs (survey/audit/context/design/tasks/backlog)
out of the flat docs/ root into docs/features/<feature>/ (ai-assistant, orders,
logistics, auth-catalog). Core numbered spec stays at docs/ root so CLAUDE.md
and 00-index.md path references remain valid. Add docs/features/README.md index
and a pointer from 00-index.md.
…ira import

Design for the AI Shopping Assistant orchestration layer (Tầng 2): provider
GLM 5.2 (Free) via ZenMux behind a provider-agnostic IAssistantChatClient,
Option B host-layer, MVP 5 tools, non-streaming v1 (SSE deferred), two-phase
confirmation safety gate, DB-backed conversation store (Redis deferred). Adds
T1-T8 task breakdown and a Jira CSV bulk-import (Epic Link SCRUM-234).
…it model

Document DEC-002 (B2B credit / công nợ payment, superseding the per-order
gateway) and update the capstone registration with the implemented business
model (internal Market Agents, role set, Catalog, voice price updates).
- Non-streaming orchestrator loop (LLM <-> tool, MaxToolHops bounded)
- POST /api/v1/assistant/chat with conversation persistence
- Per-user session ownership check (404 on mismatch) prevents IDOR/session hijacking (CWE-639)
- Request validation via FluentValidation invoked explicitly (no MediatR pipeline on this path)
@kody-ai

kody-ai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Code Review Could Not Complete ⚠️

The review failed before suggestions could be generated.

Reason: The configured API key (google_gemini) is out of credits or has hit its billing limit. Top up the account or adjust the plan.

After fixing the issue, comment @kody review on this PR to re-run the review.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Business Logic

Access your configuration settings here.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Free

Run ID: 6b034476-06e6-46ac-8813-e3d122762fe0

📥 Commits

Reviewing files that changed from the base of the PR and between 1452188 and 21d93ea.

📒 Files selected for processing (14)
  • Directory.Packages.props
  • docs/00-index.md
  • docs/02A-system-overview-diagrams.drawio
  • docs/02A-system-overview-diagrams.md
  • docs/02B-state-machine-diagrams.drawio
  • docs/02B-state-machine-diagrams.md
  • docs/02C-activity-diagrams.drawio
  • docs/02C-activity-diagrams.md
  • docs/03-database-schema.dbml
  • docs/03-database-schema.md
  • docs/04-api-design.md
  • src/FreshFlow.API/FreshFlow.API.csproj
  • src/FreshFlow.API/Program.cs
  • src/FreshFlow.API/Swagger/RequestValidationSchemaBridge.cs

📝 Walkthrough

Walkthrough

The PR adds pricing product search and order-confirmation preview paths, an assistant chat stack with tool dispatch and conversation persistence, solution/runtime wiring, and updated planning, schema, and flow documentation.

Changes

Feature implementation

Layer / File(s) Summary
Market search query path
src/Modules/Pricing/..., tests/Unit/FreshFlow.Pricing.UnitTests/..., tests/Integration/FreshFlow.IntegrationTests/Pricing/...
Adds cursor-paginated market product search contracts, repository logic, and matching unit and integration coverage.
Order preview query path
src/Modules/Orders/.../PreviewOrderConfirmation/..., src/Modules/Orders/.../Services/OrderConfirmationEvaluator.cs, src/FreshFlow.API/Controllers/OrdersController.cs, tests/Unit/FreshFlow.Orders.UnitTests/...
Adds the pure order confirmation evaluator, preview query DTO/handler, confirm-order refactor, preview endpoint, and their tests.
Assistant contracts and tool surface
src/FreshFlow.API/Assistant/..., tests/Unit/FreshFlow.Assistant.UnitTests/{Dtos,Safety,Tools}/...
Adds assistant request/response contracts, safety gates, tool definitions, prompt text, and unit coverage for those contracts.
Assistant runtime and tests
src/FreshFlow.API/Assistant/..., src/FreshFlow.API/Controllers/AssistantController.cs, src/FreshFlow.API/Program.cs, src/FreshFlow.Infrastructure.Persistence/..., Directory.Packages.props, FreshFlow.slnx, tests/Integration/FreshFlow.IntegrationTests/Assistant/..., tests/Unit/FreshFlow.Assistant.UnitTests/{Conversation,Llm,Orchestration}/...
Adds the ZenMux client, conversation persistence, orchestrator/controller wiring, startup/configuration, and runtime tests.

Documentation updates

Layer / File(s) Summary
Assistant planning docs
docs/00-index.md, docs/features/README.md, docs/features/ai-assistant/*
Adds the assistant feature index, backlog, survey, design, and task documents for thin queries and orchestration.
Capstone alignment
docs/06-context-decisions.md, docs/Register-content-of-Capstone-Project.md
Updates the capstone requirements and context decisions for B2B credit, market-agent roles, and assistant behavior.
Architecture and schema docs
docs/00-index.md, docs/02A-system-overview-diagrams*, docs/02B-state-machine-diagrams*, docs/02C-activity-diagrams*, docs/03-database-schema*, docs/04-api-design.md
Adds the updated overview, state machine, activity, database, API, and validation-reference materials for the current domain state.
Logistics and order docs
docs/features/logistics/*, docs/features/orders/*
Adds logistics requirement analysis, demo context, order-flow analysis, and flow diagrams for the current domain state.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Poem

(_/)
( •_•) I hopped through tools and search at night,
/ >🌿 With chats and credits tucked just right.
I nibbled docs and tests with glee,
FreshFlow blooms like clover tea.


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands.

return false;
}

orderId = args.OrderId.Value;
var ok = (OkObjectResult)response;
ok.Value.Should().NotBeNull();
var data = ok.Value!.GetType().GetProperty("data")?.GetValue(ok.Value);
data.Should().Be(dto);
response.Should().BeOfType<OkObjectResult>();
var ok = (OkObjectResult)response;
var data = ok.Value!.GetType().GetProperty("data")?.GetValue(ok.Value) as OrderConfirmationPreviewDto;
data.Should().NotBeNull();

// Assert
await _sender.Received(1).Send(
Arg.Is<GetOrderQuery>(q => q.UserId == _userId && q.OrderId == _orderId && q.IsAdmin == false),
Comment on lines +166 to +169
catch
{
return null; // invalid cursor treated as start of list
}
Split the ERD into IMPLEMENTED (matches AppDbContextModelSnapshot) vs
PLANNED tables. Correct drifted tables (users, roles, restaurants,
products, markets, orders, order_items, scheduled_orders, driver_profiles)
and add the new tables: product_categories, units_of_measurement,
delivery_addresses, password_reset_tokens, verification_codes,
order_issues, restaurant_credit, credit_transactions,
assistant_conversations. Document the B2B credit model superseding the
invoices/payments/refunds design and the catalog normalization.
@kody-ai

kody-ai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Code Review Could Not Complete ⚠️

The review failed before suggestions could be generated.

Reason: The configured API key (google_gemini) is out of credits or has hit its billing limit. Top up the account or adjust the plan.

After fixing the issue, comment @kody review on this PR to re-run the review.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Business Logic

Access your configuration settings here.

- Correct enum value sets/casing, FK ON DELETE behaviors, and
  logical-vs-enforced FK distinctions for implemented (Part A) tables
- Note price_snapshots is a normal (non-partitioned) table
- Document the preserved user_market_assignments.market_id -> markets FK
- Mark CHECK clauses as app-enforced (not DB-level)
…rams

- 02A system overview, 02B state machines (12 pages), 02C activity
  swimlanes (9 pages) as Draw.io sources + Markdown companions
- PLANNED states/steps rendered with solid lines (grey + italic) for
  visual consistency with implemented ones
- Update 00-index with 02A/02B/02C rows and mark 03/03A as Current
- Add Sync Status banner + Part A/Part B split mirroring the ERD doc
- Part A: authoritative inventory of all 79 implemented routes (method,
  path, auth/roles) across 12 controllers + PricingHub/OrderHub, verified
  1:1 against src/FreshFlow.API/Controllers and Program.cs
- Tag Logistics/Hub/Analytics domains and DeliveryHub as [PLANNED]
- Tag dropped/changed endpoints: order-groups + system-config [PLANNED],
  generic PATCH /orders/{id}/status [SUPERSEDED], users/{id}/status [CHANGED]
- Renumber sections (Part A inserted as section 2); update 00-index row
- Add MicroElements.Swashbuckle.FluentValidation so validator rules
  (minLength/maxLength/pattern/required) surface in the generated OpenAPI
- Upgrade Swashbuckle.AspNetCore 6.9.0 -> 10.2.3 (required by MicroElements
  on net10); adapt Program.cs to Microsoft.OpenApi 3.x (OpenApiSecuritySchemeReference,
  func-based AddSecurityRequirement)
- Add RequestValidationSchemaBridge: maps *Request DTO schemas to their
  *Command/*Query validators so constraints appear without duplicating rules
  (coverage 2 -> 35 of 41 request schemas; remainder are framework/conditional)
@kody-ai

kody-ai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Code Review Could Not Complete ⚠️

The review failed before suggestions could be generated.

Reason: The configured API key (google_gemini) is out of credits or has hit its billing limit. Top up the account or adjust the plan.

After fixing the issue, comment @kody review on this PR to re-run the review.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Business Logic

Access your configuration settings here.

@Giabaongo Giabaongo merged commit a1d3a4f into dev Jun 30, 2026
3 of 6 checks passed
Giabaongo added a commit that referenced this pull request Jun 30, 2026


- ToolDefinitions.TryParseOrderId: use 'is not { } parsedOrderId' pattern so
  the Guid? null-state is explicit (no nullable dereference)
- MarketProductRepository.SearchCursor.TryDecode: narrow generic catch to
  FormatException (bad Base64) + JsonException (bad payload); behavior unchanged
- tests: explicit null checks on reflected envelope property; simplify
  'IsAdmin == false' to '!IsAdmin'
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