ifixkart-admin/docs/12-ai/current-state.md
Adithiyan bcf215d8bc fix: resolve MEDIA_LINK NameError crash and expand VARCHAR columns to 2000
- Fix NameError in link_media_groups_to_catalog: raw_mk/raw_pmk were used
  before assignment in Priority 0 comma-split block; moved fetches to top of
  variant loop so all priority levels share the same resolved values
- Expand variant_attributes.attribute_value to String(2000) for comma-separated
  multi-image media keys
- Expand products, device_models, device_series, media_library,
  migration_media_items URL/path/name columns to String(2000)
- Update Pydantic VariantAttributeCreate.attribute_value max_length=2000
- Add rollback cache eviction for new series/model keys (fixes MySQL 1452)
- Add comma-separated media key splitting in upsert_executor for multi-image
  variant image attachment
- Add Priority 0 comma-separated MEDIA_LINK support in migration_worker
- Update docs/12-ai session summary and current state
2026-11-06 11:35:15 +05:30

88 lines
9.2 KiB
Markdown

# Current State
## Current Feature
Bulk Migration Engine 2000-Character Capacity & Multi-Image Comma-Separated Media Pipeline
## Current Work
1. **Migration Pipeline 2000-Character Expansion & Comma-Separated Media Keys**:
- `variant_attributes.attribute_value`: Migrated from `VARCHAR(255)` to `VARCHAR(2000)` in database, SQLAlchemy model, and Pydantic schema (`Catalog.py`).
- Expanded column sizes to `VARCHAR(2000)` across `products.name`, `products.full_path`, `products.warranty_summary`, `product_images.image_url`, `variant_images.image_url`, `device_models.name`, `device_models.full_path`, `device_series.name`, `media_library.original_filename`, `media_library.cdn_url`, and `migration_media_items.file_name`.
- `upsert_executor.py`: Implemented comma-separated media key splitting: parses all comma-separated keys, stores individual keys in `variant_attributes`, and attaches all corresponding images in sequential order (`sort_order = 0, 1, 2, ...`).
- `upsert_executor.py`: Implemented savepoint rollback cache eviction: on `sp.rollback()`, uncommitted series and models are evicted from `series_cache` and `model_cache`, eliminating cascade foreign key errors (MySQL 1452).
- `migration_worker.py`: Added Phase 4 `MEDIA_LINK` support for comma-separated media keys, sequentially linking multi-image media groups.
- Deployed and verified on both local FastAPI and remote production server (`ifixkart.service`).
2. **Native Swarm Intelligence Engine (`swarm/`)**:
- Multi-agent digital twin simulating 50 personas across 5 behavioral archetypes.
- 4 business simulation scenarios: Pricing Elasticity, WhatsApp Campaign Pre-Flight, Workshop Surge & SLA Delay, B2B Fleet Quote Negotiation.
- Statistical calibration against real store data (2,819 orders/catalog products) with empirical 95% CI and explicit epistemic notice disclaimers.
- Air-gapped sandbox (`SET SESSION TRANSACTION READ ONLY`) preventing simulation access to live messaging/payments.
- Durable atomic queue state machine with row-level locks, heartbeats, cancellation, and startup zombie-reaper.
- FastAPI REST API (`SimulationRouter.py`) with RBAC and SlowAPI rate limiting.
- Next.js Admin UI (`/simulation`) with Recharts visualizer, Markdown synthesis, and interactive persona interview station.
1. **Dynamic Footer Router APIs & Customer Feedback Pipeline**:
- `CustomerFeedbackModel.py`: MySQL table `customer_feedbacks` for persistent user feedback storage and ratings.
- `storefront.py`: Public endpoint `POST /api/v1/storefront/feedback` and dynamic layout endpoints `GET /api/v1/storefront/layout/{page}`.
- `admin_storefront.py`: Feedbacks administration endpoints and bulk-save partition engine ensuring safe per-page updates.
- `storefrontService.ts`: Public API client fetching dynamic layouts and dispatching feedback submissions.
- Storefront dynamic pages: `/about`, `/terms`, `/privacy`, `/help`, `/feedback`, `/faqs`, `/payments`.
2. **Admin CMS "Homepage Layout" Manager Multi-Page Customizer**:
- `app/(admin)/storefront-sections/page.tsx`:
- 8 page layout tabs: `Homepage`, `Repair Services`, `About Us`, `Terms & Policy`, `Help Center`, `Feedback`, `FAQs`, `Payments`.
- Universal Section Title and Subtitle inputs for every section.
- Tailored visual editors for story paragraphs, offering cards, contact info, policy clauses, help topics, FAQs, and payment methods.
- Live toggle visibility, drag-and-drop reordering, and instant single-click publishing to the storefront.
3. **Google Analytics 4 (GA4) Integration**:
- `google_analytics_service.py`: Google Analytics Data API client authenticated via service account (`credentials/google-analytics-service-account.json`).
- `GoogleAnalyticsRouter.py`: Telemetry endpoints for status, 30-day traffic metrics, realtime active visitor count, acquisition source breakdown, and top visited product pages.
- `app/(admin)/analytics/google/page.tsx`: Realtime visitor ticker with live pulsing indicator, 30-day KPIs, traffic sources table, and property status.
2. **Google Merchant Center Product Feed**:
- `google_merchant_feed.py`: RSS 2.0 XML product feed generator with ISO-4217 INR pricing, high-res image CDN resolution, warehouse availability (`in_stock` / `out_of_stock`), and brand mapping.
- `GoogleMerchantRouter.py`: Public XML feed endpoint (`/api/v1/storefront/feed/google-merchant.xml`) and status API (`/api/v1/merchant/status`).
- `app/(admin)/merchant-center/page.tsx`: Status dashboard with feed URL 1-click clipboard copy, 1000-product compliance verification, and manual regeneration.
3. **Razorpay Payment Gateway & Audit Ledger**:
- `RazorpayDashboardRouter.py`: Net captured volume aggregation, transaction status summary (Captured/Pending/Failed), provider breakdown, and transaction ledger.
- `app/(admin)/razorpay-dashboard/page.tsx`: Net revenue cards, search and status filter bar, and 1-click CSV export.
4. **Shiprocket Logistics & Courier Operations**:
- `ShiprocketRouter.py`: Multi-carrier SLA matrix (Blue Dart, Delhivery, Ekart, DTDC), serviceability simulator, and wallet balance preview in safe disabled sandbox mode.
- `app/(admin)/logistics/page.tsx`: Pincode serviceability & rates calculator, comparative SLA breakdown, and prepaid wallet card.
5. **Social Media & WhatsApp Omnichannel Platform**:
- `meta_graph_service.py`: Facebook & Instagram Graph API v22.0 integration for Pages and Business accounts.
- `SocialMediaRouter.py`: Unified omnichannel publisher supporting Instagram feed/reels/stories, Facebook page updates, and OpenWA WhatsApp status updates (`send-text` and `send-image`) via self-hosted port `:8088`.
- `app/(admin)/social-media/page.tsx`: Omnichannel post composer supporting "All 3 Channels (IG + FB + WA)", "WhatsApp Status", "Instagram Only", and "Facebook Only". Includes 17 live Instagram visual filters, multi-channel status indicators (Instagram ID, Facebook ID, OpenWA WhatsApp session health), and dual interactive live mobile preview mockups (Instagram Feed Post & Dark WhatsApp Status screen).
6. **Enterprise Reporting Hub**:
- `ReportExportRouter.py`: High-performance streaming export for Excel (.xlsx), CSV, and PDF formats across 5 domains:
- Sales & Revenue Ledger
- Inventory & Stock Valuation
- Service & Repair Jobs
- Logistics & Deliveries
- Employee Operational Activity (Strictly operational: leads handled, deals managed, tasks resolved — NO targets/incentives).
- `app/(admin)/reports/page.tsx`: Reporting Hub with domain selector, column schema blueprints, and 1-click download buttons.
7. **30-Minute Inactivity Auto-Logout**:
- `IdleSessionManager.tsx`: Automatically monitors user activity (`click`, `mousemove`, `keydown`, `scroll`). After 28 minutes of inactivity, displays an amber/red countdown modal with 2-minute countdown timer. Supports "Stay Logged In" and "Log Out Now" with cross-tab localStorage synchronization. Automatically logs out at 30 minutes. Mounted in `app/(admin)/layout.tsx`.
8. **Navigation & Sidebar Updates**:
- `Sidebar.tsx`: Added Google Merchant Center, Social Media, and Google Analytics to `Marketing`; added Razorpay Dashboard and Shiprocket Logistics to `Sales and Billings`; and created a dedicated `Reports & Intelligence` group.
9. **Storefront Customer-Facing Intelligence & Conversion Features**:
- `components/analytics/GoogleAnalytics.tsx` & `lib/analytics.ts`: Injected GA4 Measurement tag asynchronously into Storefront `layout.tsx` with automated pageview tracking and e-commerce event triggers (`view_item`, `add_to_cart`, `begin_checkout`, `purchase`).
- `app/products/[slug]/page.tsx`: Embedded Google Shopping / Merchant Center schema.org `Product` JSON-LD with pricing, stock status, ratings, and canonical URLs.
- `components/pdp/ProductInteractiveGrid.tsx`: Integrated live 6-digit Pincode Delivery & SLA verification widget with instant courier delivery feedback.
- `components/FloatingButtons.tsx`: Added persistent floating WhatsApp quick support and repair inquiry button (`+91 90803 23589`) with animated notification beacon and hover tooltip.
- `layout/Footer.tsx`: Added WhatsApp SVG icon rendering to `SocialIcon` and configured default social connections across Instagram, Facebook, and WhatsApp.
10. **3D Isometric PillarGrid Top Selling Products Visualizer**:
- `components/dashboard/PillarGridCanvas.tsx`: Interactive HTML5 2D Canvas isometric hexagonal matrix matching 21st.dev style. Features dedicated, side-by-side unobstructed positions for Top 1 and Top 2 products, visible numeric rank indicators (`1` through `5`) directly on top caps, dramatic focus isolation on hover (+28px lift and 30% background dimming), and an instant floating black HUD tooltip showing rank, title, sales volume, and INR revenue.
- `components/dashboard/TopSellingProductsCard.tsx`: Hybrid showcase card with embedded 3D isometric pillar canvas, discrete 5-tier `LESS ... MORE` legend, rank badges (🥇, 🥈, 🥉), dynamic volume share bars with glow effects, and formatted INR revenue.
- `app/(admin)/dashboard/page.tsx`: Integrated `TopSellingProductsCard` into the Main Overview Dashboard replacing the static list widget.
## Known Issues
- None. All backend, admin, and storefront test suites, Next.js production build (70/70 pages), and live HTTP routes pass with zero errors.