ai-powered-conversational-intelligence

PROMPT 30 — Analytics & Insights Dashboard

Committed verbatim, per 00_MASTER_IMPLEMENTATION_CONTRACT.md’s own instruction that every prompt in the 32-prompt series is executed against that standing contract, not just the one that introduced it.

CLAUDE CODE PROMPT

Role

Act as a Principal Architect, senior engineer and enterprise product engineer responsible for safely extending an existing production-oriented AI platform.

Objective

Build the primary business-user analytics experience using real analytics APIs.

Mandatory first step

Read 00_MASTER_IMPLEMENTATION_CONTRACT.md.

Then inspect the repository before changing code.

Inspect before implementation

Inspect current chat/question UI, analytics APIs, result engine, visualization specifications and frontend chart components.

Implementation requirements

Support natural-language questions and display KPI/answer, visualization, explanation, filters, time range, freshness, evidence, authorized SQL details, anomalies and related questions. Include KPI cards, trends, comparisons, rankings, distributions, anomaly panels and drill-down. Provide loading, empty, error and insufficient-evidence states. Respect field-level permissions. Link insights to evidence and semantic definitions.

Testing requirements

Test business-user access, unauthorized fields, real API data, empty/error states and visualization rendering.

Acceptance criteria

A business user can complete the full question→analysis→evidence experience from the UI.

Non-functional requirements

Required execution lifecycle

INSPECT → PLAN → IMPLEMENT → TEST → REVIEW → FIX → DOCUMENT → REPORT

Before broad implementation, present the implementation plan. After implementation, run relevant tests and fix regressions.

Required final report

Report:

  1. Areas inspected.
  2. Existing functionality reused.
  3. Files created/modified.
  4. API/config/database changes.
  5. Tests added.
  6. Tests executed and results.
  7. Security findings.
  8. Tenant-isolation findings.
  9. Performance implications.
  10. Known limitations.
  11. Remaining risks.
  12. Recommended next prompt.

Outcome summary

Prompt 30 turned the analytics the platform already computed into a business-user analysis view inside each answered question. No new dashboard page was built. The question→answer flow already exists (frontend/src/components/chat/TurnCard.tsx), and the master contract’s “never duplicate dashboard functionality” rule makes a parallel page the wrong shape. The analysis renders in the answered turn, under the insight, gated exactly like the insight itself (after “Confirm and Run”, and only while the SQL box still holds the SQL that produced the answer).

What was actually missing

The backend already computed most of this. The frontend never received it:

What changed

Backend (additive, pass-through only, no computation changed):

Frontend:

Reuse (master rule 2/3)

How the requirements map

Testing

Results: backend 3541/3541 (pytest, full suite, run twice; one earlier run failed on a test that passes in isolation and in every pairwise combination, and the rerun on an unchanged tree passed in full, see Known limitations for the concurrent-edit note). Frontend 386/386 (vitest run, up from 349). tsc -b clean. oxlint reports no warnings in any file this prompt wrote. npm run build passes. ruff check, black --check, and mypy are clean on every backend file this prompt touched.

Known limitations

Known risks

Prompt 31. Before it starts, reconcile the working tree: the files listed above were changed outside this prompt, and they should be reviewed and either committed or reverted deliberately, not carried into the next prompt by accident.