Skip to content

Conversation

@gustaavik
Copy link
Member

This pull request introduces a comprehensive backend implementation for dashboard statistics, including business logic, data transfer objects, repository interface extensions, and dependency injection for new dashboard functionality. The most important changes are grouped below.

Dashboard Statistics Feature Implementation

  • Added DashboardUseCase in internal/application/usecase/dashboard_usecase.go to aggregate key dashboard metrics (revenue, orders, customers, products, etc.) for a given time period, including logic for period-over-period comparison.
  • Defined new DTOs in internal/domain/dto/dashboard.go for dashboard stats requests, responses, and summary types for recent orders and top products.

Repository Interface Extensions

  • Extended OrderRepository, ProductRepository, and UserRepository interfaces to support dashboard statistics queries such as total revenue, total orders, customer counts, new customers, product counts, and low stock products. [1] [2] [3]

Dependency Injection and Handler Integration

  • Updated handler and use case providers to inject the new dashboard use case and handler, enabling API endpoint support for dashboard statistics. [1] [2] [3] [4] [5] [6]

Documentation

  • Added docs/dashboard_api_examples.md documenting the new dashboard API endpoint, request/response formats, and error handling.

Repository Implementation Adjustments

  • Minor fixes and adjustments in GORM repository code to support new queries and improve correctness. [1] [2] [3] [4]

Other Minor Changes

  • Makefile: streamlined test commands and added a new tygo code generation command. [1] [2]

- Introduced DashboardStatsRequest DTO for handling dashboard statistics requests.
- Implemented PercentageChange, DashboardStats, RecentOrderSummary, and TopProductSummary DTOs for structured data representation.
- Enhanced OrderRepository with methods to retrieve total revenue, total orders, recent orders summary, and top products summary by date range.
- Updated ProductRepository to include methods for counting total products and low stock products.
- Enhanced UserRepository with methods to count total customers and new customers within a date range.
- Created DashboardHandler to manage HTTP requests related to dashboard statistics.
- Added new routes for dashboard statistics in the API server.
- Removed deprecated API client code to streamline the codebase.
- Updated TypeScript DTOs to reflect the new dashboard statistics structure.
@gustaavik gustaavik merged commit a7e3821 into main Aug 25, 2025
5 checks passed
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

Successfully merging this pull request may close these issues.

2 participants