← Back to all files

Phase 0 discovery and proposed implementation

Date: 2026-11-07 (Asia/Dhaka). Source of requirements: docs/spec.md.

Status: after the user's restore, Mart catalog structure is visible. Candidate field mappings are documented below; business semantics and live-data authority remain unverified. This document proposes implementation; it does not approve database changes or establish unknown business rules.

Subsequent update: the user authorized creating new tables. The six Phase 1 chatbot tables were added to the configured local database with a chatbot_ prefix. See docs/chatbot-tables.md and docs/progress.md for current state; the findings below record the pre-implementation baseline.

Post-restore source inspection (2026-11-07)

The user restored the database and authorized checking it. Direct PDO inspection of localhost:3308/mart confirmed MySQL 8.4.3 and 31 tables. Exact aggregate counts: 3,082 products, 188 categories, and 3,159 category-product links. Counts show restored data is present; no pre-loss manifest is available to prove completeness. Evidence is saved in docs/mart-schema-discovery.json.

Capability Verified schema candidates Remaining verification
Product identity products.id primary key; nullable sku, external_id, barcode; unique url Confirm actual sellable/order identifier and whether a product row represents one pack/variant. No separate variant table is visible.
Name and descriptive content products.name, short_description, description, specifications, meta Content/language formats and safe display/search handling; contents not inspected.
Brand Nullable products.brand string; no separate brand table visible Confirm canonical spelling/identity. Do not invent brand IDs for synonyms.
Pack/unit Nullable products.unit, sold_by Confirm pack formats, quantity interpretation and variable-weight rules.
Price/currency Nullable decimal regular_price, sale_price; currency defaults to BDT Confirm populated currencies, sale eligibility, tax/quantity rules and authoritative freshness. A non-null sale price alone does not establish eligibility.
Stock products.stock_status, default unknown Confirm actual statuses, freshness and sellability rules. No stock quantity column is visible.
Categories categories.id, self-referencing parent_id, name, depth, is_leaf, is_active; products.category_id; category_product composite primary key and foreign keys Confirm primary category versus pivot membership and effective hierarchy/visibility.
Delivery delivery_zones.name, fee, free_over, min_order, eta, is_active, position Confirm address-to-zone selection, thresholds, eligibility and operating hours. Row values not inspected.
Offers No dedicated offer/promotion table visible Obtain authoritative rules/contract; do not infer Buy 2 Get 1 logic from prices or arbitrary metadata.
Checkout/orders Order tables visible by name only Table existence does not establish an approved API, idempotency, validation or customer authorization. Automated submission remains unavailable.

products.listing_scraped_at, detail_scraped_at, and category scraping workflow columns are present. This suggests ingestion/scraping behavior but does not establish source authority or update frequency. Confirm these semantics before reporting stored prices or stock as live. Existing product indexes include brand, SKU, barcode and stock status; no index changes were made.

All six chatbot tables are empty. Saved definitions are equivalent after ignoring redundant explicit utf8mb4 charset declarations; six chatbot foreign-key constraints are present. Chatbot migration-tracking rows were initially absent after restore. Subsequent approved repair recorded all six in batch 10; Laravel reports them as Ran. No table definitions or business data were changed. The original 25 migration records were preserved. See docs/chatbot-migration-reconciliation.json for the repair audit. Do not recreate the existing tables or import the saved schema; keep future chatbot migrations scoped to their own directory and connection.

Inspection used read-only transactions: schema metadata, exact catalog/chatbot counts, scoped migration tracking and chatbot SHOW CREATE TABLE. No customer/order records, settings values, product descriptions or other catalog contents were fetched. No database changes were made. Application work and unresolved policies still require the phase decisions in the spec.

The remaining sections preserve the original pre-restore discovery baseline; source-unavailable statements there are superseded by this update.

1. Findings and evidence

Local project

Area Observed evidence Implication
Framework composer.lock: Laravel 13.40.0; composer.json: PHP ^8.3 Reuse the installed Laravel application.
Runtime CLI PHP 8.4.15 from D:/wamp/bin/php/php8.4.15/php.exe; Composer 2.9.7 CLI currently uses Wamp PHP despite the project living under Laragon. Web-server PHP has not been verified.
Database Configured default connection mysql; selected schema mart; server reports MySQL 8.4.3 The required named chatbot and mart connections do not exist yet.
PHP database support PDO MySQL and SQLite available Local MySQL development and isolated SQLite unit/feature fixtures are possible.
Frontend Blade welcome view; JavaScript imports Axios; Vite 7 and Tailwind 4 declared in package.json Use Blade and lightweight JavaScript. No SPA or Livewire is installed.
Frontend runtime Laragon Node 22.23.2 and npm 10.9.8 found by absolute path Node/npm are absent from this shell's PATH. No node_modules, npm lockfile or built asset manifest found. Asset build not run.
Routes routes/web.php and artisan route:list --except-vendor show only the welcome page No chat, catalog, cart, checkout or staff routes exist.
Auth App/Models/User.php has name/email/password; session guard in config/auth.php No staff login UI, staff roles, guest/customer identity integration or Mart authentication bridge exists.
Persistence Database sessions, cache and queue selected; local filesystem points to storage/app/private Framework writes currently use the default database. They must move to chatbot ownership before feature work.
Integration No Mart repositories, schema export, API contract or credentials under named Mart configuration found Database access alone provides no checkout integration.
AI/realtime/admin No Laravel AI SDK, provider SDK, Scout, Reverb, Filament or Livewire in the dependency lockfile These are not existing capabilities to reuse.
Tests/style PHPUnit 12.5.43, Pint 1.32.1; .editorconfig requires UTF-8, LF and four spaces Reuse PHPUnit and Pint. No existing Services/Actions convention beyond the skeleton.
Version control Git 2.47.1 found under Laragon, but workspace is not a Git repository No repository status/diff history is available. No repository was initialized.
Local instructions No applicable AGENTS.md found in the workspace or inspected ancestor directories The replacement spec supplies the phase boundary.

The public directory is empty; index.php and .htaccess are at the project root. Before deployment, establish a public-only document root and restore the entry point/assets there. The current rewrite rule passes existing files through; server-level access restrictions were not inspected, so this layout must not be assumed to protect project files. Preserve the user's local URL until the approved setup work establishes the desired hosting arrangement.

Database inspection scope

Inspection used schema metadata constrained by TABLE_SCHEMA = DATABASE() on the configured connection, inside a read-only transaction that was rolled back. No customer, order, payment or product records were retrieved. No other schemas were inspected in this phase. No migrations, seeders, DDL or business-data writes were run.

Nine tables are visible in the configured mart schema:

cache, cache_locks, failed_jobs, job_batches, jobs, migrations, password_reset_tokens, sessions, users.

Their columns match the Laravel skeleton migrations. users contains name/email/password fields and no Mart-specific customer linkage. These tables are evidence of a Laravel setup, not an authoritative Mart catalog. The actual Mart schema may be elsewhere or outside this account's visibility. Read-only database privileges have not been established; a read-only inspection transaction does not prove least-privilege credentials.

Mart field-to-chatbot mapping

Unavailable below means unavailable through the current authorized connection and supplied files; it does not mean the store lacks the capability.

Required capability Status Verified source mapping Required evidence before enabling
Products and sellable SKUs/variants Unavailable No visible source table/field Approved schema, primary key, product-to-SKU relation, active/deleted visibility rules
Product names/descriptions Unavailable Unmapped Display/search fields, language fields and visibility rules
Categories and nesting Unavailable Unmapped Category IDs, parent relationship, product assignments
Brands Unavailable Unmapped Brand identity/name and SKU/product relationship
Pack sizes and units Unavailable Unmapped Original pack label, normalized amount/unit if present, variable-weight handling
Regular/current sale price and BDT Unavailable Unmapped Amount units, tax inclusions, active date/time rules, customer/quantity conditions
Stock and sellability Unavailable Unmapped On-hand/reserved/warehouse rules, backorders and availability flags; no assumption that quantity > 0 means sellable
Active offers Unavailable Unmapped Offer conditions, effective times and authoritative eligibility/quote mechanism
Delivery zones/fees/minimum/windows/hours Unavailable Unmapped Zone selection and authoritative rules, including unknown/unsupported areas
Checkout quotes Unavailable No documented integration Quote contract including final terms, expiry and customer eligibility
Order creation/idempotency/reconciliation Unavailable No documented integration Authenticated integration with stable identifiers and uncertain-result recovery
Customer identity/ownership verification Unavailable Local skeleton User is not a verified Mart customer model Approved guest identity policy and any Mart verification contract
Existing order tracking Unavailable; deferred Unmapped Authorized ownership verification plus approved status contract
Chatbot framework persistence Available The nine framework tables above, currently on the default mysql connection Decide ownership/database destination before further writes or migrations

Product counts, four-level category depth, sample product names, prices, stock, offers and delivery promises from the spec remain unverified. No mappings or domain models should be guessed from those examples.

Baseline verification

2. Proposed architecture and local stack

Use the existing Laravel/PHP setup, MySQL 8.4, PHPUnit/Pint, Blade, Tailwind and Vite. Make Node/npm available to development commands using the installed Laragon runtime. Keep browser and test base URLs explicit and separate.

Browser text UI (voice adapter in Phase 4)
  -> web routes + CSRF + rate limits + session ownership
  -> conversation orchestrator + durable local message/tool evidence
  -> replaceable ShoppingAgent interface
  -> allowlisted validated tools
       -> Mart read repository -> approved mart tables/views (SELECT only)
       -> local actions -> chatbot tables

Staff authentication + policies
  -> request review/reconfirmation actions
  -> durable submission workflow -> approved Mart integration, when available

Suggested organization: app/Contracts for replaceable interfaces; app/Integrations/Mart for source mappings/read models/repositories; app/Ai/Agents and app/Ai/Tools for provider-facing code; app/Actions/Chatbot for state changes; conventional controllers, form requests, policies and jobs. Introduce only directories needed by the current phase.

Connection and migration safeguards

Agent and providers

Propose the first-party Laravel AI SDK behind ShoppingAgent: official documentation supports Anthropic text agents, tools, structured output and test fakes. It is not installed here; exact package dependency resolution and the chosen model's tool behavior must be checked before accepting a Phase 1 lockfile. Laravel AI SDK documentation.

Use Claude as requested, with an explicit model ID in configuration. A preliminary low-latency evaluation candidate is claude-haiku-5-5; the official current model overview lists it for latency-sensitive workloads and tool use. This is a candidate, not an approved provider-spending decision or a tested Banglish accuracy claim. Resolve budget/account access and verify the SDK/model combination before live calls. Use fake responses for deterministic tests. Claude model overview.

Do not expose SQL, shell execution, arbitrary HTTP fetching or unrelated provider tools to the shopping agent. The server enforces tool permissions, result bounds and checkout gates. The LLM cannot issue customer confirmation or staff approval.

Keep SpeechToText and TextToSpeech interfaces for Phase 4. Defer provider selection until 2–3 current providers can be compared using official documentation and representative grocery recordings; no speech evaluation corpus or authorized provider budget is present. First voice transport is HTTP/push-to-talk. Realtime/barge-in infrastructure is deferred.

Use a chatbot-owned database queue for summaries/analytics/optional audio archival; persist required evidence synchronously. Store audio privately with staff-authorized playback routes when added. Session outcomes need an approved idle-expiry policy before automatic finalization; proposed semantics distinguish inquiries without draft activity from abandoned incomplete drafts, while requests/orders retain their durable outcomes.

3. Proposed chatbot-owned tables and references

These are conceptual fields for review, not executable migrations. All local relationships use local foreign keys. Mart identifiers use the actual discovered source type; no cross-database foreign keys are proposed.

Phase Table(s) Main fields and constraints
1 Existing framework tables on approved chatbot database Users, sessions, cache, jobs and migration tracking; decide whether to reuse the current skeleton database or create the proposed separate database before provisioning
1 chat_sessions Local ID/public UUID, owner binding, locale/channel, notice version/consent timestamp, started/last-active/ended timestamps, nullable terminal outcome; keep session state separate from outcome
1 chat_messages Session FK, unique (session_id, sequence), role, finalized text, original language, provider/message IDs, nullable confidence, latency, timestamps; audio fields added in Phase 4
1 chat_extractions Message/session FK, intent, necessary entities, candidate/selected external IDs, nullable confidence, extraction version; minimize repeated personal details
1 chat_tool_calls Session/message FK, tool name, sanitized input/output, success/status, duration, correlation identifier, timestamps; never store secrets
1 product_synonyms Locale, normalized alias, target kind and external target reference, active flag; indexed alias lookup and duplicate-mapping constraint; starter vocabulary requires validated targets
1 follow_up_requests Session FK, reason/status and timestamps, so an inquiry handoff reports an actual persisted state; staff assignment added with staff workflow
2 draft_carts, draft_cart_items Session/cart ownership and version; sellable reference; requested amount/unit distinct from pack count and selected SKU/pack; price observations include source/time and are not executable quotes
2 checkout_details Draft/cart FK, validated customer name/phone/address/notes, revision; protect fields and avoid scattering copies through tool records
2 checkout_quotes Cart version, authoritative/estimate status, source reference, amounts/currency, verified terms, unknown terms, expiry and immutable content hash; never manufacture unknown fees
2 order_requests, request_confirmations Unique public reference/local idempotency key, immutable confirmed snapshot, quote/cart version, direct finalized customer evidence, confirmation scope/expiry, review/reconfirmation state; later corrections produce a new version
2 Local staff access and staff_audit_events Reuse local users with explicit staff authorization; no public staff registration; actor, action, request/session reference, reason, time and protected changes
3 submission_attempts Request/version FK, durable idempotency key, integration/attempt state, safe remote result, external order reference, reconciliation timestamps; request and key constraints prevent duplicate submission
4 Message audio metadata Private disk/path, duration, encoding and retention timestamps; nullable confidence/provider metadata retained truthfully

Normal order flow: draft -> awaiting_customer_confirmation -> pending_review -> approved -> submitting -> submitted. Include needs_reconfirmation, rejected, expired and submission_unknown. Retries must never treat submission_unknown as proof of failure. Local approval does not reserve stock.

External references to sellables/categories/brands/orders carry source identity and verified reference values only. They do not imply customer ownership, current stock or permission to read an order. Keep immutable confirmation evidence access-controlled; retention and deletion policy must specify its relationship to mutable customer fields.

4. Order integration decision and unresolved choices

Decision for the proposed initial release: local requests plus staff review; automated Mart submission stays disabled. No order integration was supplied or discovered. Do not insert directly into Mart order/stock/payment tables. Manual handoff may be added with an authorized procedure and a verified external reference, without claiming automatic order creation.

Future automated submission belongs to a server-side workflow with durable attempts and policies, not to a model-controlled approval flag. It requires an approved contract for quote/authentication, stock validation, promotions, required checkout fields, idempotency and reconciliation. Customer approval and staff approval are separate version-bound evidence. Material changes invalidate both as appropriate and require renewed customer confirmation before any submission.

Needed before enabling Phase 1 live inquiries

  1. Identify the actual Mart catalog database or supplied schema export; the configured schema exposes framework tables only. Supply approved tables/views and semantics for sellable identity, price and stock. Keep credentials in local configuration, not chat or documentation.
  2. Approve lara_chatbot as the separate chatbot database, or name the intended alternative and clarify ownership of the existing nine framework tables. No database creation/move/drop is implied by this proposal.
  3. Approve guest inquiry ownership and transcript policy: proposed browser-session-bound guest conversations with no Mart customer lookup, a visible logging notice/consent gate, and staff-only review. Specify retention for messages/tool records and whether any contact details may be collected in Phase 1; proposed Phase 1 collects none intentionally.
  4. Confirm the Claude account/budget and explicit model configuration before paid provider calls. Without this, fake-agent development can proceed after phase approval, but real conversational capability cannot be claimed complete.

Needed by later phases

5. Phased implementation and acceptance gates

Phase Proposed deliverable Required acceptance evidence
0 This discovery report and docs/progress.md; replace unknown mappings once source is available Explicit source scope; no invented mappings; architecture/database decisions reviewed; implementation approval recorded
1 Named connections and migration guards; mapped Mart read adapters; synonyms; local inquiry persistence; fakeable Claude adapter; Blade text chat Isolated tests cannot reach real Mart; all framework writes stay local; verified mapped price/stock queries; truthful unknowns; Frutika size ambiguity and Parachute/no-match cases; Bangla/Banglish aliases; session isolation, CSRF/rate limits, sanitized tool logs and provider/Mart outage behavior; baseline URL issue corrected; assets build
2 Draft quantities/units and checkout details; immutable request confirmation; staff auth/review/follow-up Rice/oil/eggs pack resolution; correct-line corrections/removal; phone normalization/readback; conflicting confirmations rejected; version changes require reconfirmation; concurrent local requests deduplicated; no false Mart-order message; unauthorized staff/customer access denied
3 Approved integration adapter or documented manual handoff Final terms validated; customer/staff gates enforced; duplicates/timeouts reconciled; no unsafe retry; only verified receipt/reference marks actual submission; tests use nonproduction fixtures/integration
4 Replaceable STT/TTS, finalized captions and push-to-talk voice UI Representative multilingual speech evaluation; Android Chrome/iOS Safari recording/playback; nullable confidence; partial transcripts and interrupted readbacks cannot authorize; denial/failure retains text/cart; stage-by-stage latency measured
5 Embedding/deployment, monitoring, approved pruning and rollout controls Origin/session/CSRF/CORS checks; public-only document root and private audio authorization; permission checks; outages and recovery; retention schedule; disable-submission flag preserves reconciliation

Phase 4 can follow Phase 2 while a Mart bridge remains unavailable, with automated submission disabled. Security, ownership, audit evidence and relevant tests ship with each feature. Each phase ends with a concrete result, checks and blockers for approval before the next phase.

No application implementation or schema changes have been made as part of this Phase 0 report. Mart mapping cannot be approved until the actual source is available.