Skip to content

Bartendie Seed Data Infrastructure

The Bartendie seed data infrastructure provides a comprehensive system for populating the application with realistic sample data across all domain entities. This system is built on event sourcing principles, ensuring data consistency and auditability.

  1. Base Module (lib/bartendie/seeds/base.ex)

    • Common utilities for all seed modules
    • Command dispatching with error handling
    • Deterministic UUID generation for idempotent seeding
    • Progress tracking and logging utilities
  2. Domain-Specific Seed Modules

    • Users - User accounts with various roles (admin, bartender, organizer, user)
    • Products - Inventory items (spirits, mixers, garnishes, tools, glassware)
    • Recipes - Cocktail recipes with ingredients and instructions
    • Events - Events with themes, dates, and guest counts
    • Menus - Event-specific cocktail menus with recipe selections
    • ShoppingLists - Shopping lists based on menu requirements
  3. Mix Task (lib/mix/tasks/bartendie.seed.ex)

    • Command-line interface for seeding operations
    • Selective domain seeding
    • Data reset capabilities
    • Dry-run functionality
  4. Main Orchestrator (priv/repo/seeds.exs)

    • Coordinates all seed modules
    • Environment safety checks
    • Dependency management
    • Progress reporting
  • All data creation uses proper command dispatching
  • Ensures domain consistency and business rule enforcement
  • Provides full audit trail of seed data creation
  • Integrates with existing aggregate and projection infrastructure
  • Deterministic UUID generation based on seed strings
  • Prevents duplicate data on multiple runs
  • Safe to run repeatedly without data corruption
  • Supports incremental seeding scenarios
  • Production environment protection
  • Automatic environment detection
  • Database connectivity validation
  • EventStore connectivity verification
  • Comprehensive product catalog with realistic brands and volumes
  • Classic and modern cocktail recipes with proper ingredients
  • Diverse event scenarios (corporate, wedding, private, seasonal)
  • Theme-appropriate menu selections
  • Realistic user profiles with appropriate roles
  • Selective domain seeding (--only users,products)
  • Data reset functionality (--reset)
  • Dry-run capability (--dry-run)
  • Verbose progress reporting (--verbose)
Terminal window
# Seed all domains
mix bartendie.seed
# Alternative using seeds.exs directly
mix run priv/repo/seeds.exs
Terminal window
# Seed only specific domains
mix bartendie.seed --only users,products,recipes
# Seed with verbose output
mix bartendie.seed --verbose
Terminal window
# Reset existing data and reseed
mix bartendie.seed --reset
# Dry run to preview what would be seeded
mix bartendie.seed --dry-run
Terminal window
# View all available options
mix bartendie.seed --help

The seeding process follows a specific order to maintain referential integrity:

  1. Users - Independent, no dependencies
  2. Products - Independent, no dependencies
  3. Recipes - Depends on Products (for ingredients)
  4. Events - Depends on Users (for organizers)
  5. Menus - Depends on Events and Recipes
  6. Shopping Lists - Depends on Events and Menus
  • Users: 1 admin, 4 bartenders, 4 organizers, 10 regular users
  • Products: ~50 items across spirits, mixers, garnishes, tools, glassware
  • Recipes: ~10 cocktail recipes (classic, modern, seasonal, mocktails)
  • Events: ~10 events across different categories and themes
  • Menus: 1 menu per event with 4-8 recipes each
  • Shopping Lists: 1 shopping list per menu
  • Command validation before dispatching
  • Graceful handling of duplicate data scenarios
  • Detailed error reporting with context
  • Automatic rollback on failure (when reset is enabled)
  • Comprehensive logging for debugging
  • Missing dependencies (handled with warnings)
  • Command validation failures (detailed error messages)
  • Database connectivity issues (early detection)
  • EventStore connectivity problems (validation checks)
  1. Ensure database is running and migrated
  2. Ensure EventStore is running and accessible
  3. Run seed data: mix bartendie.seed
  1. Reset and reseed: mix bartendie.seed --reset
  2. Add specific data: mix bartendie.seed --only products,recipes
  3. Test changes: mix bartendie.seed --dry-run
  • Seed data is compatible with test environment
  • Use --reset flag for clean test data
  • Deterministic data generation for consistent tests
  • SEED_DOMAINS - Comma-separated list of domains to seed
  • RESET_SEED_DATA - Set to “true” to reset data before seeding
  • Modify seed data in individual domain modules
  • Adjust data volumes by changing iteration counts
  • Customize product catalogs, recipe collections, etc.
  • Add new domains by following existing patterns
  • Real-time progress updates during seeding
  • Domain-by-domain completion reporting
  • Final summary with record counts
  • Error and warning aggregation
  • Post-seeding data validation
  • Referential integrity checks
  • Business rule compliance verification
  • Performance impact monitoring
  1. Always run dry-run before actual seeding in shared environments
  2. Use selective seeding during development to save time
  3. Reset data when testing major changes
  4. Monitor logs for warnings and errors
  1. Never run seeding in production (automatic protection in place)
  2. Use reset functionality carefully in staging environments
  3. Validate data integrity after seeding
  4. Monitor performance impact on large datasets
  1. Database Connection Errors: Ensure PostgreSQL is running
  2. EventStore Connection Errors: Ensure EventStore is running
  3. Command Validation Failures: Check domain model constraints
  4. Memory Issues: Use selective seeding for large datasets

Use verbose flag for detailed execution information:

Terminal window
mix bartendie.seed --verbose
  • Configurable data volumes
  • Custom seed data templates
  • Performance optimization for large datasets
  • Integration with backup/restore functionality
  • Seed data versioning and migration support
  • Additional domain modules
  • Custom data generation strategies
  • External data source integration
  • Seed data validation rules
  • Performance monitoring and optimization