Skip to main content

Seed Data

This document explains the seed data configuration and execution methods for development, testing, and demo environments.

Seed Data Overview

Data Summary

Data StoreData TypeCount
AuroraUsers, Orders, Payments, Inventory, Shipments50 users, 200 orders, 150 inventory items
DocumentDBCategories, Products, Profiles, Wishlists, Reviews, Notifications10 categories, 150 products, 300 reviews
OpenSearchProduct Search Index150 products
MSKKafka Topics40+ topics
ElastiCacheCache, Sessions, CartsMultiple keys

Categories (10)

IDCategory NameSlug
CAT-01Electronicselectronics
CAT-02Fashionfashion
CAT-03Foodfood
CAT-04Beautybeauty
CAT-05Home Appliancesappliances
CAT-06Sportssports
CAT-07Booksbooks
CAT-08Petspets
CAT-09Furniturefurniture
CAT-10Baby Productsbaby

Products (150)

15 products per category, totaling 150 products tailored for the Korean market.

Electronics (CAT-01)

Product NameBrandPrice
Samsung Galaxy S25 UltraSamsung Electronics1,799,000 KRW
iPhone 16 Pro MaxApple1,990,000 KRW
LG Gram 17-inch LaptopLG Electronics2,190,000 KRW
Samsung Galaxy Tab S10Samsung Electronics1,290,000 KRW
Sony WH-1000XM6 HeadphonesSony459,000 KRW

Fashion (CAT-02)

Product NameBrandPrice
Nike Air Max DNNike199,000 KRW
The North Face Nuptse PufferThe North Face369,000 KRW
Levi's 501 Original JeansLevi's129,000 KRW
Musinsa Standard SweatshirtMusinsa Standard29,900 KRW

Food (CAT-03)

Product NameBrandPrice
Nongshim Shin Ramyun Multi-PackNongshim4,980 KRW
Bibigo Wang Dumplings 1kgCJ Bibigo12,900 KRW
Jongga Whole Kimchi 3kgJongga22,900 KRW
Chamisul Fresh 360ml x20HiteJinro28,900 KRW

Users (50)

Test users with Korean names.

-- Example users
('a0000001-0000-0000-0000-000000000001', 'kim.minjun@gmail.com', 'Minjun Kim', 'active'),
('a0000001-0000-0000-0000-000000000002', 'lee.soyeon@naver.com', 'Soyeon Lee', 'active'),
('a0000001-0000-0000-0000-000000000003', 'park.jihoon@kakao.com', 'Jihoon Park', 'active'),
...

Membership Tiers

TierUser Count
bronze10
silver10
gold15
platinum10
diamond4
vip1

Orders (200)

Order data with various statuses.

Order Status Distribution

Shipping Addresses

CityDistrictExample Address
SeoulGangnam-guTeheran-ro 152
SeoulMapo-guWorld Cup-buk-ro 396
BusanHaeundae-guHaeundae Beach-ro 264
IncheonYeonsu-guSongdo Science-ro 32
DaejeonYuseong-guUniversity-ro 99
DaeguSuseong-guDalgubeol-daero 2503
GwangjuSeo-guSangmu-daero 1001
SuwonYeongtong-guSamsung-ro 129
SeongnamBundang-guPangyo Station-ro 235
JejuJeju-siNohyeong-ro 75

Kafka Topics

Topics by Domain

# Order Domain
order.created (12 partitions)
order.confirmed (12 partitions)
order.cancelled (6 partitions)
order.status-changed (12 partitions)

# Payment Domain
payment.initiated (12 partitions)
payment.completed (12 partitions)
payment.failed (6 partitions)
payment.refunded (6 partitions)

# Inventory Domain
inventory.reserved (12 partitions)
inventory.released (6 partitions)
inventory.low-stock (3 partitions)
inventory.restocked (6 partitions)

# Shipping Domain
shipping.dispatched (12 partitions)
shipping.in-transit (12 partitions)
shipping.delivered (12 partitions)
shipping.returned (6 partitions)

# Notification Domain
notification.email (6 partitions)
notification.push (6 partitions)
notification.sms (3 partitions)
notification.kakao (6 partitions)

# User Domain
user.registered (6 partitions)
user.profile-updated (6 partitions)
user.login (6 partitions)

# Product Domain
product.created (6 partitions)
product.updated (6 partitions)
product.price-changed (6 partitions)
product.viewed (12 partitions)

# Review Domain
review.submitted (6 partitions)
review.approved (6 partitions)

# Analytics Domain
search.query-logged (12 partitions)
analytics.page-view (12 partitions)
analytics.click (12 partitions)

# Infrastructure
dlq.all (6 partitions, 30-day retention)
saga.orchestrator (12 partitions)

ElastiCache Data

Cache Types

Key PatternPurposeTTL
product:{id}Product detail cache1 hour
cache:categoriesCategory list24 hours
cart:{userId}Shopping cart7 days
session:{sessionId}User session2 hours
ratelimit:api:{userId}API Rate Limit60 seconds
leaderboard:popularPopular products (Sorted Set)Permanent
stock:{productId}Real-time inventoryPermanent
search-history:{userId}Search history30 days
promo:*Promotion cacheVarious

Example Data

// Cart (cart:a0000001-0000-0000-0000-000000000001)
{
"userId": "a0000001-0000-0000-0000-000000000001",
"items": [
{"productId": "PROD-001", "quantity": 2, "price": 1799000},
{"productId": "PROD-015", "quantity": 1, "price": 299000}
],
"updatedAt": "2026-03-15T10:00:00Z"
}

// Promotion (promo:flash-sale)
{
"id": "FLASH-001",
"title": "Today Only! Up to 50% Off Electronics",
"products": ["PROD-001", "PROD-005", "PROD-010", "PROD-015"],
"discountRate": 50
}

Running Seed Scripts

Environment Variables

# Aurora
export AURORA_ENDPOINT="production-aurora-global-us-east-1.cluster-xxx.us-east-1.rds.amazonaws.com"
export AURORA_USER="mall_admin"
export AURORA_PASSWORD="<password>"
export AURORA_DB="mall"

# DocumentDB
export DOCUMENTDB_URI="mongodb://mall_admin:<password>@production-docdb-global-us-east-1.cluster-xxx.us-east-1.docdb.amazonaws.com:27017/?tls=true&replicaSet=rs0"
export TLS_CA_FILE="/tmp/global-bundle.pem"

# OpenSearch
export OPENSEARCH_ENDPOINT="https://vpc-production-os-use1-xxx.us-east-1.es.amazonaws.com"
export OPENSEARCH_USER="admin"
export OPENSEARCH_PASS="<password>"

# MSK
export MSK_BOOTSTRAP="b-1.productionmskuseast1.xxx.c3.kafka.us-east-1.amazonaws.com:9096"
export KAFKA_HOME="/opt/kafka"

# ElastiCache
export ELASTICACHE_ENDPOINT="clustercfg.production-elasticache-us-east-1.xxx.use1.cache.amazonaws.com"
export ELASTICACHE_PORT="6379"

Running Individual Scripts

cd /home/ec2-user/multi-region-architecture/scripts/seed-data

# Aurora PostgreSQL
PGPASSWORD=$AURORA_PASSWORD psql \
-h $AURORA_ENDPOINT \
-U $AURORA_USER \
-d $AURORA_DB \
-f seed-aurora.sql

# DocumentDB
# First download TLS CA certificate
wget -O /tmp/global-bundle.pem https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem
node seed-documentdb.js

# OpenSearch
bash seed-opensearch.sh

# Kafka Topics
bash seed-kafka-topics.sh

# ElastiCache
bash seed-redis.sh

Running Master Script

# Run all seed data at once
cd /home/ec2-user/multi-region-architecture/scripts/seed-data
bash run-seed.sh

# Example output
============================================
Shopping Mall - Data Seeding
Region: us-east-1
Time: 2026-03-15T10:00:00Z
============================================

──────────────────────────────────────────
▶ Aurora PostgreSQL
──────────────────────────────────────────
Seed complete: 50 users, 200 orders, 200 payments, 150 inventory items, 180 shipments
✓ Aurora PostgreSQL completed

──────────────────────────────────────────
▶ DocumentDB
──────────────────────────────────────────
Inserted 10 categories
Inserted 150 products
Inserted 50 user profiles
Inserted 30 wishlists
Inserted 300 reviews
Inserted 50 notifications
✓ DocumentDB completed

──────────────────────────────────────────
▶ OpenSearch
──────────────────────────────────────────
Bulk indexing complete: 150 products indexed successfully
✓ OpenSearch completed

──────────────────────────────────────────
▶ MSK Topics
──────────────────────────────────────────
MSK seed complete: 42 topics created
✓ MSK Topics completed

──────────────────────────────────────────
▶ ElastiCache
──────────────────────────────────────────
Total keys: 350
✓ ElastiCache completed

============================================
Seed Summary
============================================
Succeeded: 5
Failed: 0
Skipped: 0
============================================

Data Verification

Aurora Verification

-- Check count per table
SELECT 'users' as table_name, count(*) FROM users
UNION ALL
SELECT 'orders', count(*) FROM orders
UNION ALL
SELECT 'order_items', count(*) FROM order_items
UNION ALL
SELECT 'payments', count(*) FROM payments
UNION ALL
SELECT 'inventory', count(*) FROM inventory
UNION ALL
SELECT 'shipments', count(*) FROM shipments;

-- Order status distribution
SELECT status, count(*) FROM orders GROUP BY status ORDER BY count DESC;

DocumentDB Verification

// mongosh
use mall

// Count per collection
db.getCollectionNames().forEach(c => {
print(`${c}: ${db[c].countDocuments()}`);
});

// Products count by category
db.products.aggregate([
{ $group: { _id: "$category.name", count: { $sum: 1 } } },
{ $sort: { count: -1 } }
]);

OpenSearch Verification

# List indices
curl -s -u $OPENSEARCH_USER:$OPENSEARCH_PASS --insecure \
"$OPENSEARCH_ENDPOINT/_cat/indices?v"

# Test product search
curl -s -u $OPENSEARCH_USER:$OPENSEARCH_PASS --insecure \
-X POST "$OPENSEARCH_ENDPOINT/products/_search" \
-H 'Content-Type: application/json' \
-d '{"query": {"match": {"name": "Samsung"}}, "size": 5}' | jq '.hits.hits[]._source.name'

ElastiCache Verification

redis-cli -h $ELASTICACHE_ENDPOINT -p $ELASTICACHE_PORT --tls

# Key count
DBSIZE

# Top 5 popular products
ZREVRANGE leaderboard:popular 0 4 WITHSCORES

# Check cart
GET cart:a0000001-0000-0000-0000-000000000001

Data Reset

To reset data after testing:

# Aurora - Truncate tables
psql -h $AURORA_ENDPOINT -U $AURORA_USER -d $AURORA_DB << 'EOF'
TRUNCATE shipments, payments, order_items, orders, inventory, users CASCADE;
EOF

# DocumentDB - Drop collections
mongosh "$DOCUMENTDB_URI" --eval "
['categories','products','user_profiles','wishlists','reviews','notifications']
.forEach(c => db[c].drop())
"

# OpenSearch - Delete index
curl -X DELETE "$OPENSEARCH_ENDPOINT/products" --insecure -u $OPENSEARCH_USER:$OPENSEARCH_PASS

# ElastiCache - Flush all keys
redis-cli -h $ELASTICACHE_ENDPOINT --tls FLUSHALL