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

System Topology and Layers

flowchart TB
  subgraph L1[Presentation Layer]
    R[App Router /chat]
    UCV[UnifiedChatView]
    CP[ChatPane]
    DCL[DynamicCanvasLoader]
  end

  subgraph L2[Client Orchestration Layer]
    PVD[Auth/Project/Kobi/Thread Providers]
    CCTX[AgentState + Action + ChatState Context]
    HK[useUnifiedChat* / useChat* hooks]
    ZS[Zustand Stores]
  end

  subgraph L3[Client Service Layer]
    UCS[unifiedChatService]
    SSS[sessionStartService]
    CS[canvasService]
    MS[mapService]
    DS[dashboardService]
  end

  subgraph L4[BFF/API Layer]
    SESSION["Session start API"]
    AI["/api/ai/(all)"]
    CHAT["/api/chat/(all)"]
    CANVAS["/api/canvas/(all)"]
    MAPS["/api/maps/(all)"]
    DASH["/api/dashboard/(all)"]
    INTERNAL["/api/internal/(all)"]
  end

  R --> UCV
  UCV --> CP
  UCV --> DCL
  CP --> PVD
  DCL --> PVD
  PVD --> CCTX
  CCTX --> HK
  HK --> ZS
  HK --> SSS
  HK --> UCS
  HK --> CS
  HK --> MS
  HK --> DS
  SSS --> SESSION
  SESSION --> CHAT
  SESSION --> DASH
  UCS --> AI
  UCS --> CHAT
  CS --> CANVAS
  MS --> MAPS
  DS --> DASH
  AI --> INTERNAL
flowchart LR
  A[AuthProvider] --> B[ProjectProvider] --> C[KobiProvider] --> D[ThreadProvider] --> E[AgentStateProvider] --> F[ActionProvider] --> G[ChatStateProvider] --> H[IdeaProvider]

ลำดับนี้สะท้อน dependency จริง: identity/project -> mode bootstrap -> thread scope -> action/chat state -> workspace-specific coordination

  1. UnifiedChatView
  • parse route/query/share scope
  • sync active agent จาก thread/share context
  • derive workspace scope
  • bootstrap thread/realtime/canvas props
  1. ChatPane
  • new chat bootstrap ผ่าน session start API
  • send message และ thread pre-creation fallback
  • history + thread switching
  • action approve/reject/batch resume
  • analytics readiness gate
  1. DynamicCanvasLoader
  • resolve workspace จาก modeId/workspaceId
  • mount component จาก registry และส่ง scope props ให้ถูกต้อง
  • Specialized modes ต้องมี canonical scope key ที่สอดคล้องกับ endpoint
  • New chat path ควรได้ threadId + canonicalPath จาก session start ก่อน route transition
  • URL/state ต้องถูก canonicalize เสมอเมื่อ resolve scope ได้จาก thread metadata
  • BFF เป็นจุดสุดท้ายที่ตรวจสอบ field allowlist, scope matching และ metadata normalization