Summary
The admin panel needs data to power the analytics dashboard (F-10). Backend aggregation endpoints are needed to efficiently compute platform-wide metrics without sending raw data to the frontend.
Requirements
- Add
GET /admin/analytics/overview — summary stats:
- Total escrows (by status), total volume (XLM), total platform fees collected
- Active users (last 30 days), new users (last 30 days)
- Add
GET /admin/analytics/volume?period=daily|weekly|monthly&from=&to= — time-series data:
- Escrow count and total value per time bucket
- Add
GET /admin/analytics/disputes — dispute metrics:
- Total disputes, dispute rate (% of escrows), avg resolution time
- Resolution outcome distribution (released/refunded/split)
- Add
GET /admin/analytics/top-users?limit=10 — leaderboard:
- Wallet address, escrow count, total volume, completion rate
- Use TypeORM query builder for efficient SQL aggregation (not loading all records into memory)
- Cache results with a TTL (5 minutes) to avoid expensive re-computation on every request
- All endpoints require admin role
Acceptance Criteria
Context
- Admin controller:
apps/backend/src/modules/admin/admin.controller.ts
- Admin service:
apps/backend/src/modules/admin/admin.service.ts
- Escrow entity:
apps/backend/src/modules/escrow/entities/escrow.entity.ts
- Admin guard:
apps/backend/src/modules/auth/middleware/admin.guard.ts
Rollout Phase
Phase 5 — Admin & Production Hardening
Points: 150 (Medium)
Summary
The admin panel needs data to power the analytics dashboard (F-10). Backend aggregation endpoints are needed to efficiently compute platform-wide metrics without sending raw data to the frontend.
Requirements
GET /admin/analytics/overview— summary stats:GET /admin/analytics/volume?period=daily|weekly|monthly&from=&to=— time-series data:GET /admin/analytics/disputes— dispute metrics:GET /admin/analytics/top-users?limit=10— leaderboard:Acceptance Criteria
Context
apps/backend/src/modules/admin/admin.controller.tsapps/backend/src/modules/admin/admin.service.tsapps/backend/src/modules/escrow/entities/escrow.entity.tsapps/backend/src/modules/auth/middleware/admin.guard.tsRollout Phase
Phase 5 — Admin & Production Hardening
Points: 150 (Medium)