A clean, high-performance dashboard for visualizing and exploring sales data with cursor-based pagination.
- Overview
- Key Features
- Tech Stack
- Architecture & Decisions
- Getting Started
- Project Structure
- Performance Optimizations
This dashboard interacts with a Sales API to authenticate users, fetch transaction data, apply real-time filters, and visualize sales trends over time.
The main challenge of this build was handling Cursor-Based Pagination (before/after tokens) and crafting a smooth Next/Previous navigation experience without re-fetching stale data.
- Date filtering with Start and End range
- Minimum price search
- Email and Phone filtering
- Instant data refresh on filter updates
- Interactive time-series Area Chart (Recharts)
- Responsive design across all screen sizes
- Before/After cursor-based API navigation
- History Stack to solve the Previous Page problem
- No stale data or repeated requests
- Server-side sorting (Date + Price)
- Loading skeletons for smooth UX
- React Query for server state management
- Instant back navigation using caching
| Category | Technology | Purpose |
|---|---|---|
| Framework | Next.js 14 | App structure & routing |
| Styling | Tailwind CSS | Responsive UI design |
| State / Async | React Query | Data fetching, caching |
| Charting | Recharts | Sales trend visualization |
| Animation | Framer Motion | Visual transitions |
| Icons | Lucide React | Clean SVG icons |
- Prevents duplicate requests
- Caches each page for instant back navigation
- Provides isLoading / isFetching for better UX
The Sales API uses before/after cursor-based pagination, which makes navigating backwards difficult.
Solution:
- A Navigation History Stack stores previous cursors.
- Next → Push current cursor
- Previous → Pop cursor from history
- Ensures smooth and accurate page navigation
- Node.js 18+
- npm or yarn
git clone https://github.com/Umair505/Sales-Dashboard cd sales-dashboard npm install npm run dev
yaml Copy code
Open ➝ http://localhost:3000
Once the development server is running, you can interact with the Sales Dashboard:
- Access the Dashboard: Open
http://localhost:3000in your web browser. - View Sales Overview: The main page (
src/app/page.js) displays an initial overview of sales data, including charts and a table. - Filter Data: Use the Filter Bar at the top (
src/components/dashboard/FilterBar.jsx) to refine the displayed sales data. You can filter by:- Date range (start and end dates)
- Minimum price
- Customer email
- Customer phone number
- Sort order (ascending/descending)
- Analyze Charts: The Sales Chart (
src/components/dashboard/SalesChart.jsx) will dynamically update to visualize sales trends based on your applied filters. - Explore Table Details: The Sales Table (
src/components/dashboard/SalesTable.jsx) provides detailed records. You can:- Sort columns by clicking on their headers.
- Navigate through pages using the pagination controls.
- Real-time Updates: The dashboard utilizes TanStack React Query to efficiently fetch and update data, providing a near real-time experience.
The project follows a standard Next.js application structure with clear separation of concerns:
.
├── public/ # Static assets (images, fonts)
├── src/ # Main application source code
│ ├── app/ # Next.js App Router root layout and pages
│ │ ├── favicon.ico # Site favicon
│ │ ├── globals.css # Global stylesheets
│ │ ├── layout.js # Root layout, global providers (QueryProvider, Toaster)
│ │ └── page.js # Main dashboard page component
│ ├── components/ # Reusable React components
│ │ ├── dashboard/ # Components specific to the dashboard view
│ │ │ ├── FilterBar.jsx # UI for filtering sales data
│ │ │ ├── SalesChart.jsx # Chart visualization of sales data
│ │ │ └── SalesTable.jsx # Table display of sales records
│ │ ├── providers/ # Context providers for global state
│ │ │ └── QueryProvider.jsx # TanStack React Query context
│ │ └── ui/ # Reusable UI primitives (buttons, input, cards, etc.)
│ ├── hooks/ # Custom React hooks
│ │ └── useSalesData.js # Hook for fetching and managing sales data
│ └── lib/ # Utility functions
│ └── utils.js # General utility functions (e.g., for Tailwind CSS class merging)
├── .eslintrc.mjs # ESLint configuration
├── jsconfig.json # JavaScript configuration for VS Code
├── next.config.mjs # Next.js configuration
├── package.json # Project dependencies and scripts
├── postcss.config.mjs # PostCSS configuration (for Tailwind CSS)
└── README.md # Project README file
Contributions are welcome! If you'd like to improve this project, please follow these steps:
- Fork the repository.
- Clone your forked repository:
git clone https://github.com/YOUR_USERNAME/Sales-Dashboard.git - Create a new branch:
git checkout -b feature/your-feature-name - Make your changes.
- Commit your changes:
git commit -m "feat: Add new feature" - Push to the branch:
git push origin feature/your-feature-name - Open a Pull Request against the
mainbranch of the original repository.
Please ensure your code adheres to the project's coding standards and includes appropriate tests if applicable.
