- Backend: FastAPI app with all models, services, schemas, routes - Admin Panel: Next.js dashboard with all modules (CRM, POS, repairs, warranties, billing, notifications, etc.) - Ecommerce: storefront (submodule) + product catalog - AI Agents: .agents/ skill library for Antigravity IDE - Docs: architecture, billing, notification gateway markdown - Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
329 lines
15 KiB
Python
329 lines
15 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
iFixKart Dataset Generator: 10 Products x 3 Variants (30 Total Variants)
|
|
Generates:
|
|
1. DATASET/ifixkart_10p_30v_catalog.xlsx (Full fields)
|
|
2. DATASET/ifixkart_10p_30v_media_subfolder.zip (Subfolder Mode)
|
|
3. DATASET/ifixkart_10p_30v_media_flat.zip (Flat File Mode: key__01.png)
|
|
"""
|
|
|
|
import os
|
|
import random
|
|
import string
|
|
import zipfile
|
|
import openpyxl
|
|
from PIL import Image, ImageDraw, ImageFont
|
|
|
|
DATASET_DIR = "/mnt/fam/SERVER/IfixKartEcommerce/DATASET"
|
|
os.makedirs(DATASET_DIR, exist_ok=True)
|
|
|
|
EXCEL_PATH = os.path.join(DATASET_DIR, "ifixkart_10p_30v_catalog.xlsx")
|
|
ZIP_SUBFOLDER_PATH = os.path.join(DATASET_DIR, "ifixkart_10p_30v_media_subfolder.zip")
|
|
ZIP_FLAT_PATH = os.path.join(DATASET_DIR, "ifixkart_10p_30v_media_flat.zip")
|
|
|
|
COLUMNS = [
|
|
"sku", "name", "parent_name", "brand", "category", "parent_category",
|
|
"device_series", "device_model", "price", "cost_price", "stock",
|
|
"description", "warranty_type", "warranty_summary", "seo_title",
|
|
"seo_description", "meta_keywords", "show_specifications", "barcode",
|
|
"media_key", "parent_media_key", "Color", "Storage", "RAM", "Condition",
|
|
"Weight_grams", "Warranty_months", "In_Box_Contents", "Country_of_Origin"
|
|
]
|
|
|
|
PRODUCTS_SPEC = [
|
|
{
|
|
"brand": "Apple",
|
|
"parent_category": "Spare Parts",
|
|
"category": "Mobile Display",
|
|
"series": "iPhone 15 Series",
|
|
"model": "iPhone 15 Pro",
|
|
"parent_name": "Apple iPhone 15 Pro Super Retina XDR OLED Display",
|
|
"parent_key": "apple-iphone-15-pro-display",
|
|
"show_specifications": True,
|
|
"variants": [
|
|
{"color": "Black Titanium", "storage": "128GB", "ram": "8GB", "price": 14999.00, "cost": 11000.00, "stock": 45},
|
|
{"color": "White Titanium", "storage": "256GB", "ram": "8GB", "price": 15999.00, "cost": 11500.00, "stock": 30},
|
|
{"color": "Natural Titanium", "storage": "512GB", "ram": "8GB", "price": 17999.00, "cost": 13000.00, "stock": 20},
|
|
]
|
|
},
|
|
{
|
|
"brand": "Samsung",
|
|
"parent_category": "Spare Parts",
|
|
"category": "Mobile Battery",
|
|
"series": "Galaxy S24 Series",
|
|
"model": "Samsung Galaxy S24 Ultra",
|
|
"parent_name": "Samsung Galaxy S24 Ultra 5000mAh High-Capacity Battery",
|
|
"parent_key": "samsung-galaxy-s24-ultra-battery",
|
|
"show_specifications": True,
|
|
"variants": [
|
|
{"color": "Titanium Black", "storage": "Standard 5000mAh", "ram": "N/A", "price": 3499.00, "cost": 2200.00, "stock": 100},
|
|
{"color": "Titanium Gray", "storage": "Enhanced 5300mAh", "ram": "N/A", "price": 3999.00, "cost": 2500.00, "stock": 80},
|
|
{"color": "Titanium Violet", "storage": "Fast-Charge 5000mAh", "ram": "N/A", "price": 4299.00, "cost": 2700.00, "stock": 60},
|
|
]
|
|
},
|
|
{
|
|
"brand": "Google Pixel",
|
|
"parent_category": "Spare Parts",
|
|
"category": "Mobile Camera",
|
|
"series": "Pixel 8 Series",
|
|
"model": "Google Pixel 8 Pro",
|
|
"parent_name": "Google Pixel 8 Pro Triple Rear Camera Module Assembly",
|
|
"parent_key": "google-pixel-8-pro-camera",
|
|
"show_specifications": True,
|
|
"variants": [
|
|
{"color": "Obsidian", "storage": "50MP Primary", "ram": "N/A", "price": 7999.00, "cost": 5500.00, "stock": 35},
|
|
{"color": "Porcelain", "storage": "48MP UltraWide", "ram": "N/A", "price": 8499.00, "cost": 5900.00, "stock": 25},
|
|
{"color": "Bay Blue", "storage": "48MP Telephoto", "ram": "N/A", "price": 8999.00, "cost": 6200.00, "stock": 15},
|
|
]
|
|
},
|
|
{
|
|
"brand": "OnePlus",
|
|
"parent_category": "Spare Parts",
|
|
"category": "Mobile Display",
|
|
"series": "12 Series",
|
|
"model": "OnePlus 12",
|
|
"parent_name": "OnePlus 12 ProX 120Hz Curved Fluid AMOLED Screen",
|
|
"parent_key": "oneplus-12-curved-display",
|
|
"show_specifications": False,
|
|
"variants": [
|
|
{"color": "Silky Black", "storage": "256GB", "ram": "12GB", "price": 11999.00, "cost": 8500.00, "stock": 50},
|
|
{"color": "Flowy Emerald", "storage": "512GB", "ram": "16GB", "price": 12999.00, "cost": 9200.00, "stock": 40},
|
|
{"color": "Glacial White", "storage": "1TB", "ram": "24GB", "price": 14499.00, "cost": 10500.00, "stock": 15},
|
|
]
|
|
},
|
|
{
|
|
"brand": "Xiaomi",
|
|
"parent_category": "Spare Parts",
|
|
"category": "Mobile Back Panel",
|
|
"series": "14 Series",
|
|
"model": "Xiaomi 14 Pro",
|
|
"parent_name": "Xiaomi 14 Pro Ceramic Glass Back Housing Panel",
|
|
"parent_key": "xiaomi-14-pro-back-panel",
|
|
"show_specifications": True,
|
|
"variants": [
|
|
{"color": "Obsidian Black", "storage": "Standard Glass", "ram": "N/A", "price": 1999.00, "cost": 1100.00, "stock": 120},
|
|
{"color": "Snow White", "storage": "Frosted Ceramic", "ram": "N/A", "price": 2299.00, "cost": 1300.00, "stock": 90},
|
|
{"color": "Jade Green", "storage": "Leather Texture", "ram": "N/A", "price": 2499.00, "cost": 1500.00, "stock": 70},
|
|
]
|
|
},
|
|
{
|
|
"brand": "Vivo",
|
|
"parent_category": "Spare Parts",
|
|
"category": "Mother Board",
|
|
"series": "X90 Series",
|
|
"model": "Vivo X90 Pro",
|
|
"parent_name": "Vivo X90 Pro 5G Unlocked Logic Board Motherboard Assembly",
|
|
"parent_key": "vivo-x90-pro-motherboard",
|
|
"show_specifications": True,
|
|
"variants": [
|
|
{"color": "Legend Black", "storage": "256GB", "ram": "8GB", "price": 18999.00, "cost": 14000.00, "stock": 10},
|
|
{"color": "Red Leather", "storage": "256GB", "ram": "12GB", "price": 20999.00, "cost": 15500.00, "stock": 8},
|
|
{"color": "Special Edition", "storage": "512GB", "ram": "12GB", "price": 23999.00, "cost": 17500.00, "stock": 5},
|
|
]
|
|
},
|
|
{
|
|
"brand": "Oppo",
|
|
"parent_category": "Accessories",
|
|
"category": "Camera Lens Guards",
|
|
"series": "Find X6 Series",
|
|
"model": "OPPO Find X6 Pro",
|
|
"parent_name": "OPPO Find X6 Pro 9H Sapphire Camera Lens Guard Protector",
|
|
"parent_key": "oppo-find-x6-pro-lens-guard",
|
|
"show_specifications": False,
|
|
"variants": [
|
|
{"color": "Clear HD", "storage": "Single Pack", "ram": "N/A", "price": 499.00, "cost": 150.00, "stock": 300},
|
|
{"color": "Matte Anti-Glare", "storage": "Dual Pack", "ram": "N/A", "price": 799.00, "cost": 250.00, "stock": 250},
|
|
{"color": "Titanium Ring", "storage": "Triple Pack", "ram": "N/A", "price": 1099.00, "cost": 380.00, "stock": 200},
|
|
]
|
|
},
|
|
{
|
|
"brand": "Motorola",
|
|
"parent_category": "Spare Parts",
|
|
"category": "Mobile Back Panel",
|
|
"series": "Edge 40 Series",
|
|
"model": "Motorola Edge 40",
|
|
"parent_name": "Motorola Edge 40 Vegan Leather Rear Battery Cover Door",
|
|
"parent_key": "motorola-edge-40-battery-door",
|
|
"show_specifications": True,
|
|
"variants": [
|
|
{"color": "Eclipse Black", "storage": "Vegan Leather", "ram": "N/A", "price": 1499.00, "cost": 800.00, "stock": 85},
|
|
{"color": "Nebula Green", "storage": "Vegan Leather", "ram": "N/A", "price": 1499.00, "cost": 800.00, "stock": 75},
|
|
{"color": "Viva Magenta", "storage": "Pantone Edition", "ram": "N/A", "price": 1799.00, "cost": 950.00, "stock": 50},
|
|
]
|
|
},
|
|
{
|
|
"brand": "Nothing",
|
|
"parent_category": "Accessories",
|
|
"category": "USB-C Cables",
|
|
"series": "Phone 2 Series",
|
|
"model": "Nothing Phone 2",
|
|
"parent_name": "Nothing Phone 2 Transparent Glyph Fast Charging Type-C Cable",
|
|
"parent_key": "nothing-phone-2-glyph-cable",
|
|
"show_specifications": True,
|
|
"variants": [
|
|
{"color": "White Transparent", "storage": "1 Meter", "ram": "N/A", "price": 1299.00, "cost": 600.00, "stock": 180},
|
|
{"color": "Dark Grey Transparent", "storage": "1.8 Meter", "ram": "N/A", "price": 1599.00, "cost": 750.00, "stock": 140},
|
|
{"color": "Special Braided", "storage": "2 Meter", "ram": "N/A", "price": 1899.00, "cost": 900.00, "stock": 100},
|
|
]
|
|
},
|
|
{
|
|
"brand": "Realme",
|
|
"parent_category": "Charging",
|
|
"category": "Charging Adapters",
|
|
"series": "GT5 Series",
|
|
"model": "Realme GT5 Pro",
|
|
"parent_name": "Realme GT5 Pro 240W SuperVOOC GaN Ultra Fast Charger",
|
|
"parent_key": "realme-gt5-pro-240w-charger",
|
|
"show_specifications": True,
|
|
"variants": [
|
|
{"color": "White GaN", "storage": "100W Dual Port", "ram": "N/A", "price": 2499.00, "cost": 1300.00, "stock": 90},
|
|
{"color": "White GaN", "storage": "150W SuperVOOC", "ram": "N/A", "price": 3299.00, "cost": 1800.00, "stock": 70},
|
|
{"color": "Black GaN", "storage": "240W Ultra Flash", "ram": "N/A", "price": 4499.00, "cost": 2500.00, "stock": 40},
|
|
]
|
|
}
|
|
]
|
|
|
|
|
|
def create_dynamic_image(label_text, sub_text, bg_color=(30, 41, 59), width=400, height=400):
|
|
"""Creates a PNG image with labeled text."""
|
|
img = Image.new("RGB", (width, height), bg_color)
|
|
draw = ImageDraw.Draw(img)
|
|
|
|
# Draw simple colorful border
|
|
draw.rectangle([10, 10, width - 10, height - 10], outline=(59, 130, 246), width=4)
|
|
draw.rectangle([20, 20, width - 20, height - 20], outline=(147, 51, 234), width=2)
|
|
|
|
# Render text using default font
|
|
try:
|
|
font = ImageFont.load_default()
|
|
except Exception:
|
|
font = None
|
|
|
|
draw.text((30, 140), "iFixKart Commerce", fill=(243, 244, 246), font=font)
|
|
draw.text((30, 170), label_text[:40], fill=(234, 179, 8), font=font)
|
|
draw.text((30, 200), sub_text[:40], fill=(168, 85, 247), font=font)
|
|
draw.text((30, 240), "Original Quality Guaranteed", fill=(34, 197, 94), font=font)
|
|
|
|
import io
|
|
buf = io.BytesIO()
|
|
img.save(buf, format="PNG")
|
|
return buf.getvalue()
|
|
|
|
|
|
def generate_dataset():
|
|
print("🚀 Generating 10 Products x 3 Variants (30 Total Variants) Dataset...")
|
|
|
|
rows = []
|
|
subfolder_images = {} # rel_path -> bytes
|
|
flat_images = {} # filename -> bytes
|
|
|
|
for p_idx, p in enumerate(PRODUCTS_SPEC, start=1):
|
|
parent_name = p["parent_name"]
|
|
parent_key = p["parent_key"]
|
|
show_specs = p["show_specifications"]
|
|
|
|
# Product parent level 3 images
|
|
for p_img_i in range(1, 4):
|
|
img_bytes = create_dynamic_image(
|
|
f"PRODUCT {p_idx}: {parent_name}",
|
|
f"Parent Image #{p_img_i}",
|
|
bg_color=(15, 23, 42)
|
|
)
|
|
# Subfolder mode: parent_key/img_01.png
|
|
subfolder_images[f"{parent_key}/img_{p_img_i:02d}.png"] = img_bytes
|
|
# Flat mode: parent_key__01.png
|
|
flat_images[f"{parent_key}__{p_img_i:02d}.png"] = img_bytes
|
|
|
|
# 3 Variants for this product
|
|
for v_idx, v in enumerate(p["variants"], start=1):
|
|
color = v["color"]
|
|
storage = v["storage"]
|
|
ram = v["ram"]
|
|
price = v["price"]
|
|
cost = v["cost"]
|
|
stock = v["stock"]
|
|
|
|
variant_sku = f"IFK-{p['brand'][:3].upper()}-{p_idx:02d}-V{v_idx:02d}"
|
|
variant_name = f"{parent_name} - {color} ({storage})"
|
|
variant_slug_part = color.lower().replace(' ', '-').replace('/', '-')
|
|
var_media_key = f"{parent_key}-{variant_slug_part}"
|
|
|
|
barcode = "".join(random.choices(string.digits, k=13))
|
|
|
|
# Variant level 3 images
|
|
for v_img_i in range(1, 4):
|
|
v_img_bytes = create_dynamic_image(
|
|
f"VARIANT {variant_sku}",
|
|
f"{color} - Image #{v_img_i}",
|
|
bg_color=(30, 27, 75)
|
|
)
|
|
# Subfolder mode: var_media_key/img_01.png
|
|
subfolder_images[f"{var_media_key}/img_{v_img_i:02d}.png"] = v_img_bytes
|
|
# Flat mode: var_media_key__01.png
|
|
flat_images[f"{var_media_key}__{v_img_i:02d}.png"] = v_img_bytes
|
|
|
|
row = {
|
|
"sku": variant_sku,
|
|
"name": variant_name,
|
|
"parent_name": parent_name,
|
|
"brand": p["brand"],
|
|
"category": p["category"],
|
|
"parent_category": p["parent_category"],
|
|
"device_series": p["series"],
|
|
"device_model": p["model"],
|
|
"price": price,
|
|
"cost_price": cost,
|
|
"stock": stock,
|
|
"description": f"Genuine OEM {parent_name}. Color: {color}, Spec: {storage}. Fully tested by iFixKart engineers.",
|
|
"warranty_type": "Brand Warranty",
|
|
"warranty_summary": "12 Months iFixKart Replacement Guarantee",
|
|
"seo_title": f"Buy Original {parent_name} ({color}) | iFixKart",
|
|
"seo_description": f"Order {variant_name} online. 100% original, tested quality, fast shipping across India.",
|
|
"meta_keywords": f"{parent_name}, {p['brand']} spare parts, {color}, ifixkart",
|
|
"show_specifications": show_specs,
|
|
"barcode": barcode,
|
|
"media_key": var_media_key,
|
|
"parent_media_key": parent_key,
|
|
"Color": color,
|
|
"Storage": storage,
|
|
"RAM": ram,
|
|
"Condition": "New",
|
|
"Weight_grams": random.randint(150, 350),
|
|
"Warranty_months": 12,
|
|
"In_Box_Contents": "Replacement Part, Installation Seal, iFixKart Certificate",
|
|
"Country_of_Origin": random.choice(["India", "Taiwan", "South Korea"])
|
|
}
|
|
rows.append(row)
|
|
|
|
# 1. Build Excel Catalog File
|
|
print(f"📊 Writing Excel file: {EXCEL_PATH} ({len(rows)} rows)...")
|
|
wb = openpyxl.Workbook()
|
|
ws = wb.active
|
|
ws.title = "Products"
|
|
ws.append(COLUMNS)
|
|
for r in rows:
|
|
ws.append([r.get(c, "") for c in COLUMNS])
|
|
wb.save(EXCEL_PATH)
|
|
print(f"✅ Saved Excel file ({os.path.getsize(EXCEL_PATH)} bytes)")
|
|
|
|
# 2. Build Subfolder ZIP Archive
|
|
print(f"📦 Writing Subfolder ZIP archive: {ZIP_SUBFOLDER_PATH} ({len(subfolder_images)} images)...")
|
|
with zipfile.ZipFile(ZIP_SUBFOLDER_PATH, "w", zipfile.ZIP_DEFLATED) as zf:
|
|
for rel_path, img_data in subfolder_images.items():
|
|
zf.writestr(rel_path, img_data)
|
|
print(f"✅ Saved Subfolder ZIP archive ({os.path.getsize(ZIP_SUBFOLDER_PATH)} bytes)")
|
|
|
|
# 3. Build Flat File ZIP Archive
|
|
print(f"📦 Writing Flat File ZIP archive: {ZIP_FLAT_PATH} ({len(flat_images)} images)...")
|
|
with zipfile.ZipFile(ZIP_FLAT_PATH, "w", zipfile.ZIP_DEFLATED) as zf:
|
|
for filename, img_data in flat_images.items():
|
|
zf.writestr(filename, img_data)
|
|
print(f"✅ Saved Flat File ZIP archive ({os.path.getsize(ZIP_FLAT_PATH)} bytes)")
|
|
|
|
print("\n🎉 Dataset generation complete!")
|
|
print(f"- Excel: {EXCEL_PATH}")
|
|
print(f"- ZIP Subfolder Mode: {ZIP_SUBFOLDER_PATH}")
|
|
print(f"- ZIP Flat Mode: {ZIP_FLAT_PATH}")
|
|
|
|
if __name__ == "__main__":
|
|
generate_dataset()
|