ข้ามไปยังเนื้อหา

Trust and Ownership Boundaries

flowchart LR
  subgraph Browser[Browser UI]
    UI1[Route + Components]
    UI2[Local UI State]
  end

  subgraph ClientRuntime[Client Runtime]
    C1[Context Providers]
    C2[Zustand Stores]
    C3[Service Adapters]
  end

  subgraph BFF[Next.js API Trust Boundary]
    B1["/api/ai/(all)"]
    B2["/api/chat/(all)"]
    B3["/api/canvas/(all)"]
    B4["/api/maps/(all)"]
    B5["/api/dashboard/(all)"]
    B6["/api/internal/(all)"]
  end

  subgraph External[Engine / Realtime / DB]
    E1[AI Engine]
    E2[Realtime Infra]
    E3[Persistence]
  end

  UI1 --> C1
  UI2 --> C2
  C1 --> C3
  C2 --> C3
  C3 --> B1
  C3 --> B2
  C3 --> B3
  C3 --> B4
  C3 --> B5
  B1 --> E1
  B4 --> E2
  B2 --> E3
  B3 --> E3
  B5 --> E3
  B6 --> E3
LayerOwnerต้องรับผิดชอบ
Route + ViewUI teamparse params, render state, UX feedback
Orchestration hooksFrontend platformcanonicalization, bootstrap guards, race prevention
Client servicesFrontend platformrequest shaping, scope propagation
BFF /api/ai/*Backend/BFFauth, allowlist, scope-context resolution, normalization
BFF /api/chat/*Backend/BFFthread/message/history schema + scope enforcement
BFF workspace APIsBackend/BFFworkspace reads/mutations + idempotency + decision telemetry
  1. Browser ต้องไม่ข้าม BFF ไปเรียก inference โดยตรง
  2. Scope validation ต้องจบที่ BFF ทุกครั้งก่อน call downstream
  3. Internal routes ต้องมี trusted claims และ deny เมื่อ claim-scope mismatch
  4. UI state ต้องถือว่า response อาจ stale ได้ และมี guard ป้องกัน overwrite