Bartendie Seed Data Infrastructure
Bartendie Seed Data Infrastructure
Section titled “Bartendie Seed Data Infrastructure”Overview
Section titled “Overview”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.
Architecture
Section titled “Architecture”Core Components
Section titled “Core Components”-
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
-
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 instructionsEvents- Events with themes, dates, and guest countsMenus- Event-specific cocktail menus with recipe selectionsShoppingLists- Shopping lists based on menu requirements
-
Mix Task (
lib/mix/tasks/bartendie.seed.ex)- Command-line interface for seeding operations
- Selective domain seeding
- Data reset capabilities
- Dry-run functionality
-
Main Orchestrator (
priv/repo/seeds.exs)- Coordinates all seed modules
- Environment safety checks
- Dependency management
- Progress reporting
Features
Section titled “Features”Event Sourcing Integration
Section titled “Event Sourcing Integration”- 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
Idempotent Seeding
Section titled “Idempotent Seeding”- Deterministic UUID generation based on seed strings
- Prevents duplicate data on multiple runs
- Safe to run repeatedly without data corruption
- Supports incremental seeding scenarios
Environment Safety
Section titled “Environment Safety”- Production environment protection
- Automatic environment detection
- Database connectivity validation
- EventStore connectivity verification
Realistic Data Generation
Section titled “Realistic Data Generation”- 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
Flexible Execution Options
Section titled “Flexible Execution Options”- Selective domain seeding (
--only users,products) - Data reset functionality (
--reset) - Dry-run capability (
--dry-run) - Verbose progress reporting (
--verbose)
Basic Seeding
Section titled “Basic Seeding”# Seed all domainsmix bartendie.seed
# Alternative using seeds.exs directlymix run priv/repo/seeds.exsSelective Seeding
Section titled “Selective Seeding”# Seed only specific domainsmix bartendie.seed --only users,products,recipes
# Seed with verbose outputmix bartendie.seed --verboseData Management
Section titled “Data Management”# Reset existing data and reseedmix bartendie.seed --reset
# Dry run to preview what would be seededmix bartendie.seed --dry-runHelp and Documentation
Section titled “Help and Documentation”# View all available optionsmix bartendie.seed --helpDomain Dependencies
Section titled “Domain Dependencies”The seeding process follows a specific order to maintain referential integrity:
- Users - Independent, no dependencies
- Products - Independent, no dependencies
- Recipes - Depends on Products (for ingredients)
- Events - Depends on Users (for organizers)
- Menus - Depends on Events and Recipes
- Shopping Lists - Depends on Events and Menus
Data Volumes
Section titled “Data Volumes”Default Seed Data Includes:
Section titled “Default Seed Data Includes:”- 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
Error Handling
Section titled “Error Handling”Robust Error Management
Section titled “Robust Error Management”- 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
Common Error Scenarios
Section titled “Common Error Scenarios”- Missing dependencies (handled with warnings)
- Command validation failures (detailed error messages)
- Database connectivity issues (early detection)
- EventStore connectivity problems (validation checks)
Development Workflow
Section titled “Development Workflow”Initial Setup
Section titled “Initial Setup”- Ensure database is running and migrated
- Ensure EventStore is running and accessible
- Run seed data:
mix bartendie.seed
Development Iterations
Section titled “Development Iterations”- Reset and reseed:
mix bartendie.seed --reset - Add specific data:
mix bartendie.seed --only products,recipes - Test changes:
mix bartendie.seed --dry-run
Testing Integration
Section titled “Testing Integration”- Seed data is compatible with test environment
- Use
--resetflag for clean test data - Deterministic data generation for consistent tests
Configuration
Section titled “Configuration”Environment Variables
Section titled “Environment Variables”SEED_DOMAINS- Comma-separated list of domains to seedRESET_SEED_DATA- Set to “true” to reset data before seeding
Customization Points
Section titled “Customization Points”- 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
Monitoring and Reporting
Section titled “Monitoring and Reporting”Progress Tracking
Section titled “Progress Tracking”- Real-time progress updates during seeding
- Domain-by-domain completion reporting
- Final summary with record counts
- Error and warning aggregation
Validation
Section titled “Validation”- Post-seeding data validation
- Referential integrity checks
- Business rule compliance verification
- Performance impact monitoring
Best Practices
Section titled “Best Practices”For Developers
Section titled “For Developers”- Always run dry-run before actual seeding in shared environments
- Use selective seeding during development to save time
- Reset data when testing major changes
- Monitor logs for warnings and errors
For Production-like Environments
Section titled “For Production-like Environments”- Never run seeding in production (automatic protection in place)
- Use reset functionality carefully in staging environments
- Validate data integrity after seeding
- Monitor performance impact on large datasets
Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”- Database Connection Errors: Ensure PostgreSQL is running
- EventStore Connection Errors: Ensure EventStore is running
- Command Validation Failures: Check domain model constraints
- Memory Issues: Use selective seeding for large datasets
Debug Mode
Section titled “Debug Mode”Use verbose flag for detailed execution information:
mix bartendie.seed --verboseFuture Enhancements
Section titled “Future Enhancements”Planned Features
Section titled “Planned Features”- Configurable data volumes
- Custom seed data templates
- Performance optimization for large datasets
- Integration with backup/restore functionality
- Seed data versioning and migration support
Extension Points
Section titled “Extension Points”- Additional domain modules
- Custom data generation strategies
- External data source integration
- Seed data validation rules
- Performance monitoring and optimization