Skip to content

B-7: Admin analytics aggregation endpoints #202

@KuchiMercy

Description

@KuchiMercy

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

  • Overview endpoint returns accurate summary statistics
  • Volume endpoint returns time-series data groupable by day/week/month
  • Dispute endpoint returns rate and resolution metrics
  • Top users endpoint returns ranked user list
  • All endpoints are protected by the admin guard
  • Queries use SQL aggregation (GROUP BY, COUNT, SUM) not in-memory computation
  • Results are cached with 5-minute TTL
  • Date range filtering works on the volume endpoint

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions