Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 Feature: Dashboard/admin endpoint #174

Open
2 tasks done
yurimutti opened this issue Dec 7, 2024 · 2 comments
Open
2 tasks done

🚀 Feature: Dashboard/admin endpoint #174

yurimutti opened this issue Dec 7, 2024 · 2 comments

Comments

@yurimutti
Copy link
Contributor

🔖 Feature description

Create an /admin/dashboard endpoint to provide a comprehensive overview of the platform’s key metrics and statistics. The endpoint should return aggregated data about users, reports, residue types, financial performance, and platform growth to enhance admin decision-making and platform monitoring.

🎤 Why is this feature needed ?

This feature is crucial for administrators to have a centralized view of the platform's performance and user activity. By having access to vital metrics, admins can:

Monitor the health and growth of the platform.
Identify areas for improvement, such as low user engagement or delayed report approvals.
Take data-driven actions to enhance the recycling ecosystem.
Example Use-Case:
In my use case, the dashboard will help admins quickly assess:

How many users are actively submitting recycling reports.
Which residue types are being processed the most.
How the platform's financial incentives (tokens) are performing.
This information is essential to ensure operational efficiency and scalability.

✌️ How do you aim to achieve this?

The /admin/dashboard endpoint will be implemented as a GET route and will return a structured JSON response with the following metrics:

User Statistics: Total, active users, and breakdown by type (e.g., recyclers, auditors).
Reports Data: Total, monthly submissions, and status breakdown (approved, pending, rejected).
Residue Types: Aggregated weight by type (e.g., plastic, metal).
Financials: Tokens issued/redeemed and cashback amounts.
Growth Metrics: Monthly user and report growth rates.
The implementation will leverage service classes for data aggregation and optimize database queries for performance. Data may also be cached for faster retrieval.

🔄️ Additional Information

Alternative Solution: A separate endpoint could be created for each metric (e.g., /admin/stats/users, /admin/stats/reports), but this would result in multiple requests from the frontend and a less cohesive dashboard experience.
Performance Optimization: To avoid heavy database queries, caching (e.g., Redis) can be implemented for frequently accessed stats.
Authentication: The endpoint will include admin-only access using role-based access control (RBAC).

👀 Have you spent some time to check if this feature request has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Are you willing to submit PR?

None

@yurimutti yurimutti changed the title 🚀 Feature: admin/dashboard endpoint 🚀 Feature: dashboard/admin endpoint Dec 7, 2024
@yurimutti
Copy link
Contributor Author

Like this:

{
  "platformStats": {
    "totalResiduesReported": 502500.7,
    "totalReportsSubmitted": 12500,
    "activeUsers": 1000,
    "crecyInCirculation": 1000000
  },
  "residueTypes": {
    "plastic": 320000.5,
    "glass": 150000.2,
    "metal": 32500
  },
  "financialPerformance": {
    "crecyPrice": 0.25,
    "totalTransactions": 5000,
    "volumeTransacted": 125000.5
  },
  "topPerformingUsers": [
    {
      "userId": "user_001",
      "name": "John Doe",
      "totalResidues": 2000.5,
      "reportsSubmitted": 30,
      "crecyEarned": 450.75
    },
    {
      "userId": "user_002",
      "name": "Jane Smith",
      "totalResidues": 1800,
      "reportsSubmitted": 25,
      "crecyEarned": 400.25
    }
  ]
}

@yurimutti
Copy link
Contributor Author

We need to validate if role is admin.

@yurimutti yurimutti added this to the Milestone 1 milestone Dec 7, 2024
@yurimutti yurimutti changed the title 🚀 Feature: dashboard/admin endpoint 🚀 Feature: Dashboard/admin endpoint Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant