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

[FEAT]: Admin Dashboard Implementation - Backend #133

Open
Juninhotech opened this issue Jul 27, 2024 · 0 comments
Open

[FEAT]: Admin Dashboard Implementation - Backend #133

Juninhotech opened this issue Jul 27, 2024 · 0 comments
Assignees

Comments

@Juninhotech
Copy link
Contributor

Juninhotech commented Jul 27, 2024

Description

Implement a backend API endpoint to provide data for the admin dashboard page, displaying key metrics and product sales data.

Acceptance Criteria (Backend)

  1. API endpoint /api/v1/admin_dashboard is implemented and accessible
  2. The endpoint returns a JSON response with the correct structure, including status, message, and data fields
  3. All required data points (totalRevenue, totalUsers, totalProducts, lifetimeSales, monthlyRevenue, topProducts) are included in the response

Features

  1. Total Revenue
  2. Total Users count
  3. Total Products count
  4. Lifetime Sales amount
  5. Monthly revenue data
  6. Top Products list

Purpose

Create an API endpoint that returns all necessary data for the dashboard in a single request.

Proposed API Endpoint

GET /api/v1/admin_dashboard

Expected Response

Status Code: 200 OK

Content-Type: application/json

Body:

{
  "status": 200,
  "message": "Success",
  "data": {
    "overview": {
      "totalRevenue": 45000.00,
      "totalUsers": 4000,
      "totalProducts": 1000,
      "lifetimeSales": 450000.00
    },
    "monthlyRevenue": [
      { "month": "Jan", "revenue": 4000 },
      { "month": "Feb", "revenue": 3200 },
      { "month": "Mar", "revenue": 5600 },
      { "month": "Apr", "revenue": 5500 },
      { "month": "May", "revenue": 5400 },
      { "month": "Jun", "revenue": 3700 },
      { "month": "Jul", "revenue": 1000 },
      { "month": "Aug", "revenue": 2800 },
      { "month": "Sep", "revenue": 900 },
      { "month": "Oct", "revenue": 4000 },
      { "month": "Nov", "revenue": 0 },
      { "month": "Dec", "revenue": 0 }
    ],
    "topProducts": [
      { "name": "The Lemonade blender", "sales": 500 },
      { "name": "Bean Cake Powder", "sales": 250 },
      { "name": "Flour Mixer", "sales": 230 },
      { "name": "Blender", "sales": 500 },
      { "name": "A Food Product", "sales": 150 },
      { "name": "Cake Powder", "sales": 100 }
    ]
  }
}

Handling Empty Lists

If any list in the response is empty (e.g., no monthly revenue data or no top products), return an empty array for that field rather than omitting it. For example:

{
  "status": 200,
  "message": "Success",
  "data": {
    "overview": {
      "totalRevenue": 0,
      "totalUsers": 0,
      "totalProducts": 0,
      "lifetimeSales": 0
    },
    "monthlyRevenue": [],
    "topProducts": []
  }
}

Unit Testing Requirements

Implement comprehensive unit tests for the dashboard API. Tests should cover:

  • Ensure all required data points are present in the response
  • Verify handling of extreme values (very large numbers, zero values)
  • Test calculation of total revenue, users, products, and lifetime sales

Additional Considerations

  • Implement caching mechanism to improve response time for frequently accessed data
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

No branches or pull requests

1 participant