Skip to main content

Overview

The Seeding API provides comprehensive database initialization and test data generation for development, testing, and demo environments. This system ensures consistent data setup across different environments with UAE-specific content. Location: convex/seed.ts

Seeding Process

1

Clear Existing Data

Optional: Clear all existing data for fresh start
2

Seed Core Data

Add cities, areas, banks, categories, and platform configuration
3

Seed Test Data

Add test customers, stores, products, and orders for development
4

Verify Setup

Check seeding status and data integrity

Quick Setup

For immediate development environment setup:
// Complete database setup in one call
const result = await convex.mutation(api.seed.seedAllData);
console.log('Database seeded:', result);

// Add test data for development
await convex.mutation(api.seed.seedTestCustomers);
await convex.mutation(api.seed.seedTestOrders);

Seed All Data

Seeds all essential data types in the correct dependency order.
const result = await convex.mutation(api.seed.seedAllData);
{
  "success": true,
  "message": "All data seeded successfully",
  "results": {
    "cities": 7,
    "areas": 156,
    "banks": 15,
    "categories": 25,
    "platformConfig": "pc123456789"
  }
}

Get Seeding Status

Check the current seeding status of the database.
const status = await convex.query(api.seed.getSeedingStatus);
{
  "isSeeded": true,
  "counts": {
    "cities": 7,
    "areas": 156,
    "banks": 15,
    "categories": 25,
    "platformConfig": 1
  }
}

Individual Seeding Functions

Cities

Function: seedCities
Data: 7 major UAE cities with Arabic names

Areas

Function: seedAreas
Data: 150+ areas across all UAE cities

Banks

Function: seedBanks
Data: 15 major UAE banks with SWIFT codes

Categories

Function: seedCategories
Data: Hierarchical product categories

Test Data Generation

const customersResult = await convex.mutation(api.seed.seedTestCustomers);
// Creates 10 test customers with realistic profiles

Development Workflow

Setting up a completely fresh development environment:
// 1. Clear existing data (optional)
await convex.mutation(api.seed.clearAllData);

// 2. Seed core data
await convex.mutation(api.seed.seedAllData);

// 3. Add test data
await convex.mutation(api.seed.seedTestCustomers);
await convex.mutation(api.seed.seedTestOrders);

// 4. Verify setup
const status = await convex.query(api.seed.getSeedingStatus);
console.log('Environment ready:', status);
Adding specific data types:
// Add more areas to existing cities
await convex.mutation(api.seed.seedAreas);

// Update platform configuration
await convex.mutation(api.seed.seedPlatformConfig);

// Add more test customers
await convex.mutation(api.seed.seedTestCustomers);
Generate large datasets for testing:
// Generate bulk test data
await convex.mutation(api.seed.seedBulkOrders);

// Check database performance
const analytics = await convex.query(api.shared.analytics.getProductCountsByGlobalCategory);

UAE-Specific Data

The seeding system includes comprehensive UAE market data:

UAE Cities

Cities: Dubai, Abu Dhabi, Sharjah, Ajman, Ras Al Khaimah, Fujairah, Umm Al Quwain
Languages: English and Arabic names

UAE Areas

Coverage: 150+ areas across all emirates
Types: Districts, neighborhoods, communities, sectors

UAE Banks

Banks: All major UAE banking institutions
Data: SWIFT codes, Arabic names, regulatory compliance

Local Categories

Categories: UAE market-specific business categories
Structure: Hierarchical organization for local businesses
Seeding functions are designed for development and testing environments. Use with caution in production and always backup data before clearing.
Use getSeedingStatus to check if your database is properly initialized before running your application in development.