Skip to content

Reports

Melvin PETIT edited this page Jun 16, 2026 · 1 revision

Reports

The Reports page assembles a filterable, exportable security report from the current data. Aggregation logic lives in src/lib/reports/, orchestrated by getReportData(companyId, filters).

Report sections

getReportData runs all aggregations in parallel and returns a ReportData object with these sections:

Section Module Content
Key findings findings.ts Headline takeaways derived from the other sections
Exposure exposure.ts Overall exposure summary (employees affected, breach counts)
Data types data-types.ts Breakdown of compromised data categories
Departments departments.ts Exposure grouped by department
Employees by-employee.ts Per-employee breach breakdown
Trends trends.ts Time-series of detections
Compliance compliance.ts Compliance-oriented summary
Deltas deltas.ts Change vs. a comparison window

Each section has a matching UI component in src/components/reports/ (ExposureSection, DataTypeSection, DepartmentSection, EmployeeSection, TrendsSection, ComplianceSection, KeyFindingsSection), composed by ReportCanvas with a ReportToolbar and ReportFilterBar.

Filters

Filters are defined in reports/filters.ts (ReportFilters, with an EMPTY_FILTERS default). They scope every section consistently, since all aggregations receive the same filter object.

Comparison windows

The Deltas section compares the current period against a previous one. The window logic is in reports/windows.ts and is covered by unit tests in reports/windows.test.ts (run with npm test).

CSV export

Reports export to CSV via reports/csv.ts, exposed at:

GET /api/reports/export

The endpoint streams a CSV built from the same ReportData, honoring the active filters.

Clone this wiki locally