feat: implement real uptime monitoring, alerts, admin dashboard, billing & usage tracking

- Uptime service: real HTTP HEAD checks with response time tracking
- Alert engine: evaluates scan results, auto-resolves recovered alerts
- Notifications: Resend email + webhook delivery
- Admin dashboard: system stats, user CRUD, org management (role-protected)
- Billing: tier limits (free/starter/pro/enterprise), usage tracking API
- Competitor analysis: real Lighthouse comparison + response time
- Tests: 11 backend + 11 frontend = 22 total tests passing
- Database: added competitor_metrics, alert_configurations tables

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Dennis
2026-03-06 00:51:54 +01:00
parent 14a32bdc0d
commit 0d2aef07bc
19 changed files with 2198 additions and 63 deletions
@@ -166,4 +166,41 @@ CREATE POLICY "Users can view uptime checks for their organization's websites" O
JOIN users u ON w.organization_id = u.organization_id
WHERE u.id = auth.uid()
)
);
-- Competitor metrics table
CREATE TABLE IF NOT EXISTS competitor_metrics (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
website_id uuid REFERENCES websites(id) ON DELETE CASCADE,
url text NOT NULL,
name text,
performance_score numeric,
seo_score numeric,
accessibility_score numeric,
best_practices_score numeric,
status_code integer,
response_time integer,
last_scanned_at timestamp with time zone DEFAULT now(),
created_at timestamp with time zone DEFAULT now(),
UNIQUE(website_id, url)
);
CREATE INDEX IF NOT EXISTS idx_competitor_metrics_website_id ON competitor_metrics(website_id);
-- Alert configurations table (per-website thresholds)
CREATE TABLE IF NOT EXISTS alert_configurations (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
website_id uuid REFERENCES websites(id) ON DELETE CASCADE UNIQUE,
performance_threshold numeric DEFAULT 0.5,
seo_threshold numeric DEFAULT 0.5,
accessibility_threshold numeric DEFAULT 0.5,
uptime_threshold numeric DEFAULT 0.95,
email_enabled boolean DEFAULT true,
email_address text,
slack_enabled boolean DEFAULT false,
slack_webhook_url text,
alert_frequency text DEFAULT 'immediate',
created_at timestamp with time zone DEFAULT now(),
updated_at timestamp with time zone DEFAULT now()
);
);