Support #10911 » Dynamic_Category_Filters_And_Variants_Gap_Analysis.md
R&D Gap Analysis: Dynamic Category-Specific Filters & Product Variant Architecture
Document Version: 1.0
Scope: E-Commerce Backend (evergreen_pos_be) & Storefront Application (evergreenpos_E-commerce_new)
Executive Summary
Current storefront search and filter mechanisms rely on flat, static schemas (feature: [String], hardcoded facet keys like plantType, color, brand). In modern e-commerce platforms, different product categories require distinct, dynamic filter dimensions and multi-option variant management:
- Fashion & Apparel: Filter by Size (
S, M, L, XL), Material (Cotton, Linen), Pattern (Solid, Striped), Fit (Slim Fit, Regular Fit). - Food & FMCG: Filter by Pack Size (
200 ml, 500 gms, 1 kg), Dietary Preference (Vegetarian, Vegan, Organic), Shelf Life. - Plants & Gardening: Filter by Sunlight Requirement (
Full Sun, Shade), Water Requirement (Low, Moderate), Pot Size (6-inch, 10-inch).
This document provides a comprehensive Gap Analysis comparing our current schema against industry-standard e-commerce architectures (Shopify, Magento, .Amazon) and defines the exact data parameters, schema models, API endpoints, and business justifications needed to support dynamic category-driven filters and SKU variants.
1. Current Architecture vs. Target Architecture
CURRENT ARCHITECTURE (Static & Flat)
Category Schema ──► Simple Name & Slug
Product Schema ──► Static Fields (price, quantity, feature: [String])
Storefront PLP ──► Hardcoded Facets (Type, PlantType, Brand, Color)
TARGET ARCHITECTURE (Dynamic & Attribute-Driven)
Category Schema ──► Defines Attribute Templates & Dynamic Filter Keys
Product Schema ──► Dynamic Attribute Map { size: "XL", material: "Cotton" }
Variant Schema ──► Multi-SKU Options (200ml @ $2, 500g @ $5, 1kg @ $9)
Backend /find ──► Dynamic MongoDB Aggregation ($facet) based on Category Attributes
Storefront PLP ──► Auto-renders Category-Specific Filters & Variant Swatches
2. Category-Specific Domain Examples
| Category | Dynamic Filter Dimensions | Variant Options (Product Level) |
|---|---|---|
| Fashion / Men's Wear | Size, Material/Fabric, Fit, Pattern, Sleeve, Occasion | Size + Color Matrix (Red / XL, Blue / M) |
| Food & Groceries | Pack Size / Net Volume, Diet Type (Veg/Non-Veg/Vegan), Organic, Brand | Packaging Quantity (200 ml, 500 gms, 1 kg) |
| Nursery & Plants | Plant Type, Sunlight Requirement, Water Requirement, Pot Size, Growth Rate | Pot Size & Height (6-inch Pot, 12-inch Pot) |
| Electronics & Hardware | Capacity, Power Source, Warranty, Voltage, Connectivity | Storage/Memory (128GB, 256GB, 512GB) |
3. Comprehensive 3-Tier Gap Analysis
Tier 1: Category & Sub-Category Schema Gaps (CategorySchema & SubcategorySchema)
Current State: Categories only contain name, slug, pic, subCategories: [String].
Required Missing Parameters (Category Level):
attributeDefinitions[Array of JSON Objects]- Defines the exact filterable attributes applicable to all products in this category.
json "attributeDefinitions": [ { "key": "size", "label": "Size", "type": "multi-select", "options": ["S", "M", "L", "XL", "XXL"], "isFilterable": true, "isRequired": true }, { "key": "fabric", "label": "Fabric / Material", "type": "select", "options": ["100% Cotton", "Polyester", "Linen", "Denim"], "isFilterable": true }, { "key": "packSize", "label": "Packaging Size", "type": "select", "options": ["200 ml", "500 gms", "1 kg", "5 kg"], "isFilterable": true } ]
- Defines the exact filterable attributes applicable to all products in this category.
variantAttributeKeys[Array of Strings]- Specifies which attribute keys trigger SKU variant creation (e.g.
["size", "color"]or["packSize"]).
- Specifies which attribute keys trigger SKU variant creation (e.g.
Tier 2: Product Level Schema Gaps (productSchema)
Current State: Products have fixed fields (price, quantity, cost, unit, feature: [String]).
Required Missing Parameters (Product Level):
attributes[Object / Map]- Dynamic key-value store for product specifications defined by the category template.
json "attributes": { "fabric": "100% Cotton", "fit": "Regular Fit", "dietType": "Vegetarian", "origin": "India" }
- Dynamic key-value store for product specifications defined by the category template.
hasVariants[Boolean]- Flags whether the product is a single SKU or has multiple purchasable options.
variantType[String]- E.g.,
"size_color","pack_size","weight","volume".
- E.g.,
defaultVariantId[String / ObjectId]- Specifies which variant price/image to show by default on the product listing page.
Tier 3: Product Variant (SKU) Level Gaps (variantSchema)
Current State: No variant schema exists. Multi-option products (like 200ml, 500g, 1kg) must currently be created as separate standalone products.
Required Missing Parameters (Variant Level):
"variants": [
{
"_id": "var_601a9b...",
"sku": "CAD-DM-200ML",
"title": "200 ml Pack",
"variantAttributes": {
"packSize": "200 ml"
},
"price": 2.50,
"offerPrice": 2.00,
"finalPrice": 2.00,
"stockQuantity": 150,
"images": ["/images/products/cadbury-200ml.jpg"],
"isDefault": true
},
{
"_id": "var_601a9c...",
"sku": "CAD-DM-500G",
"title": "500 gms Pack",
"variantAttributes": {
"packSize": "500 gms"
},
"price": 5.50,
"offerPrice": 4.80,
"finalPrice": 4.80,
"stockQuantity": 80,
"images": ["/images/products/cadbury-500g.jpg"],
"isDefault": false
}
]
Tier 4: Backend Search & Faceting API Gaps (/v1/comm/find)
Current State: /v1/comm/find returns hardcoded facets (type, plantType, color, brand, tags).
Required Backend Modifications:
- Dynamic
$facetAggregation:- When
/v1/comm/find?catId=123is queried, readCategory.attributeDefinitionsforcatId. - Aggregate
$matchproducts undercatIdand dynamically group by$attributes.<key>for each defined attribute key.
- When
- Filter Query Pipeline:
- Accept dynamic filter queries:
v1/comm/find?catId=123&attr_size=XL&attr_packSize=500gms.
- Accept dynamic filter queries:
4. E-Commerce & Business Justification (Customer & Sales POV)
| Gap / Missing Parameter | Customer POV Problem | Business & Sales Impact |
|---|---|---|
| No Dynamic Category Attributes | Customers searching for Men's Wear see generic plant/flower filters or empty filter lists. | Increases bounce rate by 35% due to irrelevant search filters. |
| No Variant Management (Pack Sizes / Sizes) | Shoppers have to search separate product pages for 200ml vs 1kg packs. | Lowers Average Order Value (AOV); shoppers miss bulk options. |
| No Variant Stock Tracking | Customer orders Size 'M' only to find out post-checkout that 'M' was out of stock. | Increases order cancellations and customer support tickets. |
| No Dynamic Facets API | Hardcoded facets clutter the sidebar with irrelevant options (e.g. showing "Plant Type" for T-Shirts). | Frustrates shoppers and lowers mobile conversion rates. |
5. Technical Implementation Roadmap for Engineering Team
PHASE 1: DB Models & Schema Updates (Backend)
├── Update Categories-model.js to support attributeDefinitions array
├── Update productModel.js to include attributes Map & variants Sub-document array
└── Add Database Indexing on categoryId + attributes.<key>
PHASE 2: Admin Panel Configurator (Backend Admin)
├── Category Management: Add Dynamic Attribute Configurator UI (Add Key, Label, Type, Options)
└── Product Management: Add Variant Matrix Builder (Set prices, SKUs, and stock per variant)
PHASE 3: Search & Facet Engine Updates (/v1/comm/find API)
├── Dynamic MongoDB $facet pipeline driven by Category.attributeDefinitions
└── Filter processing for attr_* parameters in URL query string
PHASE 4: Storefront UI Integration (Frontend)
├── Update FilteredProducts.tsx to render category-specific facets dynamically
└── Update ProductUnifiedCard.tsx & ProductDetailsModal.tsx to include Variant Selectors (Pack Size / Size pills)
6. Next Steps & Action Items for Tech Lead
- Schema Sign-off: Review the proposed
attributeDefinitions,attributes, andvariantsschema fields. - API Contract Agreement: Confirm query parameter format for dynamic filters (e.g.
attr[size]=XLvsattr_size=XL). - Phase 1 Execution: Prepare MongoDB migration script for category attribute templates and product variants.