feat(dashboard): integrate live analytics stats, quota widget, and mobile 2-col layout
Summary of Changes
Features & Enhancements
-
Live Dashboard Stats Integration:
- Replaced mock data in
crawler.service.tswith realGET /api/v1/dashboard/statsvia Next.js proxy. - Connected 5 KPI
StatCarditems to real-time database figures: Total Jobs, Running Jobs, Crawled Pages, Extracted Records, and Success Rate.
- Replaced mock data in
-
Quota & Resource Usage Widget (
quota-usage-widget.tsx):- Displays user plan quota consumption from
GET /api/v1/auth/me/usage(daily pages crawled, daily job count, remaining concurrent task slots). - Dynamic visual alert banners triggered at threshold levels ($\ge 80%$ warning, $100%$ limit reached).
- Deterministic reset countdown timer calculated to midnight UTC.
- Displays user plan quota consumption from
-
Service Ecosystem Health Bar (
service-health-bar.tsx):- Live ecosystem status checking via
/health/readinessand/health/metrics. - Biophilic badges indicating status and response latencies for Supabase PostgreSQL and BullMQ/Redis.
- Live ecosystem status checking via
-
Hero & Header Polish:
- Removed technical stack badge (
Next.js 16 + TanStack Query + shadcn/ui) and clean up from bothviandentranslations.
- Removed technical stack badge (
Bug Fixes & Resilient Improvements
-
Zero Metrics Success Rate Bug:
- Fixed logic where
successRatedefaulted to100%whentotalJobsandtotalPageswere both0. It now accurately computes0%. - Disabled misleading
Ecoand100%trend chips on cards when no activity exists. - Smart numeric check in
StatCardto avoid prepending+to non-numeric strings (Live,Eco,Thời gian thực).
- Fixed logic where
-
SSR Hydration Mismatch Resolution:
- Replaced native
.toLocaleString()calls with deterministicformatNumber()using invarianten-USformatting paired withsuppressHydrationWarningto eliminate server vs client locale number separator differences (1,000vs1.000).
- Replaced native
-
Backend Redis Downtime Resilience:
- Wrapped BullMQ Redis ping and queue checks in
health.service.tswith a 1.5s timeout (Promise.race), preventing PostgreSQL from showing false-offline when Redis is stopped. - Enabled degraded startup mode in
server.tsso API and database remain available when queues are inactive.
- Wrapped BullMQ Redis ping and queue checks in
Mobile Responsiveness (UX)
- Upgraded the 5 KPI StatCard grid to
grid-cols-2on mobile viewports ($\ge 2$ columns per row) with the 5th card spanning across columns, eliminating awkward scrolling and orphan rows. - Adjusted padding (
p-3.5 sm:p-5) and icon sizing on mobile to prevent text truncation. - Re-aligned the health bar refresh button on mobile headers to prevent single-button orphan rows.