Skip to content

feat: owner-facing analytics dashboard (revenue, low-stock, trust score) - #16

Merged
Mahakisore7 merged 1 commit into
mainfrom
feat/analytics-dashboard
Sep 19, 2026
Merged

Mahakisore7 merged 1 commit into
mainfrom
feat/analytics-dashboard

Conversation

@Mahakisore7

Copy link
Copy Markdown
Contributor

Adds GET /dashboard, restricted to owner/manager via authContext's new canViewDashboard(). Reads existing data only — inventory_records via its ShopConflictIndex GSI and orders via its existing pk/sk query — so there are zero schema changes and no new audit_log GSI, keeping the write-path untouched.

  • revenue: total, order count, average order value, trailing 7-day window
  • low_stock: items at/under a configurable threshold (default 5), sorted ascending
  • trust_score: (total_items - items_with_open_conflict) / total_items, derived from inventory_records' current conflict_status

Frontend gets a role-gated Dashboard nav link and DashboardPage showing the same breakdown, color-toned by trust-score severity.

Tests: 6 new API tests (dashboardQuery.test.ts), 3 new web tests (DashboardPage.test.tsx), 2 new App.test.tsx nav-visibility tests, 2 new CDK tests for the Analytics construct — full CDK suite (34/34) verified green including the new tests.

Adds GET /dashboard, restricted to owner/manager via authContext's new
canViewDashboard(). Reads existing data only — inventory_records via its
ShopConflictIndex GSI and orders via its existing pk/sk query — so there
are zero schema changes and no new audit_log GSI, keeping the write-path
untouched.

- revenue: total, order count, average order value, trailing 7-day window
- low_stock: items at/under a configurable threshold (default 5), sorted
  ascending
- trust_score: (total_items - items_with_open_conflict) / total_items,
  derived from inventory_records' current conflict_status

Frontend gets a role-gated Dashboard nav link and DashboardPage showing
the same breakdown, color-toned by trust-score severity.

Tests: 6 new API tests (dashboardQuery.test.ts), 3 new web tests
(DashboardPage.test.tsx), 2 new App.test.tsx nav-visibility tests, 2 new
CDK tests for the Analytics construct — full CDK suite (34/34) verified
green including the new tests.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Mahakisore7
Mahakisore7 merged commit 57660b2 into main Sep 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant