Dashboard Runtime 01 · แดชบอร์ด · ศูนย์ติดตาม intelligence · query pipeline + chart renderer + preset storage

Planning · v0.2
เอกสาร planning เท่านั้น · ไม่มี runtime · ไม่ bind pipeline จริง · ไม่ claim live data. B's contract at /kb/dashboard is shell only. Runtime implementation ต้องผ่าน human approval per field ก่อนลงมือ.
Binding: live mock mapped-not-bound placeholder derived

Context บริบท · อ่านอะไร

Phase 12E เปิดตัว dashboard contract ที่ B เขียนไว้ · 17 dashboards ครอบคลุม 6 axes (Input / Processing / Outcome / AI / Business / Governance) · แต่ละ dashboard ระบุ metrics · dimensions · filters · drilldown · chart_type · related-card edges · trilingual labels ครบ. A ต้อง build: signal pipeline → aggregate → cache → chart render · plus personal preset + cross-filter + top-search.

docs/kb/data/dashboard_contract.json17 dashboards · 6 tab axes · 13 chart types · personal preset model · related-card behavior · top-search · D3 rendering note
docs/kb/data/time_intelligence.json17 time modes + 4 view modes · needed for time selector
docs/kb/data/snapshot_model.json5 catalog · 4 export · immutable snapshot rules
docs/kb/data/spatial_intelligence.json6 levels · 4 patterns · for geo dashboards
docs/kb/data/behavioral_intelligence.json6 dims · 4 patterns
docs/kb/data/segment_intelligence.json7 dims · 2 patterns

Scope A implement อะไร

Field Mapping B contract field → A runtime surface

Source: dashboard_contract.dashboards[*] object shape.

B Field B Type A Runtime Target A Owner Layer Approval Gate Binding Notes
id string URL path /app/dashboard/{id} + PK in dashboards table Backend + FE none mapped-not-bound Must be stable — referenced by related_dashboards edges.
tab_axis enum(6) Top-nav tab filter · FE state Frontend none mapped-not-bound 6 fixed: input/processing/outcome/ai/business/governance
label_th / label_en / label_zh string × 3 i18n dictionary · FE t(key) lookup Frontend none mapped-not-bound Trilingual parity required — never display untranslated
purpose_th / purpose_en / purpose_zh string × 3 Dashboard header tooltip · accessible via hint system Frontend none mapped-not-bound Hint-system binding — never hand-typed in A code
audience array RBAC filter · check JWT tier before render Backend gate-rbac mapped-not-bound CLAUDE.md RBAC tiers · 403 if no overlap
chart_type enum(13) Component map · chartRegistry[chart_type] React.lazy Frontend none mapped-not-bound 13 types — all D3-based per d3_rendering_note
primary_metrics[] array<string> TimescaleDB metric columns · CTE in query service Backend gate-signal-pipeline mapped-not-bound Each metric needs producer + dbt model + index — signal pipeline dep
secondary_metrics[] array<string> Same as primary · optional columns Backend gate-signal-pipeline mapped-not-bound Secondary = available but not default-shown
dimensions[] array<string> GROUP BY columns · FE dimension-toggle control Backend + FE none mapped-not-bound dimension must exist in silver table schema
filters[] array<object> WHERE clause builder · FE filter chip row Backend + FE none mapped-not-bound Each filter: field + type + default + allowed values
sort_fields[] array<string> ORDER BY options · FE sort dropdown Backend + FE none mapped-not-bound
drilldown_levels[] array<string> Router drilldown → spatial_intelligence levels Frontend gate-spatial-kanon mapped-not-bound k-anonymity ≥5 per H3 cell before render (CLAUDE.md PDPA)
final_raw_transaction_shape object Raw-view response schema · admin-only endpoint Backend gate-admin-only mapped-not-bound JWT tier=admin required · audit-logged
related_dashboards[] array<dashboard_id> Related-card cross-filter graph · FE click propagation Frontend none mapped-not-bound See related_card_behavior for propagation rules
related_actors[] / related_journeys[] / related_services[] / related_cases[] / related_subsystems[] array<id> Context panel · deep-link to atlas/journeys/services/cases Frontend none mapped-not-bound Links open B-owned KB pages as reference
source_basis / source_refs string / array "Source" footer on card · trust signal Frontend none mapped-not-bound T1..T5 + document refs visible to user
requires_human_review boolean Yellow "under review" banner over chart Frontend none mapped-not-bound Do NOT hide chart — flag it as under-review
honest_note string Caption under chart · never editable in A code Frontend none mapped-not-bound Must render verbatim · no A-side re-wording
personal_dashboard_model.rules object user_preferences.dashboards JSONB column · preset schema Backend gate-auth mapped-not-bound Stored per-user · requires session · PDPA-compliant

A-owned Runtime Boundary ขอบเขต A vs B

B owns (read-only for A)

  • Contract JSON (all fields listed in "Context" block above)
  • Trilingual label parity
  • honest_note + requires_human_review flags
  • Contract evolution (schema-versioned)

A owns (this runtime)

  • All tables + indexes for entities in ER diagram below
  • API endpoints in API Sketch block
  • Frontend components + chart/form rendering
  • Cache + feature flag integration
  • Auth + sign-off capture
  • Audit trail

ER Diagram A-owned tables · Dashboard · query pipeline

Dashboard · query pipeline
dashboards ● id (PK) tab_axis chart_type metrics[] audience[] contract_ref metric_series (hypertable) ● (ts, metric, dim) value tenant_id (RLS) h3_cell k_anon_ok user_preferences ● user_id dashboards JSONB time_mode pinned[] locale snapshots ● id dashboard_id filter_state raw_data (immutable) exported_to

API Sketch FastAPI endpoints

GET/api/dashboard/{id}?filters=&time_mode=
Dashboard data fetch · applies audience+RBAC filter · k-anon enforced
GET/api/dashboard/preset/{user_id}
Load personal dashboard preset · per-user JSONB
POST/api/dashboard/preset
Save/update personal preset
POST/api/dashboard/{id}/snapshot
Produce immutable snapshot · 4 export formats
GET/api/dashboard/search?q=
Top-search across 17 dashboards + metric names (<300ms)

Sequence Flow Dashboard render · cross-filter · k-anon

Dashboard render · cross-filter · k-anon
Next.js UI Query API Timescale k-anon filter D3 renderer 1 GET /api/dashboard/gmv-daily 2 SELECT time_bucket · GROUP BY tenant rows (raw) 3 apply k-anon ≥5 per H3 cell filtered · k_anon_applied=true 4 response JSON D3 render · honest-note banner if requires_human_review=true

Dependencies ต้อง done ก่อน

Upstream (must be done first)

  • Signal pipeline (Kafka → dbt → TimescaleDB) — A infra
  • Auth + JWT tier system — A infra
  • Feature flag registry (hand-feature-flags)
  • H3 spatial k-anonymity filter (PDPA)

Downstream (enables after)

  • Cases runtime (uses dashboard cross-filter)
  • Wizard runtime (uses personal preset storage)
  • Snapshot export (feeds reporting / PDF)

Human Approval Gates human sign-off ก่อน go-live

Risks ความเสี่ยง + mitigation

Signal pipeline lag causes stale dashboards
High
dbt_test_silver freshness >30min → P2 alert (CLAUDE.md); dashboard shows "stale" banner when lag exceeds refresh_cadence
k-anonymity violation on spatial drilldown
High
Enforce k≥5 at query service before return · return "insufficient-k" sentinel · FE shows privacy-suppression card
13 chart types ≠ 13 D3 components — some may share implementation
Med
Map chart_type → renderer key · allow many-to-one · document in A's chart registry
Personal preset schema drifts from B's personal_dashboard_model.rules
Med
Validation layer re-reads contract at app start · schema-version check · migration notes in SYNC
Trilingual label missing for new dashboard
Low
Contract validator already enforces (B-side) · A falls back to EN with visible "untranslated" badge

Definition of Done runtime ถือว่าพร้อม pilot เมื่อ

  1. All 17 dashboards have end-to-end data flow (pipeline → cache → chart) in staging
  2. Time selector + view mode + filter chip + drilldown all functional
  3. Personal preset save/load round-trips for 5 test users
  4. Related-card cross-filter click propagation matches related_card_behavior
  5. Top-search returns results across all 17 + metric names within 300ms p95
  6. 4 export formats (CSV/JSON/PDF/PNG) produce immutable snapshot per snapshot_model
  7. Honest-note banner visible on every requires_human_review=true dashboard
  8. k-anonymity k≥5 enforced on all spatial drilldowns · penetration-tested
  9. All 5 approval gates signed off with evidence in audit trail
  10. Feature flag dashboard.runtime_v1 flipped to staged rollout · rollback drill completed

Deferred จงใจยังไม่ทำในรอบนี้

Dashboard Runtime Planning · v0.2 · Session A · A-owned ← Planning hub · B contract ↗