Skip to content

Tóm tắt quyết định (Decision Brief) — Insight Ghi Âm cho BOD

Đọc trước hết — bức tranh 5 phút về scope, quyết định, ảnh hưởng và việc tiếp theo. Chi tiết triển khai xem prd.md, ui-spec.md, dev-spec.md.


1. Bức tranh tổng quan

Vấn đề: BOD không có view tổng quan compliance ghi âm tư vấn toàn 70 chi nhánh. Hiện phải gọi Manager hỏi từng CN hoặc duyệt list /e/record thủ công — không scale.

Giải pháp: Trang dashboard mới /e/record/insights chỉ tracking-only (xem + nghe + drill-down). Tận dụng tối đa code hiện có (RecordForm audio, RecordTable filter, DashboardCardItem, Chart.js wrappers).

Đối tượng người dùng: BOD, IT Leader, Admin (3 role). BranchManager sẽ được cấp quyền ở P2.

Phạm vi P0 (~1.5 tuần): Dashboard chính với 5 KPI + 4 chart + 2 anomaly + 2 modal drill-down + extend /e/record với URL query params + 3 Hasura materialized views (mandatory P0 sau code review B5) + Hasura appointment.records relationship (required FR-006/007) + BE permission seed schema v2 + 4 indexes Tier 1.

Phạm vi P1 (~1 tuần): Comparison mode + Hour-of-day filter + Anomaly banner trên /e/record + Lazy load charts.

Phạm vi P2 (~1.5 tuần): Export Excel/PDF + Schedule email + Full Staff Ranking page + KPI drill-down panel.


2. Quyết định canonical (Z — Decision Log preview)

IDQuyết địnhTác động chính
DEC-001Tracking-only stance — không gọi/SMS/ghi chú/taskGiảm 65% scope so design v1
DEC-003Reuse RecordForm.tsx audio — không build mớiTiết kiệm 3 components + waveform lib
DEC-006Drill-down /e/record thay vì modal complexChỉ 2 modal P0 (Missing + KH chờ TV)
DEC-010Permission Dynamic v2 — action view_insight mớiSeed migration BOD + ITLeader
DEC-012Performance P0 mandatory: 4 Tier 1 indexes + Hasura cache + URQL stale-while-revalidate + 3 materialized views P0TTFMP < 2s/7d, < 3s/30d
DEC-016 (NEW)BE enforcement P0: Hasura permission cho 3 materialized views (filter branch IN allowed)Tránh leak data
DEC-008Branch chart bar top 10 + "Khác" (KHÔNG pie 70 slices)Scale 70 CN UX

Đầy đủ 15 DEC — xem SOURCE_OF_TRUTH.md §1.


3. Phạm vi & loại trừ

Trong phạm vi (In Scope) — P0

Hạng mụcSố lượng
Page mới /e/record/insights1
Dashboard widgets7 (FilterBar, KPIRow, TrendChart, TopStaffChart, HourHeatmap, BranchTopChart, AnomalyAlerts)
Drill-down modals2 (MissingRecords, AnomalyMissingTV)
Store1 (useRecordInsightStore)
/e/record extendParse URL query params + 2 filter (durationGt/Lt)
BE permission seedAction view_insight cho voice_recording_management module
Indexes Tier 1 mandatory4 indexes (3 B-tree + 1 BRIN)

Tổng FE components P0: ~11 — giảm 65% so design v1 (16 components). Tổng BE additions P0: 1 migration seed permission + 1 indexes migration + optional 1 audio URL action.

Ngoài phạm vi MVP (Out of Scope)

  • AI transcription / sentiment / auto-tag — separate PRD
  • Mobile responsive — web-only
  • Audit notes / Compose reminder / Tạo task / Gọi điện / SMS
  • Anomaly Long calls (>60p), Short calls (<1p) — Manager/Operations scope
  • 5 modal phức tạp (TopStaffDetail/HeatmapSlot/AnomalyLong/AnomalyShort/TrendDayDetail) — đã chuyển drill-down

Defer P1

  • Comparison mode (P0 chỉ delta WoW trên KPI card)
  • Hour-of-day filter trong RecordTable
  • Anomaly banner trên /e/record khi drill-down
  • Lazy load chart components (IntersectionObserver)

Defer P2

  • Export Excel/PDF + Schedule email
  • Full Staff Ranking page sub-route
  • KPI drill-down panel
  • Configurable anomaly thresholds Settings

4. Ảnh hưởng

Người dùng

  • BOD/CEO/CFO: view tổng quan compliance + coverage toàn 70 CN trong < 5s
  • IT Leader: track infrastructure health của recording system
  • Manager (P2): xem insight branch của họ
  • NV Staff: KHÔNG ảnh hưởng — vẫn dùng /e/record như cũ

Hệ thống

  • Database: 4 indexes mới + 1 migration permission seed P0; 3 materialized views P0
  • Hasura: 3 view metadata YAML (P0) + appointment.records relationship YAML (P0) + Hasura view permission filter (BE enforcement P0)
  • API: aggregation queries qua Hasura GraphQL (không cần BE custom action P0)
  • Frontend: 1 page + 7 widgets + 2 modal mới; extend RecordTable.tsx
  • Performance: 105k records/30 ngày × 70 CN với TTFMP target 2-3s

Vận hành

  • Permission Dynamic v2 phải seed action mới TRƯỚC khi FE deploy
  • Migration indexes phải chạy TRƯỚC (zero-downtime với CREATE INDEX CONCURRENTLY)
  • BOD phải được seed view_insight trước demo

5. Rủi ro chính

Rủi roMứcHành động giảm thiểu
TTFMP > 3s với 30 ngày × 70 CN🟠 CaoTier 1 indexes mandatory + benchmark trên staging trước go-live (PD-008)
Appointment baseline cho "Tuân thủ" chưa rõ (PD-003)🟠 CaoBlock metric "Tuân thủ ghi âm" cho đến khi PO/BE align — fallback default tạm thời
reference_file.duration NULL nhiều (PD-004)🟡 TrungView expose records_without_duration để monitor; backfill script nếu > 5% NULL
JWT claim size 70 branches (PD-006)🟡 TrungTest JWT size < 8KB; optimize bằng view_all flag nếu cần
Action permission tên (PD-005)🟡 TrungĐề xuất view_insight — BE confirm trước migration
Materialized view refresh fail🟡 TrungMonitoring + alerting; fallback inline aggregation

6. Việc tiếp theo

TaskNgười làmDeadlineTrạng thái
BE align Pending Decisions PD-001 đến PD-008Tech Lead BE + POTrước P0 dev kickoff⚠ Open
Frontend implement P0 widgets + page + 2 modalFE Dev~5 ngày dev📋 Pending
Backend permission seed + indexes migrationBE Dev~1 ngày📋 Pending
QA test plan executionQASau dev complete📋 Pending
Staging benchmark performance (TTFMP)DevOps + Tech LeadTrước go-live📋 Pending
Go-Live P0 (BOD demo)AllT+10 ngày từ kickoff📋 Pending

7. File bộ đọc trước (Reading order)

1. decision-brief.md (file này) → bức tranh 5 phút
2. SOURCE_OF_TRUTH.md            → truth canonical, 15 DEC + 10 PD
3. EVIDENCE_PACK.md              → bằng chứng code/screen verified

8. File bộ triển khai

4. prd.md                        → hợp đồng nghiệp vụ (Z+A sections)
5. ui-spec.md                    → hợp đồng màn hình (B sections, mockups)
6. dev-spec.md                   → data/API/migration/performance (C sections)
7. qa-test-plan.md               → test oracle (D sections)
8. go-live-checklist.md          → release gates (E sections)
9. handoff.md                    → RACI + timeline + blocker

Quy ước: SOURCE_OF_TRUTH.md thắng mọi conflict. PRD là hợp đồng nghiệp vụ, không phải landing page delivery. Handoff là nơi canonical cho RACI/timeline/blocker.