@startuml
skinparam linetype ortho

'===============================================================================
'=====================================Kafka=====================================
'===============================================================================
package Site_kafka <<Cloud>> {
    abstract promotions_kafka {
        +Topics site.products.promotions
        --
        *product_guid
        *locality_guid
        *promotions array[string]
    }
    abstract rnames_kafka {
        + topics site.products.rname
        --
        *url
        *guid
    }
    abstract sale_kafka {
        + site.products.sale
        --
        *nomenclature_guid
        *main_region_guid
        *price
        *clearance_sale_guid
        *quantity_left
        *status
    }
    abstract tagpage_delete_kafka {
        + topics site.tagpage.delete
        --
        *id
    }
    abstract tagpage_status_kafka {
        + topics site.tagpage.status
        --
        *id
        *name
        *is_active
        *is_enable
    }

    abstract makes_visibility_kafka {
        + topics site.make.visibility
        --
        *visibility
        *makeGuid
        *localities
    }
    abstract categories_visibility_kafka {
        + topics site.categories.visibility
        --
        *visibility
        *values map[string]
        *items array[string]
    }
    abstract up_caption_kafka {
        + topics site.categories.up_caption
        --
        *guid
                *up_caption
    }
    abstract relevancy_kafka {
        + topics site.products.relevancy
        --
        *guid
        *orders
        *views
        *rating
        *reviews
        *data [array] - массив данных
        *[array].category
        *[array].manufacturer
        *[array].seo_position
        *[array].koef_sort
    }
}

    package "MySql" <<database>> {
        entity "search_products" as products {
            *id: int auto_increment "PK"
            --
            *is_consumable: tinyint(1)
            *is_on_site: tinyint(1)
            *is_visible: tinyint(1)
            *status: smallint
            *is_discountinued: tinyint(1)
            *is_for_order: tinyint(1)
            *sku: int
            *height: float
            *lenght: float
            *width: float
            *guid: char(36)
            *manufacter_guid: char(36)
            *name_site: varchar(256)
            *category: char(36)
            *name_pdm: varchar(256)
            *name_wtis: varchar(256)
            *name_contractor: varchar(256)
            *keywords: varchar(256)
            *lights: varchar(20)
            *country_code: varchar(3)
            *uri: text
            *advantages: text
            *description: text
            *equipment: text
            *features: text
            *updated_at: timestamp
            --
            unique (guid)
        }

        entity "search_manufacturers_settings" as manufacturers_settings {
            *id: int auto_increment "PK"
            --
            *manufacturer_guid: char(36)
            *locality_guid: char(36)
            *is_hide: tinyint(1)
            *updated_at: timestamp
            *created_at: timestamp
            --
            unique (manufacturer_guid, locality_guid)
        }

        entity "search_categories_settings" as categories_settings {
            *id: int auto_increment "PK"
            --
            *category_guid: char(36)
            *locality_guid: char(36)
            *is_hide: tinyint(1)
            *updated_at: timestamp
            *created_at: timestamp
            --
            unique (category_guid, locality_guid)
        }

        entity "search_categories" as categories {
            *id: int auto_increment "PK"
            --
            *guid: char(36)
            name: varchar(256)
            type: varchar(256)
            parent_guid: char(36)
            is_active: tinyint(1)
            is_enable: tinyint(1)
            up_caption: varchar(256)
            updated_at: timestamp
            --
            unique (guid)
        }

        entity "search_products_relevancy_counts" as products_relevancy_counts {
            *id: bigint: auto_increment "PK"
            --
            *product_guid: char(36)
            *orders: int(11)
            *views: int(11)
            *reviews: int(11)
            *updated_at: timestamp
            --
            unique (product_guid)
        }

        entity "search_products_relevancy_data_items" as relevancy_data_items {
            *id: bigint: auto_increment "PK"
            --
            *hash: char(40)
            *product_guid: char(36)
            *manufacter_guid: char(36)
            *seo_position: int
            *koef_sort: float
            *updated_at: timestamp
            --
            unique (hash)
        }

        entity "search_products_sort_rating" as products_sort_rating {
            *id: bigint: auto_increment "PK"
            --
            *product_guid: char(36)
            *rating: float
            *updated_at: timestamp
            --
            unique (product_guid)
        }


        entity "search_products_sale" as product_sale {
            *id: bigint: auto_increment "PK"
            --
            *hash: char(40)
            *guid: char(36)
            *product_guid: char(36)
            *locality_guid: char(36)
            remaining: int
            price: float
            updated_at: timestamp
            --
            unique (hash)
        }

        entity "search_promotions" as promotions {
            *id: int: auto_increment "PK"
            --
            *product_guid: char(36)
            *locality_guid char(36)
            *name: varchar(256)
            *updated_at: timestamp
        }

        }

    relevancy_kafka -d--> products_relevancy_counts
    relevancy_kafka -d--> relevancy_data_items: data [array]
    relevancy_kafka -d--> products_sort_rating: rating
    rnames_kafka -d----> products
    sale_kafka -d--> product_sale
    promotions_kafka -d--> promotions
    tagpage_status_kafka -d--> categories
    tagpage_delete_kafka -d--> categories
    makes_visibility_kafka -d--> manufacturers_settings
    categories_visibility_kafka -d--> categories_settings
    up_caption_kafka -d--> categories

@enduml