> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Workflow Metrics & KPI Dashboards — Integration Documentation

> Version: 1.0.0 Last Updated: 2026-03-23 Status: \U0001F4DD Planned

**Version:** 1.0.0\
**Last Updated:** 2026-03-23\
**Spec:** [FW-58](../../../specs/fw/archive/FW-58-workflow-metrics-kpi-dashboards.md)\
**Status:** 📝 Planned

***

## Overview

FW-58 provides business-oriented KPI dashboards (approval rates, SLA compliance, form completion, automation throughput, time-saved estimates), snapshot storage for scalable reads, drill-down into existing FW surfaces, and scheduled PDF reports delivered through PF-10.

***

## Integration Points

### 1. FW-23 (Workflow Performance Analytics)

**Pattern:** Intra-core navigation / complementary metrics\
**Direction:** FW-58 deep-links to execution lists or FW-23 views from automation throughput cards\
**Status:** 📝 Planned

FW-23 focuses on technical execution performance. FW-58 consumes execution counts and success rates for business KPIs without duplicating node-level timing charts.

### 2. FW-34 (Approval Workflows)

**Pattern:** Data read + drill-down route\
**Direction:** KPI aggregates from `fw_approval_requests`; drill-down opens filtered approval list\
**Status:** 📝 Planned

### 3. FW-35 / PF-83 (SLA)

**Pattern:** Data read\
**Direction:** SLA compliance KPI reads deadline/breach fields from approval + SLA instance data per existing FW-35/PF-83 contracts\
**Status:** 📝 Planned

### 4. FW-05 (Multi-Page Forms)

**Pattern:** Data read (optional)\
**Direction:** Form drop-off KPI uses page/step analytics when available\
**Status:** 📝 Planned

### 5. PF-10 (Notifications) & email provider

**Pattern:** Platform Layer — email with **link** to stored PDF (Phase 1)\
**Direction:** FW-58 Edge function uploads PDF to Storage, then creates `pf_notifications` rows and/or sends via `sendEmailWithAutoConfig` (`moduleCode: 'fw'`)\
**Status:** 📝 Planned

**Contract (high level):**

* Caller: `fw-kpi-scheduled-report` Edge function (service role after schedule validation).
* Recipients: org profile emails only (Phase 1 per spec).
* **No raw PDF attachment** in Phase 1: `supabase/functions/_shared/email-provider.ts` `EmailSendRequest` has no `attachments` field; HTML body includes **signed download URL** (and optional `action_url` to `/fw/...` dashboard when route exists).
* Phase 2 (optional): extend `sendEmail` / Graph / Gmail builders to support attachments, then attach `application/pdf` directly.

**PHI:** KPI PDFs must contain only aggregates; no PHI in body or stored object metadata.

### 6. PF-58 (Table v2)

**Pattern:** Platform Layer\
**Direction:** Tabular drill-down lists use `@/platform/table-v2`\
**Status:** 📝 Planned

### 7. FW-43 (Audit Trail) — optional

**Pattern:** Convention / future correlation\
**Direction:** Report generation may emit audit events aligned with FW-43 patterns; not blocking for MVP\
**Status:** 📝 Deferred

***

## Event Contracts

No new cross-core domain events required for Phase 1. Optional internal event: `fw_kpi_report_sent` for observability (intra-core only).

***

## Security & Tenancy

* All new tables include `organization_id` and RLS via `fw_has_org_access`.
* Snapshot writes are not exposed as direct authenticated INSERT; use `SECURITY DEFINER` batch function or Edge job with validated scope.
* Drill-down respects underlying table RLS and permission keys on target UIs.

***

## Related Documents

* [CROSS\_CORE\_INTEGRATIONS.md](./CROSS_CORE_INTEGRATIONS.md) — matrix row for FW-58
* [PLATFORM\_INTEGRATION\_LAYERS.md](./PLATFORM_INTEGRATION_LAYERS.md)
* [FW-58 CONTEXT](../../../specs/fw/archive/FW-58-CONTEXT.md) — UI and behavior decisions
