{
  "$schema": "mantara.schema.v1",
  "system_name": "Tourism Management System",
  "schema_name": "ai_sch_20260513_034832",
  "description": "A comprehensive platform for managing tourism operations including tour packages, bookings, customer management, and service provider coordination.",
  "menus": [
    {
      "menu_id": 1,
      "menu_name": "User Management",
      "sequence_number": 1,
      "description": "Manage all user accounts, roles, and permissions.",
      "submenus": [
        {
          "submenu_id": 101,
          "submenu_name": "User Accounts",
          "sequence_number": 1,
          "description": "Manage user accounts and authentication details.",
          "tables": [
            {
              "table_name": "users",
              "comment": "Stores user authentication credentials and role assignments.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 101 NOT NULL REFERENCES tms.submenu(submenu_id)"
                },
                {
                  "name": "email",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL UNIQUE"
                },
                {
                  "name": "password_hash",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "Stores bcrypt hash, never plain text"
                },
                {
                  "name": "role",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL CHECK (role IN ('super_admin','tour_manager','booking_agent','tour_guide','service_provider','customer','finance_manager'))"
                },
                {
                  "name": "first_name",
                  "type": "VARCHAR(100)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "last_name",
                  "type": "VARCHAR(100)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "phone",
                  "type": "VARCHAR(20)"
                },
                {
                  "name": "is_active",
                  "type": "BOOLEAN",
                  "constraints": "NOT NULL DEFAULT true"
                },
                {
                  "name": "last_login_at",
                  "type": "TIMESTAMP"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 102,
          "submenu_name": "Customer Profiles",
          "sequence_number": 2,
          "description": "Manage customer profiles and loyalty information.",
          "tables": [
            {
              "table_name": "customers",
              "comment": "Stores extended customer profiles including contact details and loyalty status.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 102 NOT NULL REFERENCES tms.submenu(submenu_id)"
                },
                {
                  "name": "user_id",
                  "type": "UUID",
                  "constraints": "NOT NULL UNIQUE REFERENCES tms.users(id) ON DELETE CASCADE"
                },
                {
                  "name": "date_of_birth",
                  "type": "DATE"
                },
                {
                  "name": "nationality",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "passport_number",
                  "type": "VARCHAR(50)"
                },
                {
                  "name": "passport_expiry",
                  "type": "DATE"
                },
                {
                  "name": "emergency_contact_name",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "emergency_contact_phone",
                  "type": "VARCHAR(20)"
                },
                {
                  "name": "address_line1",
                  "type": "VARCHAR(255)"
                },
                {
                  "name": "address_line2",
                  "type": "VARCHAR(255)"
                },
                {
                  "name": "city",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "state",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "country",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "postal_code",
                  "type": "VARCHAR(20)"
                },
                {
                  "name": "loyalty_status",
                  "type": "VARCHAR(50)",
                  "constraints": "CHECK (loyalty_status IN ('bronze','silver','gold','platinum'))"
                },
                {
                  "name": "loyalty_points",
                  "type": "INTEGER",
                  "constraints": "NOT NULL DEFAULT 0"
                },
                {
                  "name": "preferences",
                  "type": "TEXT"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "menu_id": 2,
      "menu_name": "Tour Management",
      "sequence_number": 2,
      "description": "Manage tour packages, itineraries, and schedules.",
      "submenus": [
        {
          "submenu_id": 201,
          "submenu_name": "Tour Packages",
          "sequence_number": 1,
          "description": "Create and manage tour packages including pricing and availability.",
          "tables": [
            {
              "table_name": "tour_packages",
              "comment": "Stores information about tour packages including pricing, duration, and features.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 201 NOT NULL REFERENCES tms.submenu(submenu_id)"
                },
                {
                  "name": "category_id",
                  "type": "UUID",
                  "constraints": "NOT NULL REFERENCES tms.categories(id) ON DELETE RESTRICT"
                },
                {
                  "name": "name",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "slug",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL UNIQUE"
                },
                {
                  "name": "description",
                  "type": "TEXT"
                },
                {
                  "name": "duration_days",
                  "type": "INTEGER",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "duration_nights",
                  "type": "INTEGER",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "difficulty_level",
                  "type": "VARCHAR(50)",
                  "constraints": "CHECK (difficulty_level IN ('easy','moderate','challenging','difficult'))"
                },
                {
                  "name": "min_age",
                  "type": "INTEGER"
                },
                {
                  "name": "max_age",
                  "type": "INTEGER"
                },
                {
                  "name": "min_group_size",
                  "type": "INTEGER",
                  "constraints": "NOT NULL DEFAULT 1"
                },
                {
                  "name": "max_group_size",
                  "type": "INTEGER",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "base_price",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "child_price",
                  "type": "DECIMAL(10,2)"
                },
                {
                  "name": "single_supplement",
                  "type": "DECIMAL(10,2)"
                },
                {
                  "name": "inclusions",
                  "type": "TEXT"
                },
                {
                  "name": "exclusions",
                  "type": "TEXT"
                },
                {
                  "name": "terms_and_conditions",
                  "type": "TEXT"
                },
                {
                  "name": "cancellation_policy",
                  "type": "TEXT"
                },
                {
                  "name": "is_active",
                  "type": "BOOLEAN",
                  "constraints": "NOT NULL DEFAULT true"
                },
                {
                  "name": "is_featured",
                  "type": "BOOLEAN",
                  "constraints": "NOT NULL DEFAULT false"
                },
                {
                  "name": "rating",
                  "type": "DECIMAL(3,2)"
                },
                {
                  "name": "total_reviews",
                  "type": "INTEGER",
                  "constraints": "NOT NULL DEFAULT 0"
                },
                {
                  "name": "image_url",
                  "type": "VARCHAR(500)"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 202,
          "submenu_name": "Itineraries",
          "sequence_number": 2,
          "description": "Define day-by-day itineraries for tour packages.",
          "tables": [
            {
              "table_name": "itineraries",
              "comment": "Stores daily itineraries for tour packages including activities and meals.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 202 NOT NULL REFERENCES tms.submenu(submenu_id)"
                },
                {
                  "name": "tour_package_id",
                  "type": "UUID",
                  "constraints": "NOT NULL REFERENCES tms.tour_packages(id) ON DELETE CASCADE"
                },
                {
                  "name": "day_number",
                  "type": "INTEGER",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "title",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "description",
                  "type": "TEXT"
                },
                {
                  "name": "activities",
                  "type": "TEXT"
                },
                {
                  "name": "meals_included",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "accommodation_type",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "start_time",
                  "type": "TIME"
                },
                {
                  "name": "end_time",
                  "type": "TIME"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 203,
          "submenu_name": "Tour Schedules",
          "sequence_number": 3,
          "description": "Manage specific instances of tour packages with assigned resources.",
          "tables": [
            {
              "table_name": "tour_schedules",
              "comment": "Stores scheduled instances of tour packages including assigned resources and status.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 203 NOT NULL REFERENCES tms.submenu(submenu_id)"
                },
                {
                  "name": "tour_package_id",
                  "type": "UUID",
                  "constraints": "NOT NULL REFERENCES tms.tour_packages(id) ON DELETE CASCADE"
                },
                {
                  "name": "tour_guide_id",
                  "type": "UUID",
                  "constraints": "REFERENCES tms.tour_guides(id) ON DELETE SET NULL"
                },
                {
                  "name": "departure_date",
                  "type": "DATE",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "return_date",
                  "type": "DATE",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "available_slots",
                  "type": "INTEGER",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "booked_slots",
                  "type": "INTEGER",
                  "constraints": "NOT NULL DEFAULT 0"
                },
                {
                  "name": "status",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL CHECK (status IN ('scheduled','confirmed','in_progress','completed','cancelled')) DEFAULT 'scheduled'"
                },
                {
                  "name": "meeting_point",
                  "type": "VARCHAR(255)"
                },
                {
                  "name": "meeting_time",
                  "type": "TIME"
                },
                {
                  "name": "special_instructions",
                  "type": "TEXT"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "menu_id": 3,
      "menu_name": "Booking Management",
      "sequence_number": 3,
      "description": "Handle customer bookings, payments, and cancellations.",
      "submenus": [
        {
          "submenu_id": 301,
          "submenu_name": "Bookings",
          "sequence_number": 1,
          "description": "Manage customer bookings for tours including traveler details and status.",
          "tables": [
            {
              "table_name": "bookings",
              "comment": "Stores customer bookings for tour schedules including payment and status details.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 301 NOT NULL REFERENCES tms.submenu(submenu_id)"
                },
                {
                  "name": "booking_number",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL UNIQUE"
                },
                {
                  "name": "customer_id",
                  "type": "UUID",
                  "constraints": "NOT NULL REFERENCES tms.customers(id) ON DELETE RESTRICT"
                },
                {
                  "name": "tour_schedule_id",
                  "type": "UUID",
                  "constraints": "NOT NULL REFERENCES tms.tour_schedules(id) ON DELETE RESTRICT"
                },
                {
                  "name": "booking_agent_id",
                  "type": "UUID",
                  "constraints": "REFERENCES tms.users(id) ON DELETE SET NULL"
                },
                {
                  "name": "discount_id",
                  "type": "UUID",
                  "constraints": "REFERENCES tms.discounts(id) ON DELETE SET NULL"
                },
                {
                  "name": "booking_date",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "number_of_adults",
                  "type": "INTEGER",
                  "constraints": "NOT NULL DEFAULT 1"
                },
                {
                  "name": "number_of_children",
                  "type": "INTEGER",
                  "constraints": "NOT NULL DEFAULT 0"
                },
                {
                  "name": "number_of_infants",
                  "type": "INTEGER",
                  "constraints": "NOT NULL DEFAULT 0"
                },
                {
                  "name": "subtotal",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "discount_amount",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL DEFAULT 0"
                },
                {
                  "name": "tax_amount",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL DEFAULT 0"
                },
                {
                  "name": "total_amount",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "amount_paid",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL DEFAULT 0"
                },
                {
                  "name": "amount_due",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "booking_status",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL CHECK (booking_status IN ('pending','confirmed','cancelled','completed','refunded')) DEFAULT 'pending'"
                },
                {
                  "name": "payment_status",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL CHECK (payment_status IN ('unpaid','partial','paid','refunded')) DEFAULT 'unpaid'"
                },
                {
                  "name": "special_requests",
                  "type": "TEXT"
                },
                {
                  "name": "cancellation_reason",
                  "type": "TEXT"
                },
                {
                  "name": "cancelled_at",
                  "type": "TIMESTAMP"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 302,
          "submenu_name": "Payments",
          "sequence_number": 2,
          "description": "Track and process payments for bookings.",
          "tables": [
            {
              "table_name": "payments",
              "comment": "Records payment transactions for bookings including method and status.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 302 NOT NULL REFERENCES tms.submenu(submenu_id)"
                },
                {
                  "name": "booking_id",
                  "type": "UUID",
                  "constraints": "NOT NULL REFERENCES tms.bookings(id) ON DELETE CASCADE"
                },
                {
                  "name": "payment_method",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL CHECK (payment_method IN ('credit_card','debit_card','bank_transfer','cash','paypal','stripe','other'))"
                },
                {
                  "name": "transaction_id",
                  "type": "VARCHAR(255)"
                },
                {
                  "name": "amount",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "currency",
                  "type": "VARCHAR(3)",
                  "constraints": "NOT NULL DEFAULT 'USD'"
                },
                {
                  "name": "payment_status",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL CHECK (payment_status IN ('pending','processing','completed','failed','refunded')) DEFAULT 'pending'"
                },
                {
                  "name": "payment_date",
                  "type": "TIMESTAMP"
                },
                {
                  "name": "payment_gateway",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "gateway_response",
                  "type": "TEXT"
                },
                {
                  "name": "notes",
                  "type": "TEXT"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 303,
          "submenu_name": "Cancellations",
          "sequence_number": 3,
          "description": "Manage cancellation requests and refunds.",
          "tables": [
            {
              "table_name": "cancellation_requests",
              "comment": "Stores customer-initiated cancellation requests for bookings.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 303 NOT NULL REFERENCES tms.submenu(submenu_id)"
                },
                {
                  "name": "booking_id",
                  "type": "UUID",
                  "constraints": "NOT NULL REFERENCES tms.bookings(id) ON DELETE CASCADE"
                },
                {
                  "name": "customer_id",
                  "type": "UUID",
                  "constraints": "NOT NULL REFERENCES tms.customers(id) ON DELETE CASCADE"
                },
                {
                  "name": "reason",
                  "type": "TEXT",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "requested_date",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "cancellation_fee",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL DEFAULT 0"
                },
                {
                  "name": "refund_amount",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL DEFAULT 0"
                },
                {
                  "name": "status",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL CHECK (status IN ('pending','approved','rejected','processed')) DEFAULT 'pending'"
                },
                {
                  "name": "processed_by",
                  "type": "UUID",
                  "constraints": "REFERENCES tms.users(id) ON DELETE SET NULL"
                },
                {
                  "name": "processed_date",
                  "type": "TIMESTAMP"
                },
                {
                  "name": "admin_notes",
                  "type": "TEXT"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "menu_id": 4,
      "menu_name": "Service Provider Management",
      "sequence_number": 4,
      "description": "Manage service providers including hotels and transportation.",
      "submenus": [
        {
          "submenu_id": 401,
          "submenu_name": "Service Providers",
          "sequence_number": 1,
          "description": "Manage profiles and contracts of service providers.",
          "tables": [
            {
              "table_name": "service_providers",
              "comment": "Stores information about service providers including contact details and contract terms.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 401 NOT NULL REFERENCES tms.submenu(submenu_id)"
                },
                {
                  "name": "user_id",
                  "type": "UUID",
                  "constraints": "NOT NULL UNIQUE REFERENCES tms.users(id) ON DELETE CASCADE"
                },
                {
                  "name": "company_name",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "service_type",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL CHECK (service_type IN ('hotel','transportation','restaurant','activity','insurance','other'))"
                },
                {
                  "name": "registration_number",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "tax_id",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "contact_person",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "contact_email",
                  "type": "VARCHAR(255)"
                },
                {
                  "name": "contact_phone",
                  "type": "VARCHAR(20)"
                },
                {
                  "name": "address_line1",
                  "type": "VARCHAR(255)"
                },
                {
                  "name": "address_line2",
                  "type": "VARCHAR(255)"
                },
                {
                  "name": "city",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "state",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "country",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "postal_code",
                  "type": "VARCHAR(20)"
                },
                {
                  "name": "contract_start_date",
                  "type": "DATE"
                },
                {
                  "name": "contract_end_date",
                  "type": "DATE"
                },
                {
                  "name": "payment_terms",
                  "type": "TEXT"
                },
                {
                  "name": "rating",
                  "type": "DECIMAL(3,2)"
                },
                {
                  "name": "is_verified",
                  "type": "BOOLEAN",
                  "constraints": "NOT NULL DEFAULT false"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 402,
          "submenu_name": "Hotels",
          "sequence_number": 2,
          "description": "Manage hotel details and room types.",
          "tables": [
            {
              "table_name": "hotels",
              "comment": "Stores information about hotels including location, amenities, and policies.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 402 NOT NULL REFERENCES tms.submenu(submenu_id)"
                },
                {
                  "name": "service_provider_id",
                  "type": "UUID",
                  "constraints": "NOT NULL REFERENCES tms.service_providers(id) ON DELETE CASCADE"
                },
                {
                  "name": "name",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "star_rating",
                  "type": "INTEGER",
                  "constraints": "CHECK (star_rating >= 1 AND star_rating <= 5)"
                },
                {
                  "name": "address_line1",
                  "type": "VARCHAR(255)"
                },
                {
                  "name": "address_line2",
                  "type": "VARCHAR(255)"
                },
                {
                  "name": "city",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "state",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "country",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "postal_code",
                  "type": "VARCHAR(20)"
                },
                {
                  "name": "latitude",
                  "type": "DECIMAL(10,8)"
                },
                {
                  "name": "longitude",
                  "type": "DECIMAL(11,8)"
                },
                {
                  "name": "phone",
                  "type": "VARCHAR(20)"
                },
                {
                  "name": "email",
                  "type": "VARCHAR(255)"
                },
                {
                  "name": "website",
                  "type": "VARCHAR(500)"
                },
                {
                  "name": "check_in_time",
                  "type": "TIME"
                },
                {
                  "name": "check_out_time",
                  "type": "TIME"
                },
                {
                  "name": "description",
                  "type": "TEXT"
                },
                {
                  "name": "policies",
                  "type": "TEXT"
                },
                {
                  "name": "is_active",
                  "type": "BOOLEAN",
                  "constraints": "NOT NULL DEFAULT true"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 403,
          "submenu_name": "Transportation",
          "sequence_number": 3,
          "description": "Manage transportation services and vehicles.",
          "tables": [
            {
              "table_name": "transportations",
              "comment": "Stores information about transportation services including vehicle details and capacity.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 403 NOT NULL REFERENCES tms.submenu(submenu_id)"
                },
                {
                  "name": "service_provider_id",
                  "type": "UUID",
                  "constraints": "NOT NULL REFERENCES tms.service_providers(id) ON DELETE CASCADE"
                },
                {
                  "name": "transport_type",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL CHECK (transport_type IN ('bus','flight','train','car','boat','other'))"
                },
                {
                  "name": "vehicle_name",
                  "type": "VARCHAR(255)"
                },
                {
                  "name": "vehicle_number",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "capacity",
                  "type": "INTEGER",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "amenities",
                  "type": "TEXT"
                },
                {
                  "name": "is_active",
                  "type": "BOOLEAN",
                  "constraints": "NOT NULL DEFAULT true"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "menu_id": 5,
      "menu_name": "Financial Management",
      "sequence_number": 5,
      "description": "Manage financial transactions, invoices, and commissions.",
      "submenus": [
        {
          "submenu_id": 501,
          "submenu_name": "Invoices",
          "sequence_number": 1,
          "description": "Generate and manage invoices for bookings.",
          "tables": [
            {
              "table_name": "invoices",
              "comment": "Stores invoices for bookings including line items and payment terms.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 501 NOT NULL REFERENCES tms.submenu(submenu_id)"
                },
                {
                  "name": "booking_id",
                  "type": "UUID",
                  "constraints": "NOT NULL REFERENCES tms.bookings(id) ON DELETE CASCADE"
                },
                {
                  "name": "invoice_number",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL UNIQUE"
                },
                {
                  "name": "invoice_date",
                  "type": "DATE",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "due_date",
                  "type": "DATE"
                },
                {
                  "name": "subtotal",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "tax_amount",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL DEFAULT 0"
                },
                {
                  "name": "discount_amount",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL DEFAULT 0"
                },
                {
                  "name": "total_amount",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "notes",
                  "type": "TEXT"
                },
                {
                  "name": "terms",
                  "type": "TEXT"
                },
                {
                  "name": "invoice_status",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL CHECK (invoice_status IN ('draft','sent','paid','overdue','cancelled')) DEFAULT 'draft'"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 502,
          "submenu_name": "Commissions",
          "sequence_number": 2,
          "description": "Calculate and manage commissions for booking agents.",
          "tables": [
            {
              "table_name": "commissions",
              "comment": "Stores commission records for booking agents based on bookings.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 502 NOT NULL REFERENCES tms.submenu(submenu_id)"
                },
                {
                  "name": "booking_id",
                  "type": "UUID",
                  "constraints": "NOT NULL REFERENCES tms.bookings(id) ON DELETE CASCADE"
                },
                {
                  "name": "booking_agent_id",
                  "type": "UUID",
                  "constraints": "NOT NULL REFERENCES tms.users(id) ON DELETE CASCADE"
                },
                {
                  "name": "booking_amount",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "commission_rate",
                  "type": "DECIMAL(5,2)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "commission_amount",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "status",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL CHECK (status IN ('pending','approved','paid')) DEFAULT 'pending'"
                },
                {
                  "name": "payment_date",
                  "type": "DATE"
                },
                {
                  "name": "notes",
                  "type": "TEXT"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "menu_id": 6,
      "menu_name": "Content Management",
      "sequence_number": 6,
      "description": "Manage content related to destinations, reviews, and promotions.",
      "submenus": [
        {
          "submenu_id": 601,
          "submenu_name": "Destinations",
          "sequence_number": 1,
          "description": "Manage geographic locations featured in tours.",
          "tables": [
            {
              "table_name": "destinations",
              "comment": "Stores information about destinations including attractions and climate.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 601 NOT NULL REFERENCES tms.submenu(submenu_id)"
                },
                {
                  "name": "name",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "slug",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL UNIQUE"
                },
                {
                  "name": "country",
                  "type": "VARCHAR(100)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "state",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "city",
                  "type": "VARCHAR(100)"
                },
                {
                  "name": "description",
                  "type": "TEXT"
                },
                {
                  "name": "attractions",
                  "type": "TEXT"
                },
                {
                  "name": "best_time_to_visit",
                  "type": "VARCHAR(255)"
                },
                {
                  "name": "climate_info",
                  "type": "TEXT"
                },
                {
                  "name": "latitude",
                  "type": "DECIMAL(10,8)"
                },
                {
                  "name": "longitude",
                  "type": "DECIMAL(11,8)"
                },
                {
                  "name": "image_url",
                  "type": "VARCHAR(500)"
                },
                {
                  "name": "is_active",
                  "type": "BOOLEAN",
                  "constraints": "NOT NULL DEFAULT true"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 602,
          "submenu_name": "Reviews",
          "sequence_number": 2,
          "description": "Manage customer reviews and ratings for tours.",
          "tables": [
            {
              "table_name": "reviews",
              "comment": "Stores customer reviews for tour packages including ratings and comments.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 602 NOT NULL REFERENCES tms.submenu(submenu_id)"
                },
                {
                  "name": "booking_id",
                  "type": "UUID",
                  "constraints": "NOT NULL REFERENCES tms.bookings(id) ON DELETE CASCADE"
                },
                {
                  "name": "customer_id",
                  "type": "UUID",
                  "constraints": "NOT NULL REFERENCES tms.customers(id) ON DELETE CASCADE"
                },
                {
                  "name": "tour_package_id",
                  "type": "UUID",
                  "constraints": "NOT NULL REFERENCES tms.tour_packages(id) ON DELETE CASCADE"
                },
                {
                  "name": "tour_guide_id",
                  "type": "UUID",
                  "constraints": "REFERENCES tms.tour_guides(id) ON DELETE SET NULL"
                },
                {
                  "name": "overall_rating",
                  "type": "INTEGER",
                  "constraints": "NOT NULL CHECK (overall_rating >= 1 AND overall_rating <= 5)"
                },
                {
                  "name": "guide_rating",
                  "type": "INTEGER",
                  "constraints": "CHECK (guide_rating >= 1 AND guide_rating <= 5)"
                },
                {
                  "name": "accommodation_rating",
                  "type": "INTEGER",
                  "constraints": "CHECK (accommodation_rating >= 1 AND accommodation_rating <= 5)"
                },
                {
                  "name": "transportation_rating",
                  "type": "INTEGER",
                  "constraints": "CHECK (transportation_rating >= 1 AND transportation_rating <= 5)"
                },
                {
                  "name": "value_for_money_rating",
                  "type": "INTEGER",
                  "constraints": "CHECK (value_for_money_rating >= 1 AND value_for_money_rating <= 5)"
                },
                {
                  "name": "title",
                  "type": "VARCHAR(255)"
                },
                {
                  "name": "comment",
                  "type": "TEXT"
                },
                {
                  "name": "photos",
                  "type": "TEXT[]"
                },
                {
                  "name": "is_verified",
                  "type": "BOOLEAN",
                  "constraints": "NOT NULL DEFAULT false"
                },
                {
                  "name": "is_published",
                  "type": "BOOLEAN",
                  "constraints": "NOT NULL DEFAULT false"
                },
                {
                  "name": "management_response",
                  "type": "TEXT"
                },
                {
                  "name": "response_date",
                  "type": "TIMESTAMP"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 603,
          "submenu_name": "Promotions",
          "sequence_number": 3,
          "description": "Manage discounts and promotional offers for tour packages.",
          "tables": [
            {
              "table_name": "discounts",
              "comment": "Stores discount codes and promotional offers applicable to tour packages.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 603 NOT NULL REFERENCES tms.submenu(submenu_id)"
                },
                {
                  "name": "code",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL UNIQUE"
                },
                {
                  "name": "name",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "description",
                  "type": "TEXT"
                },
                {
                  "name": "discount_type",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL CHECK (discount_type IN ('percentage','fixed_amount','early_bird','group','loyalty'))"
                },
                {
                  "name": "discount_value",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "min_booking_amount",
                  "type": "DECIMAL(10,2)"
                },
                {
                  "name": "max_discount_amount",
                  "type": "DECIMAL(10,2)"
                },
                {
                  "name": "min_travelers",
                  "type": "INTEGER"
                },
                {
                  "name": "applicable_tour_package_id",
                  "type": "UUID",
                  "constraints": "REFERENCES tms.tour_packages(id) ON DELETE CASCADE"
                },
                {
                  "name": "valid_from",
                  "type": "DATE",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "valid_to",
                  "type": "DATE",
                  "constraints": "NOT NULL"
                },
                {
                  "name": "usage_limit",
                  "type": "INTEGER"
                },
                {
                  "name": "usage_count",
                  "type": "INTEGER",
                  "constraints": "NOT NULL DEFAULT 0"
                },
                {
                  "name": "is_active",
                  "type": "BOOLEAN",
                  "constraints": "NOT NULL DEFAULT true"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "assumptions": [
    "Each tour package can have multiple itineraries and schedules.",
    "Bookings can be associated with multiple payments and a single invoice.",
    "Service providers can manage multiple hotels and transportation services."
  ],
  "open_questions": [
    "Should the system support multi-currency transactions beyond USD?",
    "Is there a need for a separate module for handling tour guide certifications and renewals?"
  ]
}
