Skip to content

Admin: Platform dashboard (stats, revenue, users) #48

Description

@manoahLinks

Summary

Platform-wide dashboard for administrators showing key metrics: total revenue, user counts, event counts, recent activity, and platform health indicators.

Endpoint

GET /api/admin/dashboard
Auth: JWT required (ADMIN role)

Success Response (200)

{
  "success": true,
  "data": {
    "users": {
      "total": 5420,
      "buyers": 5100,
      "organizers": 315,
      "admins": 5,
      "newThisMonth": 420
    },
    "events": {
      "total": 890,
      "draft": 45,
      "published": 120,
      "completed": 700,
      "cancelled": 25,
      "newThisMonth": 32
    },
    "revenue": {
      "totalPlatformRevenue": 12500000,
      "totalTicketsSold": 45000,
      "revenueThisMonth": 2100000,
      "ticketsSoldThisMonth": 3200,
      "byProvider": [
        { "provider": "PAYSTACK", "amount": 9000000, "count": 35000 },
        { "provider": "MONNIFY", "amount": 2500000, "count": 7000 },
        { "provider": "BLOCKRADAR", "amount": 1000000, "count": 3000 }
      ]
    },
    "payouts": {
      "totalPaid": 10000000,
      "pendingAmount": 1500000,
      "pendingCount": 12
    },
    "recentActivity": [
      { "type": "event_published", "name": "Abuja Music Fest", "at": "2026-03-12T14:00:00Z" },
      { "type": "payout_completed", "organizer": "John Doe", "amount": 450000, "at": "2026-03-12T13:30:00Z" },
      { "type": "user_registered", "email": "new@user.com", "at": "2026-03-12T13:00:00Z" }
    ]
  }
}

Tasks

  • Implement AdminService.getDashboard():
    1. Aggregate user counts by role + new this month
    2. Aggregate event counts by status + new this month
    3. Aggregate revenue from Transaction records (status=SUCCESS)
    4. Revenue breakdown by provider
    5. Payout summary (total paid, pending)
    6. Recent activity feed (last 10 events: new events, payouts, registrations)
  • Add GET /api/admin/dashboard to AdminController with @Roles(UserRole.ADMIN)
  • Optimize: use Prisma aggregations, cache results in Redis (TTL: 5 min)

Notes

  • Platform revenue = sum of HostIt fees (5% of ticket sales)
  • "This month" = current calendar month
  • Consider caching dashboard data in Redis to avoid heavy queries on every request

Acceptance Criteria

  • Returns comprehensive platform statistics
  • User, event, revenue breakdowns accurate
  • Revenue split by payment provider
  • Recent activity shows latest 10 platform events
  • Only ADMIN role can access (403 for others)
  • Response time < 1s (use aggregations, caching)

Metadata

Metadata

Assignees

No one assigned

    Labels

    adminPlatform administrationphase-8Phase 8: Organizer + Admin

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions