"""Generate demo data for Travel Company MCP Server"""
import sqlite3
import json
import random
from datetime import datetime, timedelta
from pathlib import Path
from .database import Database
# Sample data
FIRST_NAMES = [
"James", "Mary", "John", "Patricia", "Robert", "Jennifer", "Michael", "Linda",
"William", "Barbara", "David", "Elizabeth", "Richard", "Susan", "Joseph", "Jessica",
"Thomas", "Sarah", "Charles", "Karen", "Christopher", "Nancy", "Daniel", "Lisa",
"Matthew", "Betty", "Anthony", "Margaret", "Mark", "Sandra", "Donald", "Ashley",
"Steven", "Kimberly", "Paul", "Emily", "Andrew", "Donna", "Joshua", "Michelle",
"Kenneth", "Dorothy", "Kevin", "Carol", "Brian", "Amanda", "George", "Melissa",
"Edward", "Deborah", "Ronald", "Stephanie", "Timothy", "Rebecca", "Jason", "Sharon",
"Jeffrey", "Laura", "Ryan", "Cynthia"
]
LAST_NAMES = [
"Smith", "Johnson", "Williams", "Brown", "Jones", "Garcia", "Miller", "Davis",
"Rodriguez", "Martinez", "Hernandez", "Lopez", "Gonzalez", "Wilson", "Anderson", "Thomas",
"Taylor", "Moore", "Jackson", "Martin", "Lee", "Perez", "Thompson", "White",
"Harris", "Sanchez", "Clark", "Ramirez", "Lewis", "Robinson", "Walker", "Young",
"Allen", "King", "Wright", "Scott", "Torres", "Nguyen", "Hill", "Flores",
"Green", "Adams", "Nelson", "Baker", "Hall", "Rivera", "Campbell", "Mitchell",
"Carter", "Roberts"
]
CITIES = [
("New York", "NY"), ("Los Angeles", "CA"), ("Chicago", "IL"), ("Houston", "TX"),
("Phoenix", "AZ"), ("Philadelphia", "PA"), ("San Antonio", "TX"), ("San Diego", "CA"),
("Dallas", "TX"), ("San Jose", "CA"), ("Austin", "TX"), ("Jacksonville", "FL"),
("Fort Worth", "TX"), ("Columbus", "OH"), ("San Francisco", "CA"), ("Charlotte", "NC"),
("Indianapolis", "IN"), ("Seattle", "WA"), ("Denver", "CO"), ("Boston", "MA"),
("Portland", "OR"), ("Miami", "FL"), ("Atlanta", "GA"), ("Minneapolis", "MN")
]
DESTINATIONS = [
"Paris, France", "Tokyo, Japan", "London, England", "Rome, Italy",
"Barcelona, Spain", "Amsterdam, Netherlands", "Dubai, UAE", "Sydney, Australia",
"Bali, Indonesia", "Santorini, Greece", "Maldives", "Iceland",
"New York City, USA", "Los Angeles, USA", "Las Vegas, USA", "Hawaii, USA",
"Cancun, Mexico", "Cabo San Lucas, Mexico", "Costa Rica", "Peru",
"Thailand", "Vietnam", "Singapore", "Hong Kong", "Seoul, South Korea",
"Cairo, Egypt", "Morocco", "South Africa", "New Zealand", "Switzerland"
]
TRIP_TYPES = ["adventure", "luxury", "family", "cultural", "beach", "city"]
LOYALTY_TIERS = ["Bronze", "Silver", "Gold", "Platinum"]
BUDGET_RANGES = ["$1000-2000", "$2000-5000", "$5000-10000", "$10000+"]
def generate_customers(cursor: sqlite3.Cursor, num_customers: int = 100):
"""Generate customer records"""
customers = []
for i in range(num_customers):
first_name = random.choice(FIRST_NAMES)
last_name = random.choice(LAST_NAMES)
name = f"{first_name} {last_name}"
email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1, 999)}@email.com"
phone = f"({random.randint(200, 999)}) {random.randint(200, 999)}-{random.randint(1000, 9999)}"
city, state = random.choice(CITIES)
address = f"{random.randint(100, 9999)} {random.choice(['Main', 'Oak', 'Maple', 'Cedar', 'Elm'])} St"
registration_date = (datetime.now() - timedelta(days=random.randint(30, 1095))).strftime("%Y-%m-%d")
loyalty_tier = random.choice(LOYALTY_TIERS)
preferences = {
"dietary": random.choice(["none", "vegetarian", "vegan", "gluten-free"]),
"interests": random.sample(["culture", "food", "adventure", "relaxation", "shopping", "nightlife"], k=random.randint(2, 4))
}
cursor.execute("""
INSERT INTO customers (name, email, phone, address, city, state, country, registration_date, loyalty_tier, preferences)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""", (name, email, phone, address, city, state, "USA", registration_date, loyalty_tier, json.dumps(preferences)))
customers.append(cursor.lastrowid)
return customers
def generate_trips(cursor: sqlite3.Cursor, customer_ids: list, num_trips: int = 200):
"""Generate trip records"""
for i in range(num_trips):
customer_id = random.choice(customer_ids)
destination = random.choice(DESTINATIONS)
# Generate dates
days_ago = random.randint(-90, 730) # Some future trips, some past
start_date = datetime.now() + timedelta(days=days_ago)
duration = random.randint(3, 21)
end_date = start_date + timedelta(days=duration)
# Determine status
if start_date < datetime.now():
if end_date < datetime.now():
status = random.choice(["completed", "completed", "completed", "cancelled"])
else:
status = "upcoming"
else:
status = "upcoming"
booking_date = (start_date - timedelta(days=random.randint(14, 180))).strftime("%Y-%m-%d")
start_date_str = start_date.strftime("%Y-%m-%d")
end_date_str = end_date.strftime("%Y-%m-%d")
cost = round(random.uniform(800, 12000), 2)
num_travelers = random.choice([1, 1, 2, 2, 2, 3, 4])
trip_type = random.choice(TRIP_TYPES)
notes_options = [
None, None, None, # Most trips have no notes
"Special anniversary trip",
"Requested ocean view room",
"Vegetarian meals required",
"Celebrating birthday",
"First time international travel",
"Needs accessible accommodations"
]
notes = random.choice(notes_options)
cursor.execute("""
INSERT INTO trips (customer_id, destination, start_date, end_date, cost, status, booking_date, num_travelers, trip_type, notes)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""", (customer_id, destination, start_date_str, end_date_str, cost, status, booking_date, num_travelers, trip_type, notes))
def generate_requests(cursor: sqlite3.Cursor, num_requests: int = 50):
"""Generate information request records"""
statuses = ["pending", "contacted", "converted", "closed"]
status_weights = [0.3, 0.2, 0.15, 0.35] # More pending and closed
for i in range(num_requests):
first_name = random.choice(FIRST_NAMES)
last_name = random.choice(LAST_NAMES)
name = f"{first_name} {last_name}"
email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1000, 9999)}@email.com"
if random.random() > 0.3: # 70% have phone numbers
phone = f"({random.randint(200, 999)}) {random.randint(200, 999)}-{random.randint(1000, 9999)}"
else:
phone = None
destination_interest = random.choice(DESTINATIONS)
# Travel dates
future_date = datetime.now() + timedelta(days=random.randint(30, 365))
travel_dates = future_date.strftime("%B %Y") if random.random() > 0.2 else "Flexible"
num_travelers = random.choice([1, 2, 2, 3, 4, 5])
budget_range = random.choice(BUDGET_RANGES)
messages = [
f"Interested in visiting {destination_interest}. Looking for recommendations.",
f"Planning a trip for {num_travelers} people. What packages do you offer?",
f"Can you help plan a {random.choice(TRIP_TYPES)} trip to {destination_interest}?",
f"Looking for the best time to visit {destination_interest}.",
f"Need help with itinerary planning for {destination_interest}.",
"What are your most popular destinations?",
f"Do you offer group discounts for {num_travelers} travelers?",
"Looking for all-inclusive packages.",
]
message = random.choice(messages)
days_ago = random.randint(0, 60)
request_date = (datetime.now() - timedelta(days=days_ago)).strftime("%Y-%m-%d")
status = random.choices(statuses, weights=status_weights)[0]
cursor.execute("""
INSERT INTO requests (name, email, phone, destination_interest, travel_dates, num_travelers, budget_range, message, request_date, status)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""", (name, email, phone, destination_interest, travel_dates, num_travelers, budget_range, message, request_date, status))
def seed_database():
"""Initialize database with demo data"""
print("Initializing Travel Company database...")
# Initialize database
db = Database()
print("Creating schema...")
db.initialize_schema()
cursor = db.conn.cursor()
# Check if data already exists
cursor.execute("SELECT COUNT(*) FROM customers")
if cursor.fetchone()[0] > 0:
print("Database already contains data. Skipping seed.")
db.close()
return
print("Generating customer data...")
customer_ids = generate_customers(cursor, num_customers=100)
print("Generating trip data...")
generate_trips(cursor, customer_ids, num_trips=200)
print("Generating request data...")
generate_requests(cursor, num_requests=50)
db.conn.commit()
db.close()
print("Database seeded successfully!")
print(f" - {len(customer_ids)} customers")
print(f" - 200 trips")
print(f" - 50 requests")
if __name__ == "__main__":
seed_database()