Item Master 架構圖 / Architecture Diagram

日期 / Date:2026-03-20 依據 / Based on:C02-spec.mdC03-schema.sqlC05-review.mdC09-import.mdC12-dbx.md [Verified]

建議閱讀方式 / Suggested reading order:

1. 白話流程架構圖 / Plain-Language Flow Architecture [Verified]

+----------------------------------+
| 我們先收到很多商品相關資料        |
| 發票名稱 / 通路頁 / 條碼 / 圖片   |
| 群眾回報 / 品牌分類提示           |
+----------------+-----------------+
                 |
                 v
+----------------------------------+
| 先全部當成證據                   |
| 不先相信任何單一來源就是答案      |
+----------------+-----------------+
                 |
                 v
+----------------------------------+
| 把很像的發票名稱放成一群          |
| 先回答:這群名稱在講哪個商品?     |
+----------------+-----------------+
                 |
                 v
+----------------------------------+
| 找出最可能的幾個商品版本          |
| 通常先挑 2 到 5 個候選            |
+----------------+-----------------+
                 |
                 v
+----------------------------------+
| 比對各種證據                     |
| 名稱 / 條碼 / 圖片 / 品牌 / 規格  |
| 包裝層級 / 時間 / 通路上下文      |
+----------------+-----------------+
                 |
      +----------+----------+
      |                     |
      v                     v
+-------------+    +----------------------+
| 很明確       |    | 不夠明確或互相打架   |
| 自動確認      |    | 進人工審核或補證據   |
+------+------+    +----------+-----------+
       |                        |
       +------------+-----------+
                    |
                    v
  +----------------------------------+
  | 寫進正式商品主檔                 |
  | 發票名稱群組 -> SI -> BI         |
  +----------------+-----------------+
                   |
                   v
  +----------------------------------+
  | 通過發布條件才對外輸出           |
  | 給搜尋 / 分析 / Barcode-PN / 下游|
  +----------------+-----------------+
                   |
                   v
  +----------------------------------+
  | 已確認結果回饋下次判斷           |
  | 讓後面的比對越來越準             |
  +----------------------------------+

白話補充 / Plain-language notes:

白話例子 / Plain-language example [Inference]

2. 老闆版架構圖 / Executive Architecture [Verified]

+---------------------------+   +-----------------------------+   +-----------------------------+   +----------------------------+   +----------------------+
| 多來源資料 Sources         |-->| 證據層與候選池               |-->| 審核與決策                    |-->| 正式主檔 Gold Master        |-->| 發布閘門與輸出         |
| 發票 / 通路 / 群眾 / 分類  |   | 不讓單一來源直接定真相       |   | auto 或 human final decision |   | BI / SI / barcode / image |   | serving / Barcode-PN  |
+-------------+-------------+   +--------------+--------------+   | crowd 只補證據,不做定案    |   +-------------+--------------+   +----------+-----------+
              ^                                ^                  +--------------+--------------+                               |                         |
              |                                |                                 |                                              v                         v
              +--------------------------------+---------------------------------+                         +----------------------------+   +----------------------+
                                             已確認結果回饋下次判斷                                        | 下游應用 / 交付             |   | 發布條件                |
                                                                                                           | 搜尋 / 分析 / 映射輸出      |   | tier / status / risk   |
                                                                                                           +----------------------------+   +----------------------+

老闆版例子 / Executive example [Inference]

身份判斷速查表 / Identity Decision Quick Reference [Verified]

情況 正確判斷 不要做的事 例子
只是叫法不同,東西沒變 保持同一個 SI,把新叫法收進 alias 或證據層 不要因俗名不同就新開 BI / SI 黃罐品客Pringles Original 110g品客原味 110g
同一商品家族,只是入數或包裝層級不同 BI、新 SI 不要把 6 入 直接併成單瓶 SI 白蘭氏雞精 單瓶 vs 白蘭氏雞精 6 入
同品牌但口味或配方不同 通常不同 BI 不要只因品牌相同就合併 可口可樂原味 vs 可口可樂 Zero
同品牌但不同產品線 不同 BI 不要把品牌當成身份鍵 白蘭氏雞精 vs 白蘭氏蜆精
證據不足或彼此打架 先留在候選 / 補證據 / 人工審核 不要急著新開 BI / SI 發票只寫 完膳 250ml,看不出原味或香草

速查表例子欄為示意,用來幫助判讀,不是正式主檔資料 [Inference]

3. 工程版總體架構 / Engineering End-to-End Architecture [Verified]

+----------------------+   +------------------------+   +---------------------------+
| Source: Invoice      |   | Source: channel_master |   | Source: Crowd / Taxonomy |
| 發票資料              |   | 通路候選與證據         |   | 群眾 / 品牌分類提示       |
+----------+-----------+   +-----------+------------+   +-------------+-------------+
           |                           |                                |
           v                           v                                v
+--------------------------------------------------------------------------------------+
| Bronze / Raw                                                                         |
| raw_invoice_lines | raw_channel_master | raw_crowd_submissions | raw_*_taxonomy     |
+-----------------------------------------------+--------------------------------------+
                                                |
                                                v
+--------------------------------------------------------------------------------------+
| Silver / Working                                                                      |
| invoice_lines                                                                         |
| invoice_name_clusters + cluster_members                                               |
| evidence_observations                                                                 |
| mapping_candidates + mapping_candidate_evidence                                       |
| review_tasks + review_answers                                                         |
+----------------------------+----------------------------+----------------------------+
                             ^                            ^                            ^
                             |                            |                            |
                    +--------------------+      +----------------------+     +----------------------+
                    | Rule / ML / AI     |      | Crowd Tasks          |     | Human Review         |
                    | 候選與 tier 提議    |      | 僅補證據,不做定案   |     | 最終確認 / 駁回 / 新建 |
                    +--------------------+      +----------------------+     +----------------------+
                                               |
                                               v
+--------------------------------------------------------------------------------------+
| Gold / Master                                                                         |
| base_items (BI) | sellable_items (SI) | item_components | item_aliases               |
| item_barcodes | sellable_item_images | mapping_decisions                              |
+-----------------------------------------------+--------------------------------------+
                                                |
                                                v
+--------------------------------------------------------------------------------------+
| Serving Gate / Publish                                                                |
| item_tier + mapping_tier + status + blocking_flags -> serving views / exports        |
| vw_confirmed_invoice_mapping | vw_sellable_item_master | vw_base_item_master          |
+--------------------------------------------------------------------------------------+
                                                |
                                                v
+--------------------------------------------------------------------------------------+
| Downstream                                                                            |
| Barcode-PN export | search | analytics | other consumers                             |
+--------------------------------------------------------------------------------------+

Feedback loop / 回饋迴圈
mapping_decisions + confirmed history ------------------------------> candidate build
sellable_items (existing SI universe) ------------------------------> candidate build

命名層補充 / Naming-layer note [Verified]

工程版總體例子 / Engineering architecture example [Inference]

4. 工程版決策控制流 / Engineering Decision Control Flow [Verified]

invoice_lines
    |
    v
invoice_name_clusters
    |
    v
shortlisted candidates
2 to 5 candidate SI + score + veto + source-risk check
    |
    +--> score >= 85
    |    gap >= 12
    |    no veto
    |    no high-risk source dominates
    |    ------------------------------> gold_master_publish
    |                                     -> mapping_decisions.auto_confirmed
    |
    +--> score 60 to 84
    |    or candidate conflict
    |    or high-risk source dominates
    |    ------------------------------> under_review
    |
    +--> score < 60
    |    or missing evidence
    |    ------------------------------> needs_more_evidence
    |
    +--> no candidate survives
         ------------------------------> new_item_triage / reject_all review

under_review
new_item_triage / reject_all review
    |
    v
human final decision
    |
    +--> confirm_candidate -------> gold_master_publish
    |                                 -> mapping_decisions.review_confirmed
    |
    +--> reject_all --------------> gold_master_publish
    |                                 -> mapping_decisions.rejected
    |
    +--> needs_more_evidence ----> return to evidence_observations / review_tasks
    |
    +--> create_new_item --------> gold_master_publish
                                      -> create / update BI and SI
                                      -> mapping_decisions.needs_new_item

決策流例子 / Decision-flow example [Inference]

5. 工程版 Job DAG / Engineering Pipeline Architecture [Verified]

bronze_invoice_ingest -----------+
                                 |
                                 v
                           silver_invoice_prepare ---------------------+
                                                                      |
bronze_channel_master_ingest -----------------------------------------+--> silver_candidate_build --> silver_review_sync --> gold_master_publish
                                                                      |
bronze_crowd_ingest --------------------------------------------------+

raw_brand_taxonomy / raw_category_taxonomy ---------------------------> silver_invoice_prepare
raw_brand_taxonomy / raw_category_taxonomy ---------------------------> silver_candidate_build
AI / crowd / human answers -------------------------------------------> silver_review_sync

all jobs -------------------------------------------------------------> ops_job_monitor

Job DAG 例子 / Job DAG example [Inference]

6. 治理與權限架構 / Governance and Permission Architecture [Verified]

+----------------------+      +----------------------+      +----------------------+      +----------------------+
| Rule / ML / AI       |----->| Silver Candidates    |----->| Human Review         |----->| Gold Master Publish  |
| 可提議 candidate/tier |      | proposed state only  |      | 最終確認 / 駁回 / 新建 |      | 寫正式 decision      |
| 不可最終定案          |      | 不等於 final truth   |      | 可升降 mapping/item   |      | 建 / 更新 BI / SI    |
+----------+-----------+      +----------+-----------+      +----------+-----------+      +----------+-----------+
           ^                             ^                             ^                             |
           |                             |                             |                             v
+----------+-----------+      +----------+-----------+      +----------+-----------+      +----------------------+
| Crowd Tasks          |----->| review_answers /     |----->| review_tasks backlog |      | Serving Gate         |
| 只補證據與拆解任務    |      | evidence_observations|      | queue ownership      |      | 發布前再過條件       |
| 不可建正式商品        |      | 不可直接定案         |      | review by human      |      | tier / status / risk |
+----------------------+      +----------------------+      +----------------------+      +----------+-----------+
                                                                                                     |
                                                                                                     v
                                                                                          +----------------------+
                                                                                          | Downstream Consumers |
                                                                                          | read-only outputs    |
                                                                                          +----------------------+

角色與權限 / Role and permission summary:

治理例子 / Governance example [Inference]

7. 環境與產出架構 / Environment and Output Architecture [Verified]

+--------------------------------------------------------------------------------------------------+
| Unity Catalog: item_master                                                                       |
+--------------------------------+--------------------------------+--------------------------------+
                                 |                                |
                                 v                                v
                    +----------------------------+     +----------------------------+
                    | item_master.bronze         |     | item_master.silver         |
                    | raw_invoice_lines          |     | invoice_lines              |
                    | raw_channel_master         |     | invoice_name_clusters      |
                    | raw_crowd_submissions      |     | cluster_members            |
                    | raw_brand_taxonomy         |     | evidence_observations      |
                    | raw_category_taxonomy      |     | mapping_candidates         |
                    +-------------+--------------+     | review_tasks / answers     |
                                  |                    +-------------+--------------+
                                  |                                  |
                                  +---------------+------------------+
                                                  |
                                                  v
                                    +----------------------------+
                                    | item_master.gold           |
                                    | base_items                 |
                                    | sellable_items             |
                                    | item_barcodes              |
                                    | sellable_item_images       |
                                    | mapping_decisions          |
                                    +-------------+--------------+
                                                  |
                                                  v
                                    +----------------------------+
                                    | serving views / exports    |
                                    | vw_confirmed_invoice_mapping|
                                    | vw_sellable_item_master    |
                                    | vw_base_item_master        |
                                    | Barcode-PN export          |
                                    +-------------+--------------+
                                                  |
                                                  v
                                    +----------------------------+
                                    | downstream outputs         |
                                    | search / analytics / API   |
                                    +----------------------------+

環境與產出邊界 / Environment and output boundary notes:

環境與產出例子 / Environment and output example [Inference]

8. 圖例 / Legend