feat: implement rule management (US3) + dashboard (US4)

US3 - Rule Management:
- Backend: CRUD API + activate/deactivate + test against 90d history
- Frontend: RuleList sidebar, RuleForm (create/edit), RuleTestResults
- Weight/threshold sliders, condition type selector, audit logging

US4 - Dashboard:
- Backend: GET /dashboard/metrics (24h/7d/30d/90d), CSV export
- Frontend: MetricCards, alerts-by-hour bar chart, status pie chart,
  top rules horizontal bar chart via Recharts

Stack: 20 API routes total. Frontend tsc clean, vite build passes.
This commit is contained in:
Felipe Domingues 2026-05-12 19:14:44 -03:00
parent 989202648d
commit 1175ae7ff0
15 changed files with 1095 additions and 14 deletions

View file

@ -85,11 +85,29 @@ export interface TransactionAccepted {
}
export interface DashboardMetrics {
period: string;
total_transactions: number;
total_alerts: number;
fraud_rate_pct: number;
false_positive_rate_pct: number;
alerts_by_status: { pending: number; confirmed: number; false_positive: number; escalated: number };
alerts_by_hour: { hour: number; count: number }[];
top_triggering_rules: { rule_name: string; alert_count: number }[];
score_distribution: { low: number; medium: number; high: number; critical: number };
}
export interface DetectionRule {
id: string;
name: string;
description: string;
condition: string;
weight: number;
threshold: number;
is_active: boolean;
version: number;
created_by: string;
created_at: string;
updated_at: string;
}
export function listAlerts(params: AlertFilters = {}): Promise<AlertListResponse> {