Skip to main content

Business Rules and Constraints

This document outlines the key business rules, invariants, and constraints that govern the Bartendie domain model. These rules ensure data integrity and enforce business logic across the system.

Event Aggregate Rules

Event Rules

  • R-E001: An event must have a future date when created
  • R-E002: An event cannot be cancelled if it's already in progress or completed
  • R-E003: Guest count must be a positive integer
  • R-E004: Event name must be unique within a venue for the same date
  • R-E005: An event must be associated with exactly one venue

Guest List Rules

  • R-GL001: A guest can only appear once in an event's guest list
  • R-GL002: Guest preferences can only be set by the guest themselves or the host
  • R-GL003: RSVP status changes must follow valid transitions (invited → confirmed/declined/maybe)
  • R-GL004: Attendance estimate cannot exceed venue capacity

Venue Aggregate Rules

Venue Rules

  • R-V001: Venue name must be unique within the system
  • R-V002: Venue address must be a valid, complete address
  • R-V003: A venue must have at least one bar or storage area to host events

Bar Rules

  • R-B001: Bar name must be unique within a venue
  • R-B002: A bar cannot be deleted if it's referenced by active bar setups
  • R-B003: Bar features must be from a predefined list of valid capabilities
  • R-B004: Each bar must belong to exactly one venue

Storage Rules

  • R-S001: Storage name must be unique within a venue
  • R-S002: Storage type must be from predefined categories (dry, cold, freezer, etc.)
  • R-M001: A menu must contain at least one drink item
  • R-M002: Menu cannot be finalized without checking ingredient availability
  • R-M003: Featured drinks cannot exceed 20% of total menu items
  • R-M004: Menu must have balanced flavor profile (no single flavor > 60% dominance)

Drink Item Rules

  • R-DI001: Each drink item must reference a valid recipe
  • R-DI002: Drink item names must be unique within a menu
  • R-DI003: Featured drinks must have complete descriptions and images

Recipe Aggregate Rules

Recipe Rules

  • R-R001: Recipe name must be unique within the system
  • R-R002: Recipe must have at least one ingredient
  • R-R003: Recipe instructions cannot be empty
  • R-R004: Total ingredient alcohol content cannot exceed 95%
  • R-R005: Recipe rating must be between 1.0 and 5.0

Recipe Ingredient Rules

  • R-RI001: Ingredient quantities must be positive numbers
  • R-RI002: Measurement units must be compatible with ingredient type
  • R-RI003: Optional ingredients cannot be the primary spirit
  • R-RI004: Substitution options must be of the same ingredient type

Recipe Balance Rules

  • R-RB001: Sweetness, sourness, bitterness levels must be 1-10
  • R-RB002: Recipe is considered balanced if no single flavor exceeds level 8
  • R-RB003: Cocktails with high alcohol content (>30%) must have balancing modifiers

Inventory Aggregate Rules

Inventory Rules

  • R-I001: Product quantities cannot be negative
  • R-I002: Low stock alerts trigger when quantity < 20% of normal stock level
  • R-I003: Expired products cannot be used in recipes
  • R-I004: Barcode must be unique across all products

Product Rules

  • R-P001: Product name and brand combination must be unique
  • R-P002: Alcohol content must be between 0% and 95%
  • R-P003: Product volume must be positive
  • R-P004: Price must be non-negative

Shopping List Rules

  • R-SL001: Shopping list quantities are calculated based on menu requirements + 10% buffer
  • R-SL002: Shopping list cannot be finalized without reviewing all items
  • R-SL003: Purchased items must update inventory levels automatically

Bar Setup Aggregate Rules

Bar Setup Rules

  • R-BS001: Bar setup must reference a valid bar within the event's venue
  • R-BS002: Required tools must be available in inventory
  • R-BS003: Setup cannot be finalized without verifying tool availability
  • R-BS004: Bar setup layout must accommodate all required equipment

Equipment Rules

  • R-E001: Essential tools cannot be marked as unavailable during events
  • R-E002: Equipment quantities must be sufficient for expected guest count
  • R-E003: Tool categories must be from predefined list

User Management Rules

User Rules

  • R-U001: Username must be unique across the system
  • R-U002: Email must be unique and valid format
  • R-U003: Password must meet complexity requirements (8+ chars, mixed case, numbers)
  • R-U004: Users must have at least one active role
  • R-U005: User accounts are soft-deleted (deactivated) rather than hard-deleted

Role and Permission Rules

  • R-RP001: Role names must be unique
  • R-RP002: Permissions follow resource.action format (e.g., "recipe.create")
  • R-RP003: Admin role cannot be deleted or have permissions removed
  • R-RP004: Users cannot modify their own role assignments

Cross-Aggregate Rules

Event-Menu Rules

  • R-EM001: Menu ingredients must be available in venue's inventory
  • R-EM002: Menu complexity must match bartender skill level
  • R-EM003: Menu must be appropriate for event theme and guest preferences

Recipe-Inventory Rules

  • R-RI001: Recipe ingredients must map to available products
  • R-RI002: Ingredient substitutions must maintain recipe balance
  • R-RI003: Batch recipes must account for ingredient availability

User-Event Rules

  • R-UE001: Only event hosts can modify event details
  • R-UE002: Bartenders can only access events they're assigned to
  • R-UE003: Guests can only view events they're invited to

Validation Rules

Data Format Rules

  • R-DF001: UUIDs must be valid RFC 4122 format
  • R-DF002: Dates must be in ISO 8601 format
  • R-DF003: Email addresses must follow RFC 5322 standard
  • R-DF004: Phone numbers must include country code

Business Logic Validation

  • R-BL001: All monetary amounts must be in smallest currency unit (cents)
  • R-BL002: Percentages must be between 0 and 100
  • R-BL003: Quantities must use standard measurement units
  • R-BL004: Time durations must be positive values

Error Handling Rules

System Behavior Rules

  • R-SB001: Invalid operations must return specific error codes
  • R-SB002: Data corruption must trigger automatic rollback
  • R-SB003: External system failures must not break core functionality
  • R-SB004: Audit logs must be created for all rule violations

Recovery Rules

  • R-REC001: System must gracefully handle partial failures
  • R-REC002: Data inconsistencies must be flagged for manual review
  • R-REC003: Failed operations must be retryable where appropriate
  • R-REC004: Critical errors must trigger immediate notifications

Compliance and Audit Rules

Audit Requirements

  • R-A001: All data modifications must be logged
  • R-A002: User actions must be traceable to specific individuals
  • R-A003: Audit logs must be immutable once created
  • R-A004: Sensitive data access must be logged and monitored

Data Retention Rules

  • R-DR001: Event data must be retained for 7 years
  • R-DR002: User data must be purged upon account deletion request
  • R-DR003: Audit logs must be retained for 10 years
  • R-DR004: Recipe data is retained indefinitely unless explicitly deleted

These business rules serve as the foundation for implementing domain logic and ensuring the system maintains data integrity while supporting the complex workflows of home bartending and event planning.