KhodiMart — Smart Wholesale. Big Growth.

Section 5

Technical System Reference (AI / Development Use)

Development ane AI-assisted coding mate quick reference — key algorithms, files, ane API routes.

DevelopersAdmin

Aa section development ane AI-assisted coding mate quick reference 6e — key algorithms, files, ane API routes.

5.1 MAYA Message Flow

Seller message → classifyIntent (intent.go, keyword-based, no LLM) → runEngine (engines.go — SPIE / catalog / Meesho tools) → jo SkipLLM=true to instant engine answer, nahi to narrateWithLLM (orchestrator.go, 1 LLM call, no tool calls) → structured JSON → frontend chat.

  • Entry point: service.go → SendMessage() → orchestrate()
  • Key files: intent.go, engines.go, orchestrator.go, agents.go (12 agents), tools.go (validated Go tools, LLM never runs raw SQL), context.go (seller profile/P&L/budget)
  • Response format fields: summary, analysis, table, recommendation, risks, next_action (stored in maaya_messages.response_json)
  • API route: POST /api/v1/seller/maaya/sessions/{id}/messages — auth: seller JWT + subscription feature 'maaya' (pro/elite)
  • LLM: OpenRouter free models, primary 'openrouter/free', fallback chain nemotron-nano-9b → llama-3.2-3b → gpt-oss-120b → gemma-4-31b → llama-3.3-70b → qwen3-next

5.2 Marketplace Integration Architecture

MarketplaceAuth ModelApproval TimeOrder Sync
AmazonSP-API OAuth (LWA Refresh Token + Seller ID)None — self-serviceWebhook + 15-min poll
FlipkartClient ID + Client Secret (partner-approved)15–20 business daysReal-time webhooks
MeeshoAPI Key+Supplier ID OR Merchant ID+Identifier+Secret3–7 business daysPoll every 5 minutes
  • Meesho partner env vars: MEESHO_PARTNER_CLIENT_ID, MEESHO_PARTNER_CLIENT_SECRET, MEESHO_INTEGRATION_CHANNEL_ID, MEESHO_API_BASE_URL, MEESHO_API_AUTH_MODE (simple / partner_v2)
  • Per-seller Meesho code format: KM-MSH-{seller_id}

5.3 Meesho Ops API Routes

POST /seller/meesho/uploads/preview?type=settlement|orders|returns — pre-flight file check
POST /seller/meesho/dispatch/scan — { awb }
GET  /seller/meesho/dispatch/scans — today's dispatch log
POST /seller/meesho/returns/scan — lookup return
POST /seller/meesho/returns/scan/confirm — confirm with condition
GET  /seller/meesho/returns/scans — today's return scan log
POST /seller/meesho/uploads/labels — PDF multipart upload
GET  /seller/meesho/scan/summary — today's dispatch/return counts

5.4 Core Order & Warehouse Files

DomainBackendFrontend
Ordersinternal/order/lib/api/orders.ts, seller/orders, admin/orders
Warehouseinternal/warehouse/app/(warehouse)/warehouse/
Migrationdb/migrations/000047_phase_abc.up.sql—

5.5 Development Reference Docs (Internal)

  • progress.md — Complete + pending features (single source of truth)
  • SYSTEM_FLOWS.md — Algorithms & flows
  • structure-khodi-mart.md — Vision spec
  • DEVELOPER_GUIDE.md — Local setup
  • TESTING_SMART_CATALOG.md — Test credentials