# PRD — Mini App & Marketplace Sprint (v2.11) **Status:** Shipped **Version:** frontend v2.11.0 → v2.11.2 / backend v2.11.0 → v2.11.1 **Date:** 2026-06-08 **Scope:** Telegram Mini App UX, purchase-request archive, payment history, seller shop settings, category filters --- ## 1. Summary This sprint shipped 10 planned tasks plus several hotfixes discovered in production. The main themes were: - **Archive system** — buyers can archive completed/cancelled requests to keep the active list clean - **Payment history** — web dashboard table + mini-app overlay showing full escrow transaction history - **Seller category selection** — sellers pick categories in shop settings; buyers use them to filter the marketplace - **Mini App home dashboard** — stats strip, recent requests, archive shortcut, AI assistant overlay - **Correctness fixes** — payment token validation, Telegram link env-var, notification deep-link --- ## 2. Features Shipped ### 2.1 Purchase Request Archive **Problem:** Completed and cancelled requests pile up in the buyer's request list, making it hard to find active ones. **Solution:** Three-layer archive system: - Requests with status `completed` or `cancelled` are **auto-archived** on status transition (backend service layer) - Buyer can manually archive any request via a row action in the web dashboard list - Bulk-archive available via checkbox selection - Archived requests hidden by default; accessible via "Archived" toggle in the web app and the archive overlay in the mini app **Backend changes:** - `purchase_requests` table: added `is_archived`, `archived_at`, `archived_by` columns (migration `0029_purchase_request_archive.sql`) - Self-healing boot guard (`ensurePurchaseRequestArchiveColumns`) added to `connectDatabase()` to survive cold deployments where the migration hasn't been applied yet - New routes: `GET /marketplace/purchase-requests/archived`, `POST /marketplace/purchase-requests/:id/archive`, `POST /marketplace/purchase-requests/bulk-archive` - `getMyPurchaseRequests` filters out archived by default; accepts `?includeArchived=true` **Frontend changes:** - `buyer-request-list-view.tsx`: archive row action, `showArchived` toggle, bulk selection - `TelegramArchivedRequestsView`: full-screen overlay in mini app - Archive menu row on mini app home screen (home → archived requests) **Production incident:** Migration `0029` wasn't applied before the first deploy of v2.11.0. All `GET /marketplace/purchase-requests` calls returned HTTP 500 because Drizzle's schema referenced columns that didn't exist in production. Fixed by adding the self-healing boot guard and documenting the manual SQL path. --- ### 2.2 Payment History **Problem:** No way to see a consolidated list of all escrow payments (as buyer or seller) in either the web app or the mini app. **Backend:** New endpoint `GET /payment/history?role=buyer|seller|all` — returns payments filtered by the caller's role. **Web app:** `PaymentHistoryView` — data-grid table with columns: date, request ID, counterparty, amount, status, payment method. Accessible from the "تاریخچه" nav item under Payments in the dashboard sidebar. **Mini app:** `TelegramPaymentHistoryView` — scrollable list with icon/status/direction/amount per row. Opened via the "پرداخت‌ها و امانت" quick-action row on the home screen (previously this row only navigated to the account tab). --- ### 2.3 Seller Category Selection **Problem:** Sellers had no way to tag their shop with categories. Buyers filtering the marketplace by category got back all sellers regardless. **Backend:** Added `category_ids jsonb` column to `shop_settings` (additive migration via `ensurePostgresShopSettingsSchema`). `normalizeSellerListing` now derives `categoryIds` from the seller's active templates if not set manually. **Web app:** - `ShopSettingsGeneral`: Autocomplete multi-select using real `useGetCategories()` data - `seller-filters-drawer.tsx` / `seller-filters-result.tsx`: category filter now uses `{value, label}[]` objects; label shown in active-filter chips --- ### 2.4 Mini App Home Dashboard **Problem:** Home screen was a plain banner with quick-action links — no at-a-glance status. **Added:** - `TelegramHomeStats` — 3-up stat strip: total requests (tappable → requests tab), active escrow payments (tappable → payment history overlay), unread notifications (tappable → notifications overlay) - Recent activity section: the 3 most recent requests rendered as tappable rows - Archive shortcut row: direct entry to the archived-requests overlay - `TelegramWelcomeBanner`: personalized greeting using Telegram display name with fallback to "کاربر" / "User" --- ### 2.5 AI Assistant In-App Overlay **Problem:** "دستیار هوشمند" CTA previously opened `assist.amn.gg` in a full WebView navigation, which destroyed the mini app session — the back button led nowhere. **Solution:** Assistant now loads inside an `